コード例 #1
0
    void OnCollisionEnter(Collision collision)
    {
        Debug.Log(collision.gameObject.name);
        if (stop)
        {
            return;
        }
        stop = true;
        if (collision.gameObject.name == "roll5")
        {
            action.AddScore(1);
        }
        else if (collision.gameObject.name == "roll4")
        {
            action.AddScore(2);
        }
        else if (collision.gameObject.name == "roll3")
        {
            action.AddScore(3);
        }
        else if (collision.gameObject.name == "roll2")
        {
            action.AddScore(4);
        }
        else if (collision.gameObject.name == "roll1")
        {
            action.AddScore(5);
        }

        Destroy(this.GetComponent <Rigidbody>());
    }
コード例 #2
0
        private void OnDeath()
        {
            // Set the flag so that this function is only called once.
            m_Dead = true;

            // Move the instantiated explosion prefab to the tank's position and turn it on.
            m_ExplosionParticles.transform.position = transform.position;
            m_ExplosionParticles.gameObject.SetActive(true);

            // Play the particle system of the tank exploding.
            m_ExplosionParticles.Play();

            // Play the tank explosion sound effect.
            m_ExplosionAudio.Play();

            // Turn the tank off.
            gameObject.SetActive(false);

            Director        director = Director.GetInstance();
            FirstController fc       = (FirstController)director.CurrentScenceController;

            if (isAI)
            {
                fc.AddScore();
            }
            else
            {
                fc.GameOver();
            }
        }