Added adaptive score
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Ext.B83.Unity.Attributes;
|
using Ext.B83.Unity.Attributes;
|
||||||
|
using InterfaceOff.WorldScene;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
@@ -28,6 +29,8 @@ namespace InterfaceOff
|
|||||||
[field: SerializeField] public bool AutoSpawn { get; private set; } = true;
|
[field: SerializeField] public bool AutoSpawn { get; private set; } = true;
|
||||||
private int TimeTillNextSpawn { get; set; }
|
private int TimeTillNextSpawn { get; set; }
|
||||||
|
|
||||||
|
public static float DifficultyMultiplier = 1f;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
/* Logs the amount of types found and errors if there is none */
|
/* Logs the amount of types found and errors if there is none */
|
||||||
@@ -97,15 +100,19 @@ namespace InterfaceOff
|
|||||||
/* Spawns new windows whilst active */
|
/* Spawns new windows whilst active */
|
||||||
if (AutoSpawn)
|
if (AutoSpawn)
|
||||||
{
|
{
|
||||||
const int TICKS_PER_SECOND = 20;
|
const int TICKS_PER_SECOND = 20; // Unity constant
|
||||||
const int MINIMUM_SPAWN_TIME = 2 * TICKS_PER_SECOND;
|
const int MIN_SPAWN_TIME = 2 * TICKS_PER_SECOND;
|
||||||
const int MAXIMUM_SPAWN_TIME = 5 * TICKS_PER_SECOND;
|
const int MAX_SPAWN_TIME = 5 * TICKS_PER_SECOND;
|
||||||
|
|
||||||
|
int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)ScoreTracker.CurrentScore();
|
||||||
|
currentMaxSpawnTime = Math.Clamp(currentMaxSpawnTime, MIN_SPAWN_TIME + 1, MAX_SPAWN_TIME);
|
||||||
|
Debug.Log(currentMaxSpawnTime);
|
||||||
|
|
||||||
/* Decreases the spawn counter and spawns if at 0 */
|
/* Decreases the spawn counter and spawns if at 0 */
|
||||||
TimeTillNextSpawn = Math.Max(0, TimeTillNextSpawn - 1);
|
TimeTillNextSpawn = Math.Max(0, TimeTillNextSpawn - 1);
|
||||||
if (TimeTillNextSpawn == 0)
|
if (TimeTillNextSpawn == 0)
|
||||||
{
|
{
|
||||||
TimeTillNextSpawn = Random.Range(MINIMUM_SPAWN_TIME, MAXIMUM_SPAWN_TIME);
|
TimeTillNextSpawn = Random.Range((int)(MIN_SPAWN_TIME * DifficultyMultiplier), (int)(currentMaxSpawnTime * DifficultyMultiplier));
|
||||||
SpawnNewRandomWindow();
|
SpawnNewRandomWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user