示例#1
0
    private void OnTriggerEnter(Collider other)
    {
        if (!photonView.IsMine)
        {
            return;
        }


        if (other.CompareTag("Body"))
        {
            if (!other.GetComponentInParent <PlayerDeath>().alive) //quit if colliding with a dead person
            {
                return;
            }

            PlatformState myState    = playerColorChange.PlatState;
            PlatformState theirState = other.GetComponentInParent <PlayerColorChange>().PlatState;

            if (myState == theirState) //bounce off
            {
                GetComponent <PlayerMoveSync>().UpdateMovementRPC(GetComponent <PlayerMovement>().Velocity.normalized * -GetComponent <PlayerMovement>().topSpeed, transform.position);
            }
            else if (IsEatenBy(myState, theirState))
            {
                int otherIndex = other.GetComponentInParent <PlayerIdentity>().GetID();

                //This player is eaten.
                playerDeath.KillPlayerRPC(otherIndex); //kill self

                if (photonView.Owner == PhotonNetwork.LocalPlayer)
                {
                    Camera.main.GetComponent <FreezeFrame>().FreezeCamera();
                }
            }
        }
    }