Esempio n. 1
0
        /// <summary>
        /// Sets up matchmaking values for connecting to a room and then tries connecting to one
        /// </summary>
        private void SetConnectingToRoom()
        {
            connectingToRoom = true;

            LobbyUI lobbyUI = (LobbyUI)UI;

            lobbyUI.SetCreateRoomToggleActiveState(false);

            bool creatingRoom = lobbyUI.GetStateOfCreateRoomToggle();

            if (creatingRoom)
            {
                lobbyUI.SetMaxPlayersInputFieldActiveState(true);
                lobbyUI.WaitForMaxPlayerInput(() =>
                {
                    //setup room options and join or create room
                    RoomOptions options = new RoomOptions();
                    options.IsVisible   = false;
                    //get max players choosen by user
                    options.MaxPlayers = (byte)lobbyUI.GetMaxPlayersInput();
                    //create or join room with options
                    PhotonNetwork.CreateRoom(ROOM_NAME, options, TypedLobby.Default);
                });
            }
            else
            {
                PhotonNetwork.JoinRoom(ROOM_NAME);
            }
        }
Esempio n. 2
0
        public override void OnJoinRoomFailed(short returnCode, string message)
        {
            base.OnJoinRoomFailed(returnCode, message);
            LobbyUI lobbyUI = (LobbyUI)UI;

            lobbyUI.SetConnectButtonInteractability(true);
            lobbyUI.SetCreateRoomToggleActiveState(true);
            connectingToRoom = false;
            Debug.LogError($"Joining room failed with message: {message}");
        }
Esempio n. 3
0
        public override void OnConnectedToMaster()
        {
            base.OnConnectedToMaster();

            //if we where connecting to master we set up values and ui accordingly
            if (connectingToMaster)
            {
                SetConnectedToMaster();
                LobbyUI lobbyUI = (LobbyUI)UI;
                lobbyUI.UpdateConnectStatus(true);
                lobbyUI.UpdateConnectColor(true);
                lobbyUI.SetConnectButtonInteractability(true);
                lobbyUI.SetCreateRoomToggleActiveState(true);
            }
        }