Exemplo n.º 1
0
    void GoToNextTarget()
    {
        /*1
         * targetLocation = moveQueue.Dequeue();
         * moveQueue.Enqueue(targetLocation);
         * movesLeft--;
         */
        for (int i = 1; i < moveQueue.Count; i++)
        {
            if (i == 1)
            {
                targetLocation = moveQueue[i];
            }
            else if (i == moveQueue.Count - 1)
            {
                moveQueue[i - 1] = moveQueue[i];
                moveQueue[i]     = moveQueue[0];
                moveQueue[0]     = targetLocation;
            }
            else
            {
                moveQueue[i - 1] = moveQueue[i];
            }

            EnemyMapping.SetPath(GetComponent <Enemy>(), moveQueue);
        }
    }
 void CreatePosition(float PosX, float PosY, Transform Formation)
 {
     if (EnemyMapping.InboundsAndEmpty(PosX, PosY))
     {
         GameObject position = Instantiate(Resources.Load("Prefab/Formation/Position"), new Vector3(PosX, PosY, 0), Quaternion.identity) as GameObject;
         position.transform.SetParent(Formation);
     }
 }
 void AddEnemiesToFormation(Transform Formation)
 {
     foreach (Transform child in Formation)
     {
         GameObject enemy = Instantiate(Resources.Load("Prefab/Enemy/1"), child.position, Quaternion.identity) as GameObject;
         enemy.transform.SetParent(child);
         enemyShipCount++;
         enemy.name = enemyShipCount.ToString();
         EnemyMapping.SetToMap(enemy.transform.position.x, enemy.transform.position.y, enemy.name);
     }
 }
Exemplo n.º 4
0
    void Update()
    {
        if (!dead)
        {
            if (shotTimer <= 0)
            {
                if (leftShot)
                {
                    Instantiate(Resources.Load("Prefab/Enemy/Laser/1"), transform.position + new Vector3(-.25f, -.3f, 0), Quaternion.identity);
                }
                else
                {
                    Instantiate(Resources.Load("Prefab/Enemy/Laser/1"), transform.position + new Vector3(.25f, -.3f, 0), Quaternion.identity);
                }

                leftShot  = !leftShot;
                shotTimer = 1;
            }

            shotTimer -= Time.deltaTime;



            if (health <= 0)
            {
                dead = true;
                GetComponent <Animator>().SetTrigger("Explosion");
                GetComponent <PolygonCollider2D>().enabled = false;
            }
        }
        else
        {
            if (gameObject.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Dead"))
            {
                EnemyMapping.RemoveFromMap(transform.parent.transform.position.x, transform.parent.transform.position.y);
                Destroy(transform.parent.gameObject);
            }
        }
    }
Exemplo n.º 5
0
 public void GetRandomPath()
 {
     moveQueue = EnemyMapping.CreateRandomPathForFormation(enemiesInFormation, 3);
 }