コード例 #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            Debug.Log("Start");
            scoreKeeper script = goScorer.GetComponent <scoreKeeper>();

            GameObject parent = transform.parent.gameObject;

            script.Score(parent);

            Debug.Log("End");
        }
    }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Projectile Missle = collision.gameObject.GetComponent <Projectile>();

        if (Missle)
        {
            health -= Missle.getDamage();
            Missle.hit();
            if (health < 0)
            {
                AudioSource.PlayClipAtPoint(death, transform.position);
                Destroy(gameObject);
                scoreKeeper.Score(scoreValue);
            }
        }
    }
コード例 #3
0
 void Die()
 {
     AudioSource.PlayClipAtPoint(deathSound, transform.position);
     Destroy(gameObject);
     scoreKeeper.Score(scoreValue);
 }