From bd28e30da54baca4d008ea373c2d3c66b41100e5 Mon Sep 17 00:00:00 2001 From: Ader Alisma 01 Date: Sun, 3 Mar 2024 13:41:23 -0500 Subject: [PATCH] Comments + variable structure --- Assets/Scripts/LevelConfig/WaveConfig.cs | 6 ++++-- Assets/Scripts/LevelConfig/WaveObserver.cs | 19 ++++++++----------- Assets/Scripts/Tiles/SpawnerTile.cs | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Assets/Scripts/LevelConfig/WaveConfig.cs b/Assets/Scripts/LevelConfig/WaveConfig.cs index 4fd06c4..b994da8 100644 --- a/Assets/Scripts/LevelConfig/WaveConfig.cs +++ b/Assets/Scripts/LevelConfig/WaveConfig.cs @@ -15,10 +15,10 @@ public class WaveConfig : ScriptableObject [SerializeField] private List _nestedGroupSpawn = new List(); [SerializeField] + private List _constraintList = new List(); //List of depleted enemies private float _gameDuration = 1; private float _enemySpawndOnStart = 0; private int _enemySum = 0; - private List _constraintList = new List(); public List ConstantSpawn { get @@ -57,6 +57,8 @@ public class WaveConfig : ScriptableObject /** * Returns a random enemy among the constantSpawn list + * Called when assigning a new enemy to a spawner + * When given, ensures that assigned enemy hasn't depleted */ public EnemyType GetRandomSpawn(GameObject constraint = null) { @@ -76,7 +78,7 @@ public class WaveConfig : ScriptableObject { randomEnemy = _constantSpawn[Random.Range(0, _constantSpawn.Count)]; } while (_constraintList.Contains(randomEnemy.GetEnemyObject())); - return randomEnemy; + return randomEnemy; } else { return null; diff --git a/Assets/Scripts/LevelConfig/WaveObserver.cs b/Assets/Scripts/LevelConfig/WaveObserver.cs index 4f8f117..4d6e660 100644 --- a/Assets/Scripts/LevelConfig/WaveObserver.cs +++ b/Assets/Scripts/LevelConfig/WaveObserver.cs @@ -5,17 +5,18 @@ using UnityEngine; public class WaveObserver : Singleton { + private const int MAXTOUGHNESS = 10; + private List _subjects = new List(); private List _aliveEnemyCount = new List(); - private List _copyConstantSpawn; - private List> _copyGroupSpawn; //Contains count of enemies per group private List _groupSpawnTimers; - private WaveConfig _levelConfig; - private const int MAXTOUGHNESS = 10; - private int _spawnerTiming = 0; + private List _copyConstantSpawn; private List _intervalTiming = new List(); - private bool _once = true; + private List> _copyGroupSpawn; //Contains count of enemies per group + private WaveConfig _levelConfig; + private int _spawnerTiming = 0; private int _currentGroupIndex = 0; + private bool _once = true; public void Init(WaveConfig config) { @@ -83,14 +84,12 @@ public class WaveObserver : Singleton { if (_copyConstantSpawn[spawnIndex] == 0) //Doesn't compare this iteration because it's already empty { - Debug.Log("--I'm empty--"); continue; } if (paramPrefab.Equals(_levelConfig.ConstantSpawn[spawnIndex].GetEnemyObject())) { _copyConstantSpawn[spawnIndex]--; - Debug.Log("Amout to spawn is now: " + _copyConstantSpawn[spawnIndex]); if (_copyConstantSpawn[spawnIndex] == 0) { foreach (SpawnerTile spawner in _subjects) @@ -101,12 +100,10 @@ public class WaveObserver : Singleton if (randomEnemy?.GetEnemyObject() == spawner.Prefab || randomEnemy == null) { spawner.StopSpawn(); - Debug.Log("----Spawn Stopped----"); } else { spawner.Prefab = randomEnemy.GetEnemyObject(); - Debug.Log("----Spawn Changed!!!----"); } } } @@ -222,7 +219,7 @@ public class WaveObserver : Singleton if (_copyGroupSpawn[_currentGroupIndex][groupIndex] != 0) { CycleRows(usedRows, currentGroup, groupIndex); - /*If group is done OR max rows reached while group is not done*/ + // If group is done OR max rows reached while group is not done if (_copyGroupSpawn[_currentGroupIndex][groupIndex] > 0 || (usedRows.Count == _subjects.Count && _copyGroupSpawn[_currentGroupIndex][groupIndex] > 0)) { return false; diff --git a/Assets/Scripts/Tiles/SpawnerTile.cs b/Assets/Scripts/Tiles/SpawnerTile.cs index f0698f0..e668a4b 100644 --- a/Assets/Scripts/Tiles/SpawnerTile.cs +++ b/Assets/Scripts/Tiles/SpawnerTile.cs @@ -60,9 +60,7 @@ public class SpawnerTile : LevelTile } } } - //Debug.Log("Time: " + _spawnCounter); if (_spawnCounter < _spawnSpeed) return; - Debug.Log("Stopped but still spawning"); _spawnCounter = 0; if (!_cooldownEnded) {