public void OnGUI()
 {
     if (GUILayout.Button("Return to Lobby"))
     {
         PhotonNetworkManager.LeaveRoom();  // we will load the menu level when we successfully left the room
     }
 }
    public void OnGUI()
    {
        if (!PhotonNetworkManager.inRoom)
        {
            return;
        }

        GUILayout.BeginArea(GuiRect);

        GUILayout.Label("In-Game");
        GUILayout.Label("For simplicity, this demo just shows the players in this room. The list will expand when more join.");
        GUILayout.Label("Your (random) name: " + PhotonNetworkManager.playerName);
        GUILayout.Label(PhotonNetworkManager.playerList.Length + " players in this room.");
        GUILayout.Label("The others are:");
        foreach (PhotonPlayer player in PhotonNetworkManager.otherPlayers)
        {
            GUILayout.Label(player.ToString());
        }

        if (GUILayout.Button("Leave"))
        {
            PhotonNetworkManager.LeaveRoom();
        }
        GUILayout.EndArea();
    }
예제 #3
0
    public void Update()
    {
        // Check if we are out of context, which means we likely got back to the demo hub.
        if (this.DisconnectedPanel == null)
        {
            Destroy(this.gameObject);
        }

        // for debugging, it's useful to have a few actions tied to keys:
        if (Input.GetKeyUp(KeyCode.L))
        {
            PhotonNetworkManager.LeaveRoom();
        }
        if (Input.GetKeyUp(KeyCode.C))
        {
            PhotonNetworkManager.ConnectUsingSettings(null);
            PhotonMenuManager.StopFallbackSendAckThread();
        }


        if (!PhotonNetworkManager.inRoom)
        {
            return;
        }

        // disable the "reconnect panel" if PUN is connected or connecting
        if (PhotonNetworkManager.connected && this.DisconnectedPanel.gameObject.GetActive())
        {
            this.DisconnectedPanel.gameObject.SetActive(false);
        }
        if (!PhotonNetworkManager.connected && !PhotonNetworkManager.connecting && !this.DisconnectedPanel.gameObject.GetActive())
        {
            this.DisconnectedPanel.gameObject.SetActive(true);
        }


        if (PhotonNetworkManager.room.PlayerCount > 1)
        {
            if (this.turnManager.IsOver)
            {
                return;
            }

            /*
             * // check if we ran out of time, in which case we loose
             * if (turnEnd<0f && !IsShowingResults)
             * {
             *              Debug.Log("Calling OnTurnCompleted with turnEnd ="+turnEnd);
             *              OnTurnCompleted(-1);
             *              return;
             * }
             */

            if (this.TurnText != null)
            {
                this.TurnText.text = this.turnManager.Turn.ToString();
            }

            if (this.turnManager.Turn > 0 && this.TimeText != null && !IsShowingResults)
            {
                this.TimeText.text = this.turnManager.RemainingSecondsInTurn.ToString("F1") + " SECONDS";

                TimerFillImage.anchorMax = new Vector2(1f - this.turnManager.RemainingSecondsInTurn / this.turnManager.TurnDuration, 1f);
            }
        }

        this.UpdatePlayerTexts();

        // show local player's selected hand
        Sprite selected = SelectionToSprite(this.localSelection);

        if (selected != null)
        {
            this.localSelectionImage.gameObject.SetActive(true);
            this.localSelectionImage.sprite = selected;
        }

        // remote player's selection is only shown, when the turn is complete (finished by both)
        if (this.turnManager.IsCompletedByAll)
        {
            selected = SelectionToSprite(this.remoteSelection);
            if (selected != null)
            {
                this.remoteSelectionImage.color  = new Color(1, 1, 1, 1);
                this.remoteSelectionImage.sprite = selected;
            }
        }
        else
        {
            ButtonCanvasGroup.interactable = PhotonNetworkManager.room.PlayerCount > 1;

            if (PhotonNetworkManager.room.PlayerCount < 2)
            {
                this.remoteSelectionImage.color = new Color(1, 1, 1, 0);
            }

            // if the turn is not completed by all, we use a random image for the remote hand
            else if (this.turnManager.Turn > 0 && !this.turnManager.IsCompletedByAll)
            {
                // alpha of the remote hand is used as indicator if the remote player "is active" and "made a turn"
                PhotonPlayer remote = PhotonNetworkManager.player.GetNext();
                float        alpha  = 0.5f;
                if (this.turnManager.GetPlayerFinishedTurn(remote))
                {
                    alpha = 1;
                }
                if (remote != null && remote.IsInactive)
                {
                    alpha = 0.1f;
                }

                this.remoteSelectionImage.color  = new Color(1, 1, 1, alpha);
                this.remoteSelectionImage.sprite = SelectionToSprite(randomHand);
            }
        }
    }
 public void OnClickGoBack()
 {
     PhotonNetworkManager.LeaveRoom();
     PhotonNetworkManager.LoadLevel("LobbyScene");
 }
 public void LeaveRoom()
 {
     PhotonNetworkManager.LeaveRoom();
 }