Exemple #1
0
 void updatePos(Vector2 dis, int col, int row, ref int deathcount)
 {
     if (AllAlienShiparr[row][col] == null || AllAlienShiparr[row][col].name == "destroyed")
     {
         checker[row][col] = -1;
     }
     if (AllAlienShiparr[row][col] != null && AllAlienShiparr[row][col].name != "destroyed")
     {
         enemy1cs a = AllAlienShiparr[row][col].GetComponent <enemy1cs>();
         enemy2cs b = AllAlienShiparr[row][col].GetComponent <enemy2cs>();
         enemy3cs c = AllAlienShiparr[row][col].GetComponent <enemy3cs>();
         if (a != null)
         {
             a.gameObject.transform.Translate(new Vector3(dis.x, 0, dis.y));
         }
         if (b != null)
         {
             b.gameObject.transform.Translate(new Vector3(dis.x, 0, dis.y));
         }
         if (c != null)
         {
             c.gameObject.transform.Translate(new Vector3(dis.x, 0, dis.y));
         }
     }
 }
Exemple #2
0
    void alienFireRand()
    {
        validenemy = new List <int>();
        validenemy.Clear();
        for (int i = 0; i < AllAlienShiparr.Count; ++i)
        {
            bool rowlife = false;
            for (int j = 0; j < AllAlienShiparr[i].Count; ++j)
            {
                if (/*AllAlienShiparr[i][j]!=null||*/ AllAlienShiparr[i][j].name != "destroyed")
                {
                    rowlife = true;
                }
                //only those labled with 2 has the right to fight
                if (i == 0 && (checker[i][j] == 1 || checker[i][j] == 2))
                {
                    checker[i][j] = 2;
                    validenemy.Add(i * AllAlienShiparr[i].Count + j);
                }
                else if ((i > 0) && (checker[i][j] == 1 || checker[i][j] == 2) && checker[i - 1][j] == -1)
                {
                    checker[i][j] = 2;
                    validenemy.Add(i * AllAlienShiparr[i].Count + j);
                }
            }
            if (rowlife == false)
            {
                lowestcol = i + 1;
            }
        }
        fighter = Random.Range(0, validenemy.Count);
        int reali = validenemy[fighter] / numAlienRow;
        int realj = validenemy[fighter] - reali * numAlienRow;

        Debug.Log("reali" + reali + "  realj" + realj);
        if (AllAlienShiparr[reali][realj] != null && AllAlienShiparr[reali][realj].name != "destroyed")
        {
            enemy1cs a = AllAlienShiparr[reali][realj].GetComponent <enemy1cs>();
            enemy2cs b = AllAlienShiparr[reali][realj].GetComponent <enemy2cs>();
            enemy3cs c = AllAlienShiparr[reali][realj].GetComponent <enemy3cs>();
            if (a != null)
            {
                a.Fire();
                return;
            }
            if (b != null)
            {
                b.Fire();
                return;
            }
            if (c != null)
            {
                c.Fire();
                return;
            }
        }
    }
Exemple #3
0
    void OnCollisionEnter(Collision collision)
    {
        Collider collider = collision.collider;

        if (collider.CompareTag("Penemy1"))
        {
            enemy1cs e1 = collider.gameObject.GetComponent <enemy1cs>();
            e1.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("Penemy2"))
        {
            enemy2cs e2 = collider.gameObject.GetComponent <enemy2cs>();
            e2.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("Penemy3"))
        {
            enemy3cs e3 = collider.gameObject.GetComponent <enemy3cs>();
            e3.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("bunker"))
        {
            bunker eb = collider.gameObject.GetComponent <bunker>();
            eb.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("UFO"))
        {
            UFO uf = collider.gameObject.GetComponent <UFO>();
            uf.Die();
            Destroy(gameObject);
        }
        if (collider.CompareTag("boss"))
        {
            Global gbs = GameObject.FindGameObjectWithTag("FGlobal").GetComponent <Global>();
            boss   bs  = GameObject.FindGameObjectWithTag("boss").GetComponent <boss>();
            AudioSource.PlayClipAtPoint(hitclipboss, bs.transform.position, 10);
            Instantiate(explosion, bs.transform.position, Quaternion.identity);
            gbs.bosslives--;
        }
        if (collider.CompareTag("Fplayer"))
        {
        }
        else
        {
            Destroy(gameObject);
        }
    }
Exemple #4
0
 void destroyall()
 {
     for (int i = 0; i < AllAlienShiparr.Count; ++i)
     {
         for (int j = 0; j < AllAlienShiparr[i].Count; ++j)
         {
             enemy1cs a = AllAlienShiparr[i][j].GetComponent <enemy1cs>();
             enemy2cs b = AllAlienShiparr[i][j].GetComponent <enemy2cs>();
             enemy3cs c = AllAlienShiparr[i][j].GetComponent <enemy3cs>();
             if (a != null)
             {
                 a.Die();
             }
             if (b != null)
             {
                 b.Die();
             }
             if (c != null)
             {
                 c.Die();
             }
         }
     }
 }