Ejemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "bullets")
        {
            float damage      = col.gameObject.GetComponent <BulletFather>().damage;
            float force       = col.gameObject.GetComponent <BulletFather>().currMag;
            float totalDamage = damage + force;
            hp -= totalDamage;
            healthBar.value = hp;
            print("You took " + totalDamage + " damage!");
            Destroy(col.gameObject);
            if (hp <= 0)
            {
                hp = 0;
                healthBar.value = 0;
                Destroy(playerAvatar);
                isDead = true;

                ingameController.LoserNotification(this.gameObject);
            }
        }
        else
        {
            print("sek salah");
        }
    }
Ejemplo n.º 2
0
    void IsDead()
    {
        if (health <= 0f)
        {
            Destroy(monster);

            ingameController.LoserNotification(this.gameObject);
        }
    }