added temp scene and wave based enemy
This commit is contained in:
@@ -8,9 +8,12 @@ namespace Darkmatter.Presentation
|
||||
public class EnemiesSpawnner : MonoBehaviour
|
||||
{
|
||||
[Inject] IEnemyFactory _enemyFactory;
|
||||
public int enemiesPerWave = 5;
|
||||
public int baseEnemyCount =2;
|
||||
private ObjectPool<IEnemyPawn> _enemyPool;
|
||||
|
||||
private int killedEnemies = 0;
|
||||
private int enemiesMultiplier = 1;
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -41,21 +44,30 @@ namespace Darkmatter.Presentation
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpawnWave();
|
||||
SpawnWave(enemiesMultiplier);
|
||||
}
|
||||
|
||||
private void SpawnWave()
|
||||
private void SpawnWave(int multiplier)
|
||||
{
|
||||
for (int i = 0; i < enemiesPerWave; i++)
|
||||
for (int i = 0; i < baseEnemyCount*multiplier; i++)
|
||||
{
|
||||
IEnemyPawn enemy = _enemyPool.Get();
|
||||
enemy.GameObject.transform.position = enemy.PatrolPoints[Random.Range(0, enemy.PatrolPoints.Count)].position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ReturnEnemy(IEnemyPawn enemy)
|
||||
{
|
||||
enemy.Reset();
|
||||
_enemyPool.Release(enemy);
|
||||
killedEnemies++;
|
||||
if(killedEnemies == baseEnemyCount*enemiesMultiplier)
|
||||
{
|
||||
killedEnemies = 0;
|
||||
enemiesMultiplier++;
|
||||
SpawnWave(enemiesMultiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,5 +58,12 @@ namespace Darkmatter.Presentation
|
||||
this.PlayerTarget = player;
|
||||
this.PatrolPoints = patrolPoints;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Health = 100;
|
||||
enemyAI.enabled = true;
|
||||
isDead = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user