/*
* author: ryan lin
* date: TODO
* description: TODO
*/
using System.Collections;
using UnityEngine;
public class AIManager : MonoBehaviour
{
///
/// TODO
///
public Transform player;
///
/// TODO
///
public float cullingDistance;
///
/// TODO
///
public GameObject aiPrefab;
///
/// TODO
///
public int maxAI;
///
/// TODO
///
private GameObject[] _ais;
///
/// TODO
///
private float _distance;
///
/// TODO
///
private void Start()
{
StartCoroutine(Manager());
}
///
/// TODO
///
private void OnDrawGizmos()
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireSphere(player.position, cullingDistance);
}
///
/// TODO
///
private IEnumerator Manager()
{
while (true)
{
// FIXME: feels weird
_ais = GameObject.FindGameObjectsWithTag("AIs");
if (_ais.Length < maxAI)
{
// var instance = Instantiate(aiPrefab, gameObject.transform);
}
foreach (var i in _ais)
{
_distance = Vector3.Distance(i.transform.position, player.position);
if (_distance > cullingDistance) Destroy(i.gameObject);
}
yield return new WaitForSeconds(1);
}
// TODO: iterator never returns? is this intended?
}
}