示例#1
0
    private void OnTriggerEnter(Collider other)
    {
        WinCondition winCondition = other.GetComponent <WinCondition>();
        DieEvent     dieEvent     = other.GetComponent <DieEvent>();
        ICoins       iCoins       = other.GetComponent <ICoins>();

        if (other.tag == "Cannon")
        {
            cannonTriggered = other.gameObject;
            other.enabled   = false;
            StuckOnCannon();
            cannonTriggered.GetComponent <CannonParent>().mAnimator.SetTrigger("Entering");
            OnProgressLvl(transform.position);
        }
        else if (dieEvent != null)
        {
            mCollider.enabled     = false;
            transform.position    = reference.position;
            transform.eulerAngles = reference.eulerAngles;
            dieEvent.CharacterDie();
            m_Rigidbody.constraints  = RigidbodyConstraints.FreezeAll;
            m_SpriteRenderer.enabled = false;
        }
        else if (winCondition != null)
        {
            winCondition.Win(m_Rigidbody);
            mCollider.enabled        = false;
            m_SpriteRenderer.enabled = false;
        }
        else if (iCoins != null)
        {
            iCoins.CollectCoins();
        }
    }