コード例 #1
0
    void OnUnbreakableHit(Unbreakable unbreakable)
    {
        PlayAudio(m_UnbreakableSound);

        if (unbreakable.m_IsInstaDeath)
        {
            StartCoroutine(StartDeathSequence(2.0f));
        }
        else
        {
            StartCoroutine(StunPlayer(m_StunTime));
            m_Rigidbody.velocity = Vector3.zero;

            m_CurrentEnergy -= unbreakable.m_EnergyLost;

            Vector3 direction = unbreakable.transform.position - transform.position;
            m_Rigidbody.AddForce(-direction.normalized * 1000);

            m_CameraShake.AddTrauma(0.8f);

            GameManager.m_Singleton.AddPenalty();

            UpdateUI();
        }
    }
コード例 #2
0
    private void OnCollisionEnter(Collision collision)
    {
        Breakable breakable = collision.collider.gameObject.GetComponent <Breakable>();

        if (breakable)
        {
            OnBreakableHit(breakable);
            return;
        }

        Unbreakable unbreakable = collision.collider.gameObject.GetComponent <Unbreakable>();

        if (unbreakable)
        {
            OnUnbreakableHit(unbreakable);
            return;
        }
    }