Update Script For Scaling Based On Time

This commit is contained in:
Philip W 2021-11-11 05:29:36 +00:00
parent d314abe509
commit f4acd46409
2 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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<UITimer>().time) / difficultyScaleInSeconds) + 1 == nextDifficultyLevel)
if (((Mathf.FloorToInt(time.GetComponent<UITimer>().time) - (incrementAmountInSeconds * currentDifficultyLevel)) / incrementDifficultyInSeconds) + 1 == 2)
{
nextDifficultyLevel++;
currentDifficultyLevel++;
incrementDifficultyInSeconds += incrementAmountInSeconds;
this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f;
}
}