Added scaled difficulty
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Ext.B83.Unity.Attributes;
|
||||
using InterfaceOff.MainMenu;
|
||||
using InterfaceOff.WorldScene;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -29,8 +30,6 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user