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: m_Component:
- component: {fileID: 201752381} - component: {fileID: 201752381}
- component: {fileID: 201752382} - component: {fileID: 201752382}
- component: {fileID: 201752383}
m_Layer: 5 m_Layer: 5
m_Name: DifficultySlider m_Name: DifficultySlider
m_TagString: Untagged m_TagString: Untagged
@@ -482,10 +483,23 @@ MonoBehaviour:
m_MinValue: 3 m_MinValue: 3
m_MaxValue: 5 m_MaxValue: 5
m_WholeNumbers: 0 m_WholeNumbers: 0
m_Value: 3 m_Value: 4
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] 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 --- !u!1 &217457338
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -5,7 +5,7 @@ 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; } = 1f;
public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2); public static float DifficultyEffect => Mathf.Pow(f: DifficultyMultiplier, p: 2);
[SerializeField] private Slider DifficultySlider; [SerializeField] private Slider DifficultySlider;

View File

@@ -7,7 +7,8 @@ using UnityEngine.UI;
namespace InterfaceOff.WorldScene namespace InterfaceOff.WorldScene
{ {
[System.Serializable] public struct PlayerScore [System.Serializable]
public struct PlayerScore
{ {
public string PlayerName; public string PlayerName;
public float Score; public float Score;
@@ -27,7 +28,7 @@ namespace InterfaceOff.WorldScene
[field: SerializeField] private WindowSpawner Spawner { get; set; } [field: SerializeField] private WindowSpawner Spawner { get; set; }
[field: SerializeField] private GameObject LeaderboardObject { get; set; } [field: SerializeField] private GameObject LeaderboardObject { get; set; }
[field: SerializeField] private GameObject LeaderboardEntryPrefab { get; set; } [field: SerializeField] private GameObject LeaderboardEntryPrefab { get; set; }
[field: SerializeField] private InputField PlayerTextNameInput { get; set; } [field: SerializeField] private InputField PlayerTextNameInput { get; set; }
[field: SerializeField] private Button IDRKWhatToCallThis { get; set; } [field: SerializeField] private Button IDRKWhatToCallThis { get; set; }
@@ -39,7 +40,6 @@ namespace InterfaceOff.WorldScene
private float Score; private float Score;
#if UNITY_STANDALONE_WIN #if UNITY_STANDALONE_WIN
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void OnStart() private static void OnStart()
{ {
@@ -66,7 +66,6 @@ namespace InterfaceOff.WorldScene
string json = JsonUtility.ToJson(dmp, prettyPrint: false); string json = JsonUtility.ToJson(dmp, prettyPrint: false);
File.WriteAllText(Path.Combine(Application.persistentDataPath, "scores.json"), contents: json); File.WriteAllText(Path.Combine(Application.persistentDataPath, "scores.json"), contents: json);
} }
#endif // UNITY_STANDALONE_WIN #endif // UNITY_STANDALONE_WIN
public static float CurrentScore() public static float CurrentScore()
@@ -113,7 +112,7 @@ namespace InterfaceOff.WorldScene
if (Spawner.AutoSpawn) if (Spawner.AutoSpawn)
{ {
StoredCurrentScore = false; StoredCurrentScore = false;
Score = Time.timeSinceLevelLoad * DifficultyManager.DifficultyEffect; Score = Time.timeSinceLevelLoad * DifficultyManager.DifficultyEffect;
ScoreText.text = $"Score: {Score:F1}"; ScoreText.text = $"Score: {Score:F1}";
} }
@@ -144,4 +143,4 @@ namespace InterfaceOff.WorldScene
public void SetPlayerName(string input) => CurrentPlayerName = input; public void SetPlayerName(string input) => CurrentPlayerName = input;
} }
} }

View File

@@ -104,13 +104,15 @@ namespace InterfaceOff
int currentMaxSpawnTime = MAX_SPAWN_TIME - (int)(ScoreTracker.CurrentScore() * DifficultyManager.DifficultyEffect); 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);
Debug.Log($"Max: [{currentMaxSpawnTime}] with difficulty [{DifficultyManager.DifficultyEffect}]");
/* 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)
{ {
float difficulty = DifficultyManager.DifficultyMultiplier; 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(); SpawnNewRandomWindow();
} }
} }