Update Ability to Change Difficulty Scale Type

This commit is contained in:
Philip W 2021-11-14 16:49:45 +00:00
parent 31b445bc82
commit b4273b69f3
3 changed files with 24 additions and 10 deletions
Unity-Files/Assets
Examples/Defender
Scripts/Gameplay

@ -2568,6 +2568,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
time: {fileID: 542591968}
difficultyType: 1
incrementDifficultyInSeconds: 30
incrementAmountInSeconds: 25
--- !u!1 &1019999843

@ -148,7 +148,7 @@ SortingGroup:
m_Enabled: 1
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -6
m_SortingOrder: 1
--- !u!1 &8759752071964469198
GameObject:
m_ObjectHideFlags: 0

@ -2,27 +2,40 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DifficultyScale : MonoBehaviour
{
public GameObject time;
public TypeOfDifficulty difficultyType;
[SerializeField] private int incrementDifficultyInSeconds = 30;
[SerializeField] private int incrementAmountInSeconds = 25;
private int currentDifficultyLevel = 0;
// Start is called before the first frame update
void Start()
public enum TypeOfDifficulty
{
Exponential,
Constant
}
// Update is called once per frame
void Update()
{
if (((Mathf.FloorToInt(time.GetComponent<UITimer>().time) - (incrementAmountInSeconds * currentDifficultyLevel)) / incrementDifficultyInSeconds) == 1)
switch (difficultyType)
{
currentDifficultyLevel++;
incrementDifficultyInSeconds += incrementAmountInSeconds;
this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f;
case TypeOfDifficulty.Exponential:
if (((Mathf.FloorToInt(time.GetComponent<UITimer>().time) - (incrementAmountInSeconds * currentDifficultyLevel)) / incrementDifficultyInSeconds) == 1)
{
currentDifficultyLevel++;
incrementDifficultyInSeconds += incrementAmountInSeconds;
this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f;
}
break;
case TypeOfDifficulty.Constant:
if ((Mathf.FloorToInt(time.GetComponent<UITimer>().time) >= (incrementDifficultyInSeconds * (currentDifficultyLevel + 1))))
{
currentDifficultyLevel++;
this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f;
}
break;
}
}
}