コード例 #1
0
ファイル: RandomMatchmaker.cs プロジェクト: jy3414/SpaceCraft
    // Use this for initialization
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings("0.1");

        AI1.SetScore(500);
        AI2.SetScore(200);
        AI3.SetScore(50);
        AI4.SetScore(10);
        AI5.SetScore(5);
    }
コード例 #2
0
    private void OnPhotonEvent(byte eventCode, object content, int senderID)
    {
        PhotonEventCodes code = (PhotonEventCodes)eventCode;

        if (code == PhotonEventCodes.StartGame)
        {
            PhotonNetwork.player.SetScore(0);
            panelReady.SetActive(false);
            StartCoroutine(this.StartTimer());
        }

        if (code == PhotonEventCodes.Game_5_CanTap && view.isMine)
        {
            this.canTap = true;
            this.btnTap.interactable = true;
            this.imgTapIndicator.transform.rotation = Quaternion.Euler(0, 0, 0);
            this.imgTapIndicator.sprite             = tapIndicatorSprites[1];
        }

        if (code == PhotonEventCodes.Game_5_Tap)
        {
            RaiseEventOptions options = new RaiseEventOptions()
            {
                Receivers = ReceiverGroup.All
            };
            PhotonNetwork.RaiseEvent((byte)PhotonEventCodes.Game_5_CantTap, 0, true, options);

            object[] datas       = content as object[];
            int      playerTapID = (int)datas[0];
            if (PhotonNetwork.isMasterClient)
            {
                StopCoroutine(this.StartTimer());
                PhotonPlayer playerToScore = PhotonPlayer.Find(playerTapID);
                foreach (PhotonPlayer player in PhotonNetwork.playerList)
                {
                    if (player.IsMasterClient)
                    {
                        int playerScore = playerToScore.GetScore();
                        playerToScore.SetScore(playerScore + 1);
                        object[] playerName = new object[1];
                        playerName[0] = playerToScore.NickName;
                        PhotonNetwork.RaiseEvent((byte)PhotonEventCodes.Game_5_DisplayPlayerSocred, playerName, true, options);
                    }
                }
            }

            if (PhotonNetwork.isMasterClient)
            {
                Debug.Log("Timer ouvre toi !");
                StartCoroutine(this.ScoredDelay());
            }
        }

        if (code == PhotonEventCodes.Game_5_CantTap)
        {
            this.imgTapIndicator.sprite  = tapIndicatorSprites[0];
            this.imgTapIndicator.enabled = false;
            this.canTap = false;
            this.btnTap.interactable = false;
        }

        if (code == PhotonEventCodes.Game_5_DisplayPlayerSocred)
        {
            object[] datas        = content as object[];
            string   playerScored = (string)datas[0];
            this.txtPlayerScored.text = playerScored + " marque le point !";
        }

        if (code == PhotonEventCodes.Game_5_DisplayWaiting)
        {
            this.txtPlayerScored.text    = "";
            this.imgTapIndicator.enabled = true;
        }
    }