Wave size increases by x every y wave

This commit is contained in:
Soulaha Balde 2022-04-03 15:58:24 -04:00
parent b60ff1ca91
commit ef113a6a43
4 changed files with 14 additions and 10 deletions

View File

@ -208,10 +208,6 @@ PrefabInstance:
propertyPath: m_Name
value: SceneStuff
objectReference: {fileID: 0}
- target: {fileID: 8365024802335227869, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3}
propertyPath: orthographic size
value: 10.5
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f7f5d2b1228d13f4d9015073aced3e81, type: 3}
--- !u!4 &720678398 stripped

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9145057a34a60964eb8cc79037227889
guid: 8b8f40b774485ae4588cba2c53f8ac9d
DefaultImporter:
externalObjects: {}
userData:

View File

@ -33,6 +33,7 @@ public class Arena : MonoBehaviour {
public Transform graveyard { get; private set; } = null!;
SafeZone safeZone = null!;
[field: SerializeField]int currWaveSize = 0;
void Awake() => safeZone = GetComponentInChildren<SafeZone>();
@ -51,17 +52,21 @@ public class Arena : MonoBehaviour {
IEnumerator SpawnEnemies() {
yield return new WaitForSeconds(stats.initWaitToSpawn);
currWaveSize = stats.initWaveSize;
int currentSpawner = 0;
int amountSpawned = 0;
int wave = 1;
while(true){
while (amountSpawned < stats.waveSize) {
while (amountSpawned < currWaveSize) {
currentSpawner = Random.Range(0, spawners.Length);
SpawnEnemy(currentSpawner);
amountSpawned++;
amountSpawned++;
}
if(wave++ >= stats.increaseWaveStep){
if((currWaveSize += stats.waveIncrease) > stats.maxWaveSize) currWaveSize=stats.maxWaveSize;
}
yield return new WaitForSeconds(stats.secondsBetweenSpawners);
amountSpawned = 0;
yield return new WaitForSeconds(stats.secondsBetweenSpawners);
}
}

View File

@ -4,6 +4,9 @@
public class ArenaStats : ScriptableObject {
[Min(0f)] public float secondsBetweenSpawners = 3f;
[Min(0f)] public float initWaitToSpawn = 3f;
[Min(0f)] public float waveSize = 3f;
[Min(0f)] public int initWaveSize = 3;
[Min(0f)] public int maxWaveSize = 10;
[Min(0f), Tooltip("The amount of gladiator to add to wave")] public int waveIncrease = 1;
[Min(0f), Tooltip("How many waves before we increase by WaveIncrease")] public int increaseWaveStep = 3;
}