PR corrections

This commit is contained in:
Ader Alisma 01 2023-10-22 15:28:34 -04:00
parent e4fe735fe5
commit c57417a583
4 changed files with 26 additions and 25 deletions

View File

@ -36,10 +36,12 @@ public class WaveConfig : ScriptableObject
return _nestedGroupSpawn;
}
}
public float GetInterval()
public float Interval
{
float interval = _gameDuration * 60.0f / (_enemySum > 0 ? _enemySum.ToFloat() : SumCount());
return interval;
get {
float interval = _gameDuration * 60.0f / (_enemySum > 0 ? _enemySum.ToFloat() : SumCount());
return interval;
}
}
/**
* Returns the updated game interval after adjusting to enemies spawned at the start

View File

@ -14,23 +14,21 @@ public class WaveObserver : Singleton<WaveObserver>
private List<int> _intervalTiming = new List<int>();
private bool _once = true;
private int _currentGroupIndex = 0;
public WaveConfig LevelConfig
public void SetLevelConfig(WaveConfig config)
{
set
_levelConfig = config;
_copyConstantSpawn = new List<int>();
_copyGroupSpawn = new List<GroupList>();
_groupSpawnTimers = new List<float>();
foreach (EnemyType enemy in _levelConfig.ConstantSpawn)
{
_levelConfig = value;
_copyConstantSpawn = new List<int>();
_copyGroupSpawn = new List<GroupList>();
_groupSpawnTimers = new List<float>();
foreach (EnemyType enemy in _levelConfig.ConstantSpawn)
{
_copyConstantSpawn.Add(enemy.Count);
}
for (int index = 0; index < _levelConfig.NestedGroupSpawn.Count; index++)
{
_copyGroupSpawn.Add(_levelConfig.NestedGroupSpawn[index]);
_groupSpawnTimers.Add(_levelConfig.NestedGroupSpawn[index].triggerTime);
}
_copyConstantSpawn.Add(enemy.Count);
}
for (int index = 0; index < _levelConfig.NestedGroupSpawn.Count; index++)
{
_copyGroupSpawn.Add(_levelConfig.NestedGroupSpawn[index]);
_groupSpawnTimers.Add(_levelConfig.NestedGroupSpawn[index].triggerTime);
}
}
@ -49,7 +47,7 @@ public class WaveObserver : Singleton<WaveObserver>
if (_once)
{
_once = false;
spawnerSubject.GroupSpawnTimers = _groupSpawnTimers;
spawnerSubject.SetGroupSpawnTimers(_groupSpawnTimers);
}
}
@ -60,7 +58,7 @@ public class WaveObserver : Singleton<WaveObserver>
public void NotifySpawned(SpawnerTile spawnerSubject)
{
GameObject paramPrefab = spawnerSubject.Prefab;
spawnerSubject.ChangeSpawnSpeed(_levelConfig.GetInterval() * _spawnerTiming);
spawnerSubject.ChangeSpawnSpeed(_levelConfig.Interval * _spawnerTiming);
if (paramPrefab.Equals(_levelConfig.ConstantSpawn[0].GetEnemyObject()))
{
int currentCount = 0;
@ -152,7 +150,7 @@ public class WaveObserver : Singleton<WaveObserver>
{
index = rand.Next(_subjects.Count);
} while (_intervalTiming.Count <= index);
spawnerTile.ChangeSpawnSpeed(_levelConfig.GetInterval() * _intervalTiming[index]);
spawnerTile.ChangeSpawnSpeed(_levelConfig.Interval * _intervalTiming[index]);
_intervalTiming.Remove(index);
}

View File

@ -166,7 +166,7 @@ public class LevelManager : Singleton<LevelManager>
_currentLevel = level;
_waveObserver = WaveObserver.Instance;
_waveObserver.LevelConfig = _currentLevel.WaveConfig;
_waveObserver.SetLevelConfig(_currentLevel.WaveConfig);
Grid grid = Object.FindObjectOfType<Grid>();
//create new grid if there is none
if (!grid)

View File

@ -17,11 +17,12 @@ public class SpawnerTile : LevelTile
private bool _stopped = false;
private bool _cooldownEnded = false;
private List<float> _groupSpawnTimers = new List<float>();
public List<float> GroupSpawnTimers
public void SetGroupSpawnTimers(List<float> groupSpawnTimers)
{
set
for (int i = 0; i < groupSpawnTimers.Count-1; i++)
{
_groupSpawnTimers = value;
_groupSpawnTimers.Add(groupSpawnTimers[i]);
}
}