Compare commits
3 Commits
e46f0fff00
...
6f01cd5e71
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f01cd5e71 | ||
|
|
50156a799e | ||
|
|
195e1a5a46 |
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -27,7 +28,7 @@ namespace InterfaceOff.WorldScene
|
||||
[field: SerializeField] private WindowSpawner Spawner { get; set; }
|
||||
[field: SerializeField] private GameObject LeaderboardObject { get; set; }
|
||||
[field: SerializeField] private GameObject LeaderboardEntryPrefab { get; set; }
|
||||
|
||||
|
||||
[field: SerializeField] private InputField PlayerTextNameInput { get; set; }
|
||||
[field: SerializeField] private Button IDRKWhatToCallThis { get; set; }
|
||||
|
||||
@@ -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()
|
||||
@@ -113,7 +112,7 @@ namespace InterfaceOff.WorldScene
|
||||
if (Spawner.AutoSpawn)
|
||||
{
|
||||
StoredCurrentScore = false;
|
||||
|
||||
|
||||
Score = Time.timeSinceLevelLoad * DifficultyManager.DifficultyEffect;
|
||||
ScoreText.text = $"Score: {Score:F1}";
|
||||
}
|
||||
@@ -144,4 +143,4 @@ namespace InterfaceOff.WorldScene
|
||||
|
||||
public void SetPlayerName(string input) => CurrentPlayerName = input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,15 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user