Added scaled difficulty

This commit is contained in:
2026-01-22 23:25:16 +00:00
parent 3c25ec932f
commit e79ff061a7
4 changed files with 11 additions and 8 deletions

View File

@@ -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();
}
}