diff --git a/Assets/Scenes/MenuScene.unity b/Assets/Scenes/MenuScene.unity index 7c433bc..37cd0b2 100644 --- a/Assets/Scenes/MenuScene.unity +++ b/Assets/Scenes/MenuScene.unity @@ -1338,7 +1338,7 @@ MonoBehaviour: m_Direction: 0 m_MinValue: 3 m_MaxValue: 5 - m_WholeNumbers: 1 + m_WholeNumbers: 0 m_Value: 4 m_OnValueChanged: m_PersistentCalls: diff --git a/Assets/Scripts/DifficultyManager.cs b/Assets/Scripts/DifficultyManager.cs index 321af97..cb46d31 100644 --- a/Assets/Scripts/DifficultyManager.cs +++ b/Assets/Scripts/DifficultyManager.cs @@ -6,6 +6,8 @@ namespace InterfaceOff.MainMenu public class DifficultyManager : MonoBehaviour { public static float DifficultyMultiplier { get; private set; } = 1; + public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2); + [SerializeField] private Slider DifficultySlider; private void Awake() diff --git a/Assets/Scripts/ScoreTracker.cs b/Assets/Scripts/ScoreTracker.cs index edcf87a..bcffe9f 100644 --- a/Assets/Scripts/ScoreTracker.cs +++ b/Assets/Scripts/ScoreTracker.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using InterfaceOff.MainMenu; using UnityEngine; using UnityEngine.UI; @@ -39,8 +40,8 @@ namespace InterfaceOff.WorldScene { if (Spawner.AutoSpawn) { - ScoreText.text = $"Score: {Time.timeSinceLevelLoad:F1}"; - Score = Time.timeSinceLevelLoad; + Score = Time.timeSinceLevelLoad * DifficultyManager.DifficultyEffect; + ScoreText.text = $"Score: {Score:F1}"; } else diff --git a/Assets/Scripts/WindowSpawner.cs b/Assets/Scripts/WindowSpawner.cs index 258734f..7b12ec5 100644 --- a/Assets/Scripts/WindowSpawner.cs +++ b/Assets/Scripts/WindowSpawner.cs @@ -1,5 +1,6 @@ using System; using Ext.B83.Unity.Attributes; +using InterfaceOff.MainMenu; using InterfaceOff.WorldScene; using UnityEngine; using UnityEngine.SceneManagement; @@ -28,9 +29,7 @@ namespace InterfaceOff [field: SerializeField] public bool AutoSpawn { get; private set; } = true; private int TimeTillNextSpawn { get; set; } - - public static float DifficultyMultiplier = 1f; - + private void Awake() { /* Logs the amount of types found and errors if there is none */ @@ -104,14 +103,15 @@ namespace InterfaceOff const int MIN_SPAWN_TIME = 2 * TICKS_PER_SECOND; const int MAX_SPAWN_TIME = 5 * TICKS_PER_SECOND; - int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)ScoreTracker.CurrentScore(); + int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)(ScoreTracker.CurrentScore() / DifficultyManager.DifficultyEffect); currentMaxSpawnTime = Math.Clamp(currentMaxSpawnTime, MIN_SPAWN_TIME + 1, MAX_SPAWN_TIME); /* Decreases the spawn counter and spawns if at 0 */ TimeTillNextSpawn = Math.Max(0, TimeTillNextSpawn - 1); if (TimeTillNextSpawn == 0) { - TimeTillNextSpawn = Random.Range((int)(MIN_SPAWN_TIME * DifficultyMultiplier), (int)(currentMaxSpawnTime * DifficultyMultiplier)); + float difficulty = DifficultyManager.DifficultyMultiplier; + TimeTillNextSpawn = Random.Range((int)(MIN_SPAWN_TIME * difficulty), (int)(currentMaxSpawnTime * difficulty)); SpawnNewRandomWindow(); } }