예제 #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "bullet")
        {
            Destroy(other.gameObject);
            Debug.Log("Hit2");
            damage -= 50;
            if (damage <= 0)
            {
                Die();
                ScoringSystem.EnemyKilled();
            }
        }
        if (other.tag == "PLayer")
        {
            GameControlScript.health -= 1;
            Debug.Log("Hit1");

            Destroy(this.gameObject);

            Player_sprite player = other.transform.GetComponent <Player_sprite>();
            if (player != null)
            {
                player.Damage();
            }
        }
    }
예제 #2
0
    public void TakeDamage(int damage)
    {
        health -= damage;

        if (health <= 0)
        {
            Die();
            ScoringSystem.EnemyKilled();
        }
    }