Ejemplo n.º 1
0
        public void TestDestroyGuardian()
        {
            GameObject enemy         = (GameObject)Resources.Load("Tests/Enemy_1");
            GameObject enemyInstance = Object.Instantiate(enemy, new Vector2(0, 0), Quaternion.identity);
            enemy_ia   enemyIA       = enemyInstance.GetComponent <enemy_ia>();
            Vector2    posEnemy      = enemyIA.transform.position;

            movement.KillEnemy(enemyIA);
            Assert.AreEqual(enemyIA.getInitialPosition(), posEnemy);
        }
Ejemplo n.º 2
0
 public void KillEnemy(enemy_ia other)
 {
     other.Restart();
 }
Ejemplo n.º 3
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {
            if (!powers.invencibility)
            {
                powers.StartInvulnerable();
                Die();
                RestartHealth();
            }

            else
            {
                enemy_ia Enemy = (enemy_ia)other.gameObject.GetComponent <enemy_ia>();
                KillEnemy(Enemy);
                powers.invencibility = false;
                map.ShieldUI.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f);
            }
        }

        if (other.gameObject.CompareTag("ExplodingTrap"))
        {
            damaged = true;
            if (!powers.invencibility)
            {
                OnMusicPlaying(explosionSound);
            }
        }

        if (other.gameObject.CompareTag("Food"))
        {
            Interactable newFocus = other.GetComponent <Item>();
            SetFocus(newFocus);
            focus = newFocus;
        }

        if (other.gameObject.CompareTag("Fire"))
        {
            map.FireUI.GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f);
        }

        if (other.gameObject.CompareTag("Power-Up"))
        {
            Item newFocus = other.GetComponent <Item>();
            PowerUp = other.GetComponent <Item>();
            focus   = newFocus;

            if (newFocus.name == "Heart")
            {
                Powers power = newFocus.GetComponent <Powers>();
                if (numLifes < 3)
                {
                    numLifes++;
                    Lifes.transform.Find("Life_" + (4 - numLifes).ToString()).gameObject.SetActive(true);
                    newFocus.gameObject.SetActive(false);
                    newFocus.Interact();
                    RemoveFocus();
                }
            }
        }
    }