Fixed difficulty stuff
This commit is contained in:
@@ -5,7 +5,7 @@ namespace InterfaceOff.MainMenu
|
|||||||
{
|
{
|
||||||
public class DifficultyManager : MonoBehaviour
|
public class DifficultyManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static float DifficultyMultiplier { get; private set; } = 1;
|
public static float DifficultyMultiplier { get; private set; } = 0.75f;
|
||||||
public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2);
|
public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2);
|
||||||
|
|
||||||
[SerializeField] private Slider DifficultySlider;
|
[SerializeField] private Slider DifficultySlider;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace InterfaceOff.WorldScene
|
|||||||
private bool StoredCurrentScore = false;
|
private bool StoredCurrentScore = false;
|
||||||
private float Score;
|
private float Score;
|
||||||
|
|
||||||
#if UNITY_STANDALONE_WIN
|
#if UNITY_STANDALONE_WIN
|
||||||
|
|
||||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||||
private static void OnStart()
|
private static void OnStart()
|
||||||
|
|||||||
@@ -105,12 +105,14 @@ namespace InterfaceOff
|
|||||||
int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)(ScoreTracker.CurrentScore() * DifficultyManager.DifficultyEffect);
|
int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)(ScoreTracker.CurrentScore() * DifficultyManager.DifficultyEffect);
|
||||||
currentMaxSpawnTime = Math.Clamp(currentMaxSpawnTime, MIN_SPAWN_TIME + 1, MAX_SPAWN_TIME);
|
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 */
|
/* 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)
|
||||||
{
|
{
|
||||||
float difficulty = DifficultyManager.DifficultyMultiplier;
|
float difficulty = DifficultyManager.DifficultyMultiplier;
|
||||||
TimeTillNextSpawn = Random.Range((int)(MIN_SPAWN_TIME * difficulty), (int)(currentMaxSpawnTime * difficulty));
|
TimeTillNextSpawn = Random.Range((int)(MIN_SPAWN_TIME * difficulty), (int)(currentMaxSpawnTime / difficulty));
|
||||||
SpawnNewRandomWindow();
|
SpawnNewRandomWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user