1
Fork 0
slime-blood-and-pain/Assets/Scripts/TurnHandler.cs

35 lines
948 B
C#
Raw Normal View History

2019-04-27 20:19:35 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TurnHandler : MonoBehaviour
{
2019-04-28 13:29:17 +00:00
private MessageBar messageBar;
private void Start() {
GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");
messageBar = canvas.GetComponentInChildren<MessageBar>();
}
public void WriteToMessageBar(string message) {
messageBar.Write(message);
}
2019-04-27 20:19:35 +00:00
public void OnTurn() {
AI[] ais = gameObject.GetComponentsInChildren<AI>();
foreach(AI ai in ais) {
ai.OnTurn();
}
}
2019-04-28 12:11:21 +00:00
public List<Entity> GetEntityAtPosition(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
}
}