Ejemplo n.º 1
0
        public override void OnDisconnected(DisconnectCause cause)
        {
            base.OnDisconnected(cause);
            //try reattaching the UI for when we where inside another scene
            AttachUI(MultiplayerRacerScenes.LOBBY);
            //update lobby ui after having tried reattaching it
            LobbyUI lobbyUI = (LobbyUI)UI;

            lobbyUI.UpdateConnectStatus(false);
            lobbyUI.UpdateConnectColor(false);
            lobbyUI.ResetPlayerInfo();
            lobbyUI.SetConnectButtonInteractability(true);
            Application.quitting -= OnQuitEvent;

            print(cause);
        }
Ejemplo n.º 2
0
        public void OnPlayerLeftRoom(Player otherPlayer)
        {
            //Update our number in room since
            UpdateNumberInRoom();
            //master needs to deal with player leaving the room/him
            OnPlayerLeftMaster();
            //invoke shared functions
            Room room = PhotonNetwork.CurrentRoom;

            UI.UpdateRoomInfo(room);
            UI.UpdateNickname(MatchMakingManager.Instance.MakeNickname());
            //Update Room status based on current scene
            switch (CurrentScene)
            {
            case MultiplayerRacerScenes.LOBBY:
                //reset all player related info, then update it again
                LobbyUI lobbyUI = (LobbyUI)UI;
                lobbyUI.ResetPlayerInfo();
                lobbyUI.OnPlayerLeftSelectedCar(otherPlayer);
                lobbyUI.UpdatePlayerInfo(room.PlayerCount);
                break;

            case MultiplayerRacerScenes.GAME:
                ((GameUI)UI).ShowText($"{otherPlayer.NickName} left the game");
                break;
            }

            /*if resetable, set ourselfs to unready status, exit button and room status is shown
             * and on scene reset gets fired*/
            if (IsResetAble)
            {
                SetReady(false);
                UI.ShowExitButton();
                UI.SetButtonInfoActiveState(true);
                OnSceneReset?.Invoke(CurrentScene);
            }
        }