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