Added scaled difficulty
This commit is contained in:
@@ -1338,7 +1338,7 @@ MonoBehaviour:
|
|||||||
m_Direction: 0
|
m_Direction: 0
|
||||||
m_MinValue: 3
|
m_MinValue: 3
|
||||||
m_MaxValue: 5
|
m_MaxValue: 5
|
||||||
m_WholeNumbers: 1
|
m_WholeNumbers: 0
|
||||||
m_Value: 4
|
m_Value: 4
|
||||||
m_OnValueChanged:
|
m_OnValueChanged:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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; } = 1;
|
||||||
|
public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2);
|
||||||
|
|
||||||
[SerializeField] private Slider DifficultySlider;
|
[SerializeField] private Slider DifficultySlider;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using InterfaceOff.MainMenu;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -39,8 +40,8 @@ namespace InterfaceOff.WorldScene
|
|||||||
{
|
{
|
||||||
if (Spawner.AutoSpawn)
|
if (Spawner.AutoSpawn)
|
||||||
{
|
{
|
||||||
ScoreText.text = $"Score: {Time.timeSinceLevelLoad:F1}";
|
Score = Time.timeSinceLevelLoad * DifficultyManager.DifficultyEffect;
|
||||||
Score = Time.timeSinceLevelLoad;
|
ScoreText.text = $"Score: {Score:F1}";
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Ext.B83.Unity.Attributes;
|
using Ext.B83.Unity.Attributes;
|
||||||
|
using InterfaceOff.MainMenu;
|
||||||
using InterfaceOff.WorldScene;
|
using InterfaceOff.WorldScene;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@@ -28,9 +29,7 @@ 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 */
|
||||||
@@ -104,14 +103,15 @@ namespace InterfaceOff
|
|||||||
const int MIN_SPAWN_TIME = 2 * TICKS_PER_SECOND;
|
const int MIN_SPAWN_TIME = 2 * TICKS_PER_SECOND;
|
||||||
const int MAX_SPAWN_TIME = 5 * 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);
|
currentMaxSpawnTime = Math.Clamp(currentMaxSpawnTime, MIN_SPAWN_TIME + 1, MAX_SPAWN_TIME);
|
||||||
|
|
||||||
/* 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((int)(MIN_SPAWN_TIME * DifficultyMultiplier), (int)(currentMaxSpawnTime * DifficultyMultiplier));
|
float difficulty = DifficultyManager.DifficultyMultiplier;
|
||||||
|
TimeTillNextSpawn = Random.Range((int)(MIN_SPAWN_TIME * difficulty), (int)(currentMaxSpawnTime * difficulty));
|
||||||
SpawnNewRandomWindow();
|
SpawnNewRandomWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user