full turns
This commit is contained in:
parent
7bd61df481
commit
6ff1531662
15 changed files with 879 additions and 100 deletions
42
Assets/Scripts/EnemySpawner.cs
Normal file
42
Assets/Scripts/EnemySpawner.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class EnemySpawner : MonoBehaviour
|
||||
{
|
||||
#region Statication
|
||||
|
||||
public static EnemySpawner instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
instance = this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[SerializeField] private Transform enemyFolder;
|
||||
[SerializeField] private Enemy[] spawnableEnemies;
|
||||
public List<Transform> spawnLocationPos;
|
||||
public List<TileObject> spawnLocations;
|
||||
public void SpawnEnemy(int amount)//Enemy requestedEnemy)
|
||||
{
|
||||
while (amount > 0)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(spawnableEnemies[Random.Range(0, spawnableEnemies.Length)], enemyFolder);
|
||||
TileObject spawnLocation = GridManager.instance.FindClosestEmptyTile(spawnLocations[Random.Range(0, spawnLocations.Count)]);
|
||||
newEnemy.transform.position = spawnLocation.transform.position;
|
||||
newEnemy.currentTile = spawnLocation;
|
||||
newEnemy.currentTile.hasUnit = newEnemy;
|
||||
TurnHandler.instance.enemyEntities.Add(newEnemy);
|
||||
amount--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue