Fixed spawning decrementation and changing spawner objectives dynamically
This commit is contained in:
parent
8921c898ec
commit
bc4b4c30a8
@ -17,6 +17,8 @@ MonoBehaviour:
|
||||
_count: 4
|
||||
- _enemy: {fileID: 80204295746100150, guid: 5bbf0d85fa5bb3f4599da79f0a84e3a9, type: 3}
|
||||
_count: 4
|
||||
- _enemy: {fileID: 80204295746100150, guid: 2419a879bd4e47d4fa8b30de0fcdde42, type: 3}
|
||||
_count: 6
|
||||
_nestedGroupSpawn:
|
||||
- groupSpawn:
|
||||
- _enemy: {fileID: 80204295746100150, guid: 5bbf0d85fa5bb3f4599da79f0a84e3a9, type: 3}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using Codice.CM.Client.Differences;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@ -18,6 +18,7 @@ public class WaveConfig : ScriptableObject
|
||||
private float _gameDuration = 1;
|
||||
private float _enemySpawndOnStart = 0;
|
||||
private int _enemySum = 0;
|
||||
private List<GameObject> _constraintList = new List<GameObject>();
|
||||
public List<EnemyType> ConstantSpawn
|
||||
{
|
||||
get
|
||||
@ -64,14 +65,24 @@ public class WaveConfig : ScriptableObject
|
||||
return _constantSpawn[0];
|
||||
} else if (constraint != null)
|
||||
{
|
||||
EnemyType randomEnemy;
|
||||
do
|
||||
if (!_constraintList.Contains(constraint))
|
||||
{
|
||||
randomEnemy = _constantSpawn[Random.Range(0, _constantSpawn.Count)];
|
||||
} while (randomEnemy.GetEnemyObject() == constraint);
|
||||
_constraintList.Add(constraint);
|
||||
}
|
||||
if (_constraintList.Count < _constantSpawn.Count)
|
||||
{
|
||||
EnemyType randomEnemy;
|
||||
do
|
||||
{
|
||||
randomEnemy = _constantSpawn[Random.Range(0, _constantSpawn.Count)];
|
||||
} while (_constraintList.Contains(randomEnemy.GetEnemyObject()));
|
||||
return randomEnemy;
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return _constantSpawn[Random.Range(0, _constantSpawn.Count - 1)];
|
||||
return _constantSpawn[Random.Range(0, _constantSpawn.Count)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -81,7 +81,7 @@ public class WaveObserver : Singleton<WaveObserver>
|
||||
spawnerSubject.ChangeSpawnSpeed(_levelConfig.Interval * _spawnerTiming);
|
||||
for (int spawnIndex = 0; spawnIndex < _copyConstantSpawn.Count; spawnIndex++)
|
||||
{
|
||||
if (_copyConstantSpawn[spawnIndex] == 0)
|
||||
if (_copyConstantSpawn[spawnIndex] == 0) //Doesn't compare this iteration because it's already empty
|
||||
{
|
||||
Debug.Log("--I'm empty--");
|
||||
continue;
|
||||
@ -97,15 +97,15 @@ public class WaveObserver : Singleton<WaveObserver>
|
||||
{
|
||||
if (spawner.Prefab.Equals(paramPrefab))
|
||||
{
|
||||
GameObject randomEnemy = _levelConfig.GetRandomSpawn(paramPrefab).GetEnemyObject();
|
||||
if (randomEnemy == spawner.Prefab)
|
||||
EnemyType randomEnemy = _levelConfig.GetRandomSpawn(paramPrefab);
|
||||
if (randomEnemy?.GetEnemyObject() == spawner.Prefab || randomEnemy == null)
|
||||
{
|
||||
spawner.StopSpawn();
|
||||
Debug.Log("----Spawn Stopped----");
|
||||
}
|
||||
else
|
||||
{
|
||||
spawner.Prefab = randomEnemy;
|
||||
spawner.Prefab = randomEnemy.GetEnemyObject();
|
||||
Debug.Log("----Spawn Changed!!!----");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user