Exemplo n.º 1
0
    IEnumerator createPool()
    {
        GameObject clone;

        // created an array of type list<GameObjetc>
        thePool = new List <GameObject> [_prefabs.Length];

        for (int count = 0; count < _prefabs.Length; count++)
        {
            // here created list in each position of array
            thePool [count] = new List <GameObject> ();

            // now add gameobjects to the list
            for (int i = 0; i < _prefabs[count].Amount; i++)
            {
                clone = Instantiate(_prefabs [count].Object, Vector2.zero, Quaternion.identity) as GameObject;
                clone.SetActive(false);
                clone.transform.parent = this.transform;
                thePool [count].Add(clone);

                // wait for 1 secs in each creation
                yield return(new WaitForSeconds(0.5f));
            }
        }

        // Debug.Log ("bullets creation done");
        // send the message to EnemyEventManaget to initiate the second phase
        EnemyEventManager.theEventDelegate();
    }     // end method
    void Start()
    {
        lastRnd = Random.Range(0, topDownPos.Length - 1);

        thepooler       = FindObjectOfType <Enemy_01_Pooler>();
        theEventManager = FindObjectOfType <EnemyEventManager> ();
    }
Exemplo n.º 3
0
 public void Kill()
 {
     EnemyEventManager.TriggerEnemyKilled(gameObject);
 }