Пример #1
0
    //method for switching the players colour
    [PunRPC] public void SwitchColour(int playerID)
    {
        if (playerID != this.playerID)
        {
            return;
        }

        if (stats.colourShifts != 0)
        {
            stats.colourShifts--;
            //set the next colour
            colour.NextColour();

            //set the sprites colour to equal what the new colour is
            sprite.DOColor(colour.GetCurrentColor(), 0.5f);

            SetGlowRenderers(colour.GetCurrentColor(), 0.5f);

            if (PlayerUI.Instance)
            {
                PlayerUI.Instance.SetColourShifts(this);
            }

            tr.colorGradient = gradients[(int)colour.currentColourType];

            if (PlayerUI.Instance)
            {
                PlayerUI.Instance.SetHealthBarGlow(this);
            }

            //call the switch colour method over the network so players can see each others colour
            if (photonView.isMine)
            {
                photonView.RPC("SwitchColour", PhotonTargets.OthersBuffered);
            }
        }
    }