コード例 #1
0
ファイル: GameManager.cs プロジェクト: Javielag/TIME
 //cada vez que muere un enemigo
 public void EnemySlain()
 {
     if (enemyCount >= 0)
     {
         enemyCount--;
         if (enemyCount > 0 && enemyCount <= 2 && !flechas)
         {
             flechas = true;
             en      = new Enemy[enemyPool.GetComponentsInChildren <Enemy>().Length];
             en      = enemyPool.GetComponentsInChildren <Enemy>();
             for (int i = 0; i < en.Length; i++)
             {
                 if (en[i].gameObject.GetComponent <Health>().health > 0)
                 {
                     PointAtEnemy arrow = Instantiate(enemyArrow, player.transform);
                     arrow.SetTarget(en[i].transform);
                 }
             }
         }
         else if (flechas)
         {
             arrow = new PointAtEnemy[player.GetComponentsInChildren <PointAtEnemy>().Length];
             arrow = player.GetComponentsInChildren <PointAtEnemy>();
             for (int i = 0; i < arrow.Length; i++)
             {
                 if (arrow[i].Target.gameObject.GetComponent <Health>().health <= 0)
                 {
                     Destroy(arrow[i].gameObject);
                 }
             }
         }
         //si era el último, genera una nueva oleada
         if (enemyCount <= 0)
         {
             flechas = false;
             PointAtEnemy[] arrows = new PointAtEnemy[player.GetComponentsInChildren <PointAtEnemy>().Length];
             arrows = player.GetComponentsInChildren <PointAtEnemy>();
             for (int i = 0; i < arrows.Length; i++)
             {
                 Destroy(arrows[i].gameObject);
             }
             if (!GameObject.FindGameObjectWithTag("Ciencia"))
             {
                 if ((oleadaActual - cientifico.primeraAparicion) % cientifico.cadaX == 0)
                 {
                     //aquí van las visitas del CIENTEFRICO
                     cientifico.Visita();
                 }
                 else
                 {
                     GeneraOleada();
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: Javielag/TIME
    public void SaltaOleada()
    {
        Transform enemyPool = GameObject.FindGameObjectWithTag("EnemyPool").transform;

        foreach (Transform enemy in enemyPool)
        {
            Destroy(enemy.gameObject);
        }
        generadorOleadas.AcabaOleada();
        //int actOl = oleadaActual;
        enemyCount = 0;
        if (!GameObject.FindGameObjectWithTag("Ciencia"))
        {
            if ((oleadaActual - cientifico.primeraAparicion) % cientifico.cadaX == 0)
            {
                //aquí van las visitas del CIENTEFRICO
                cientifico.Visita();
            }
            else
            {
                GeneraOleada();
            }
        }
        flechas = false;
        PointAtEnemy[] arrows = new PointAtEnemy[player.GetComponentsInChildren <PointAtEnemy>().Length];
        arrows = player.GetComponentsInChildren <PointAtEnemy>();
        for (int i = 0; i < arrows.Length; i++)
        {
            Destroy(arrows[i].gameObject);
        }
        PointAtPortal[] arrowsPortal = new PointAtPortal[player.GetComponentsInChildren <PointAtPortal>().Length];
        arrowsPortal = player.GetComponentsInChildren <PointAtPortal>();
        for (int i = 0; i < arrowsPortal.Length; i++)
        {
            Destroy(arrowsPortal[i].gameObject);
        }
    }