Compare commits

..

3 Commits

Author SHA1 Message Date
Pasha Bibko
6f01cd5e71 Merged difficulty controls 2026-01-27 09:53:30 +00:00
Pasha Bibko
50156a799e Merge 2026-01-27 09:47:56 +00:00
Pasha Bibko
195e1a5a46 Fixed difficulty stuff 2026-01-27 09:47:11 +00:00
4 changed files with 24 additions and 9 deletions

View File

@@ -406,6 +406,7 @@ GameObject:
m_Component:
- component: {fileID: 201752381}
- component: {fileID: 201752382}
- component: {fileID: 201752383}
m_Layer: 5
m_Name: DifficultySlider
m_TagString: Untagged
@@ -482,10 +483,23 @@ MonoBehaviour:
m_MinValue: 3
m_MaxValue: 5
m_WholeNumbers: 0
m_Value: 3
m_Value: 4
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &201752383
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 201752380}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 985fe7203793456f84cbf0526b831a3a, type: 3}
m_Name:
m_EditorClassIdentifier:
DifficultySlider: {fileID: 201752382}
--- !u!1 &217457338
GameObject:
m_ObjectHideFlags: 0

View File

@@ -5,7 +5,7 @@ namespace InterfaceOff.MainMenu
{
public class DifficultyManager : MonoBehaviour
{
public static float DifficultyMultiplier { get; private set; } = 1;
public static float DifficultyMultiplier { get; private set; } = 1f;
public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2);
[SerializeField] private Slider DifficultySlider;

View File

@@ -7,7 +7,8 @@ using UnityEngine.UI;
namespace InterfaceOff.WorldScene
{
[System.Serializable] public struct PlayerScore
[System.Serializable]
public struct PlayerScore
{
public string PlayerName;
public float Score;
@@ -39,7 +40,6 @@ namespace InterfaceOff.WorldScene
private float Score;
#if UNITY_STANDALONE_WIN
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void OnStart()
{
@@ -66,7 +66,6 @@ namespace InterfaceOff.WorldScene
string json = JsonUtility.ToJson(dmp, prettyPrint: false);
File.WriteAllText(Path.Combine(Application.persistentDataPath, "scores.json"), contents: json);
}
#endif // UNITY_STANDALONE_WIN
public static float CurrentScore()

View File

@@ -105,12 +105,14 @@ namespace InterfaceOff
int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)(ScoreTracker.CurrentScore() * DifficultyManager.DifficultyEffect);
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 */
TimeTillNextSpawn = Math.Max(0, TimeTillNextSpawn - 1);
if (TimeTillNextSpawn == 0)
{
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();
}
}