コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Projectail missle = collision.gameObject.GetComponent <Projectail>();

        if (missle && missle.Parent != "Enemy")
        {
            missle.Hit();
            EnemyHealth -= missle.GetDamage();
            if (EnemyHealth <= 0)
            {
                Destroy(this.gameObject);
            }
        }
    }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Projectail missle = collision.gameObject.GetComponent <Projectail>();

        if (missle && missle.Parent != "Player")
        {
            missle.Hit();
            PlayerHealth -= missle.GetDamage();
            if (PlayerHealth <= 0)
            {
                Destroy(this.gameObject);
                LevelManager.LoadLv("Lose");
            }
        }
    }