Made the password checker spawn randomlu
This commit is contained in:
@@ -96,14 +96,16 @@ namespace InterfaceOff
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (Random.Range(0, 1000) == 500)
|
||||
{
|
||||
PasswordField.SetActive(true);
|
||||
}
|
||||
|
||||
/* Spawns new windows whilst active */
|
||||
if (AutoSpawn)
|
||||
{
|
||||
/* Has a random choice for the PasswordField to show up */
|
||||
if (Random.Range(0, 1000) == 500)
|
||||
{
|
||||
PasswordField.SetActive(true);
|
||||
}
|
||||
|
||||
/* Calculates the current max spawn time */
|
||||
const int TICKS_PER_SECOND = 20; // Unity constant
|
||||
const int MIN_SPAWN_TIME = 2 * TICKS_PER_SECOND;
|
||||
const int MAX_SPAWN_TIME = 5 * TICKS_PER_SECOND;
|
||||
@@ -111,8 +113,6 @@ namespace InterfaceOff
|
||||
int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)(ScoreTracker.CurrentScore() * DifficultyManager.DifficultyEffect);
|
||||
currentMaxSpawnTime = Math.Clamp(currentMaxSpawnTime, MIN_SPAWN_TIME + 1, MAX_SPAWN_TIME);
|
||||
|
||||
Debug.Log($"Max: [{currentMaxSpawnTime}] with difficulty [{DifficultyManager.DifficultyEffect}]");
|
||||
|
||||
/* Decreases the spawn counter and spawns if at 0 */
|
||||
TimeTillNextSpawn = Math.Max(0, TimeTillNextSpawn - 1);
|
||||
if (TimeTillNextSpawn == 0)
|
||||
@@ -122,16 +122,22 @@ namespace InterfaceOff
|
||||
SpawnNewRandomWindow();
|
||||
}
|
||||
}
|
||||
|
||||
/* Else checks if it should reload the scene */
|
||||
else if (Input.GetKey(KeyCode.Space))
|
||||
|
||||
else
|
||||
{
|
||||
SceneController.ReloadScene();
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
SceneController.Load(name: "MenuScene");
|
||||
/* Makes sure the password overlay does not interfere */
|
||||
PasswordField.SetActive(false);
|
||||
|
||||
/* Else checks if it should change the active scene */
|
||||
if (Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
SceneController.ReloadScene();
|
||||
}
|
||||
|
||||
else if (Input.GetKey(KeyCode.Tab))
|
||||
{
|
||||
SceneController.Load(name: "MenuScene");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user