Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "EnemyProjectile")
        {
            Data.ChangePlayerHP();
            int currentHp = Data.GetCurrentHP();
            SaveHandler.Save();

            if (currentHp <= 0)
            {
                foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Enemy"))
                {
                    Destroy(obj);
                }
                foreach (GameObject obj in GameObject.FindGameObjectsWithTag("EnemyProjectile"))
                {
                    Destroy(obj);
                }
                Player.position = Vector2.zero;
                SaveHandler.SaveDefaultValues();
                SaveHandler.LoadAll();
                ShowDeathMenu();
            }
        }
    }