From f4acd46409b68b7ff94f5e7a49fcff82822ed855 Mon Sep 17 00:00:00 2001 From: Philip White Date: Thu, 11 Nov 2021 05:29:36 +0000 Subject: [PATCH] Update Script For Scaling Based On Time --- Unity-Files/Assets/Examples/Defender/Defender.unity | 3 ++- Unity-Files/Assets/Scripts/Gameplay/DifficultyScale.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Unity-Files/Assets/Examples/Defender/Defender.unity b/Unity-Files/Assets/Examples/Defender/Defender.unity index 94063e5..97973c5 100644 --- a/Unity-Files/Assets/Examples/Defender/Defender.unity +++ b/Unity-Files/Assets/Examples/Defender/Defender.unity @@ -2354,7 +2354,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: time: {fileID: 542591968} - difficultyScaleInSeconds: 30 + incrementDifficultyInSeconds: 30 + incrementAmountInSeconds: 25 --- !u!1 &1019999843 GameObject: m_ObjectHideFlags: 0 diff --git a/Unity-Files/Assets/Scripts/Gameplay/DifficultyScale.cs b/Unity-Files/Assets/Scripts/Gameplay/DifficultyScale.cs index e71d6bd..53c5301 100644 --- a/Unity-Files/Assets/Scripts/Gameplay/DifficultyScale.cs +++ b/Unity-Files/Assets/Scripts/Gameplay/DifficultyScale.cs @@ -5,8 +5,9 @@ using UnityEngine; public class DifficultyScale : MonoBehaviour { public GameObject time; - [SerializeField] private int difficultyScaleInSeconds = 30; - private int nextDifficultyLevel = 2; + [SerializeField] private int incrementDifficultyInSeconds = 30; + [SerializeField] private int incrementAmountInSeconds = 25; + private int currentDifficultyLevel = 0; // Start is called before the first frame update void Start() @@ -17,9 +18,10 @@ public class DifficultyScale : MonoBehaviour // Update is called once per frame void Update() { - if ((Mathf.FloorToInt(time.GetComponent().time) / difficultyScaleInSeconds) + 1 == nextDifficultyLevel) + if (((Mathf.FloorToInt(time.GetComponent().time) - (incrementAmountInSeconds * currentDifficultyLevel)) / incrementDifficultyInSeconds) + 1 == 2) { - nextDifficultyLevel++; + currentDifficultyLevel++; + incrementDifficultyInSeconds += incrementAmountInSeconds; this.GetComponent().spawnInterval = this.GetComponent().spawnInterval * 0.5f; } }