Exemplo n.º 1
0
    protected IEnumerator SpawnEnemies()
    {
        while (numEnemies > 0)
        {
            GameObject enemy      = Instantiate(enemyPrefab, transform.position, Quaternion.identity) as GameObject;
            AreaFollow areaFollow = enemy.GetComponent <AreaFollow>();
            areaFollow.targetTrigger = targetTrigger;
            if (eventGateObject)
            {
                EventGateObject enemyEventGateObject = enemy.AddComponent(typeof(EventGateObject)) as EventGateObject;
                enemyEventGateObject.eventGate = eventGateObject.eventGate;
            }

            --numEnemies;

            yield return(new WaitForSeconds(delay));
        }
        Destroy(gameObject);
    }
Exemplo n.º 2
0
 // Use this for initialization
 void OnEnable()
 {
     eventGateObject = GetComponent <EventGateObject>();
     StartCoroutine(SpawnEnemies());
 }