2019-04-27 20:19:35 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class TurnHandler : MonoBehaviour
|
|
|
|
{
|
|
|
|
public void OnTurn() {
|
2019-04-28 14:28:31 +00:00
|
|
|
Entity[] entities = gameObject.GetComponentsInChildren<Entity>();
|
|
|
|
foreach(Entity entity in entities) {
|
|
|
|
//Check for deaths
|
|
|
|
if(entity.hp <= 0) {
|
|
|
|
entity.Die();
|
|
|
|
}
|
|
|
|
//Move AIs
|
|
|
|
if(entity is AI) {
|
|
|
|
AI ai = entity as AI;
|
|
|
|
ai.OnTurn();
|
|
|
|
}
|
2019-04-27 20:19:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-28 14:28:31 +00:00
|
|
|
public List<Entity> GetEntitiesAtPosition(Vector2Int position) {
|
2019-04-27 20:19:35 +00:00
|
|
|
Entity[] entities = GetComponentsInChildren<Entity>();
|
2019-04-28 12:11:21 +00:00
|
|
|
List<Entity> found = new List<Entity>();
|
2019-04-27 20:19:35 +00:00
|
|
|
foreach(Entity entity in entities) {
|
|
|
|
if(entity.MapPosition == position) {
|
2019-04-28 12:11:21 +00:00
|
|
|
found.Add(entity);
|
2019-04-27 20:19:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-28 12:11:21 +00:00
|
|
|
return found;
|
2019-04-27 20:19:35 +00:00
|
|
|
}
|
|
|
|
}
|