Exemple #1
0
 protected virtual void OnFailedToConnect()
 {
     if (ConnectionFailedScene != null)
     {
         ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
     }
 }
Exemple #2
0
 public void onExitClick()
 {
     Msf.Connection.SendMessage((short)ServerCommProtocl.PlayerLeftPreGame, roomId);
     removeHandlers();
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
     gameObject.SetActive(false);
 }
Exemple #3
0
 private static void handleTournamentStarted(IIncommingMessage rawMsg)
 {
     storedUpdates.Clear();
     ClientUIStateManager.requestGotoState(ClientUIStates.PlayingTournament, () => {
         storedInitMsg = rawMsg.Deserialize <TournamentInfoMsg>();
         initCurrentTree(storedInitMsg);
     });
 }
Exemple #4
0
 public void startButtonClicked()
 {
     Msf.Connection.SendMessage((short)ServerCommProtocl.StartSinglePlayerGame);
     ClientPlayersHandler.resetLocalPLayers();
     gameObject.SetActive(false);
     ClientUIStateManager.requestGotoState(ClientUIStates.PlayingGame, scene.SceneName);
     //SceneManager.LoadScene (scene.SceneName);
 }
Exemple #5
0
 public static void reOpenTournament()
 {
     ClientUIStateManager.requestGotoState(ClientUIStates.PlayingTournament, () => {
         initCurrentTree(storedInitMsg);
         storedUpdates.ForEach(u => currentTree.updateRounds(u.rounds, false));
         currentTree.renderVisualTree();
     });
 }
Exemple #6
0
 public static void handleJoinedTournament(ResponseStatus status, IIncommingMessage rawMsg)
 {
     if (Msf.Helper.serverResponseSuccess(status, rawMsg) == false)
     {
         return;
     }
     ClientUIStateManager.requestGotoState(ClientUIStates.PreTournament);
     tournamentID = rawMsg.AsString();
 }
Exemple #7
0
 private static void handleTournamentClosed(IIncommingMessage rawMsg)
 {
     if (rawMsg.AsString() != tournamentID)
     {
         return;
     }
     Debug.LogError("Tournament forcefully Closed");
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
     isInTournament = false;
     tournamentID   = "";
 }
Exemple #8
0
 private static void handleRoundStarted(IIncommingMessage rawMsg)
 {
     if (ClientUIOverlord.currentState == ClientUIStates.PlayingGame && isInTournament)
     {
         ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby, () => {
             NewGameCreator.handleJoinPreGame(GameInfoType.PreGame, rawMsg.AsString());
         });
     }
     else
     {
         NewGameCreator.handleJoinPreGame(GameInfoType.PreGame, rawMsg.AsString());
     }
 }
        public void newGameSelected()
        {
            if (exerciseDropDown.value == 0)
            {
                return;
            }

            ExerciseMapSelection m = getSelectedMap(exerciseDropDown.value);

            resetSelection();
            ClientUIStateManager.requestGotoState(ClientUIStates.PreGame);
            lobby.initGameLobby(m.Name, m.picture, m.type, m.Scene);
        }
Exemple #10
0
        public static void gameOver(string gameOverText, bool sendTCPGameOver = false)
        {
            string buttonText = CurrentTournament.isInTournament ? "To Tournament" : "Return to lobby";

            Action buttonAction;

            if (CurrentTournament.isInTournament)
            {
                buttonAction = () => { CurrentTournament.reOpenTournament(); }
            }
            ;
            else
            {
                buttonAction = () => { ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby); }
            };

            AlbotDialogBox.setGameOver();
            AlbotDialogBox.activateButton(buttonAction, DialogBoxType.GameState, gameOverText, buttonText, 70, 25);
        }
        private void handleJoinPreGameMsg(ResponseStatus status, IIncommingMessage rawMsg)
        {
            if (Msf.Helper.serverResponseSuccess(status, rawMsg) == false)
            {
                return;
            }

            PreGameRoomMsg msg = rawMsg.Deserialize <PreGameRoomMsg> ();

            currentMap = GameSelectionUI.getMatchingMapSelection(msg.specs.type);
            AccountInfoPacket playerInfo = ClientUIOverlord.getCurrentAcountInfo();
            bool isAdmin = playerInfo.Username == msg.players [0].playerInfo.username;

            ClientUIStateManager.requestGotoState(ClientUIStates.PreGame);

            //Kill old TCP Connection
            TCPLocalConnection.stopServer();

            preGameLobby.initPreGameLobby(currentMap.picture, msg);
        }
Exemple #12
0
    public IEnumerator WaitForConnection(RoomAccessPacket access)
    {
        NetworkManager = NetworkManager ?? FindObjectOfType <NetworkManager>();
        //	Debug.LogError("Connecting to game server... " + NetworkManager.networkAddress + ":" + NetworkManager.networkPort);

        var timeUntilTimeout = ConnectionTimeout;

        // Wait until we connect
        while (!NetworkManager.IsClientConnected())
        {
            yield return(null);

            timeUntilTimeout -= Time.deltaTime;

            if (timeUntilTimeout < 0)
            {
                Logger.Warn("Client failed to connect to game server: " + access);
                OnFailedToConnect();
                yield break;
            }
        }

        Logger.Info("Connected to game server, about to send access");
        // Connected, send the token
        showDissconnectMsg = true;
        NetworkManager.client.connection.Send(AlbotGameRoom.AccessMsgType, new StringMessage(access.Token));

        // While connected
        while (NetworkManager.IsClientConnected())
        {
            yield return(null);
        }
        // At this point, we're no longer connected
        if (DisconnectedScene.IsSet() && showDissconnectMsg)
        {
            AlbotDialogBox.activateButton(() => { ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby); },
                                          DialogBoxType.GameServerConnLost, "Connection to the gameserver was lost!", "Return to lobby");
        }
    }
Exemple #13
0
    public override void ConnectToGame(RoomAccessPacket access)
    {
        if (SwitchScenesIfWrongScene && SceneManager.GetActiveScene().name != access.SceneName)
        {
            // Save the access
            RoomAccess = access;

            // Switch to correct scene
            ClientUIStateManager.requestGotoState(ClientUIStates.PlayingGame, access.SceneName);
            isConnecting = true;
            return;
        }
        isConnecting = false;

        NetworkManager = NetworkManager ?? FindObjectOfType <NetworkManager>();

        //Debug.LogError (NetworkManager);
        RoomAccess = null;

        // Just in case
        NetworkManager.maxConnections = 999;
        Logger.Debug("Trying to connect to server at address: " + access.RoomIp + ":" + access.RoomPort);

        if (!NetworkManager.IsClientConnected())
        {
            // If we're not connected already
            NetworkManager.networkAddress = access.RoomIp;
            NetworkManager.networkPort    = access.RoomPort;
            NetworkManager.StartClient();
        }
        if (WaitConnectionCoroutine != null)
        {
            StopCoroutine(WaitConnectionCoroutine);
        }

        WaitConnectionCoroutine = StartCoroutine(WaitForConnection(access));
    }
Exemple #14
0
    protected virtual void Start()
    {
        if (ClientUIOverlord.hasLoaded)
        {
            return;
        }
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        if (transform.parent == null)
        {
            DontDestroyOnLoad(this.gameObject);
        }
        else
        {
            DontDestroyOnLoad(transform.parent.gameObject);
        }

        instance = this;
        SceneManager.sceneLoaded += newLevelLoaded;
        // If we currently have a room access
        // (it might have been set in a previous scene)
        if (RoomAccess != null)
        {
            if (SceneManager.GetActiveScene().name == RoomAccess.SceneName) // If we're atthe correct scene
            {
                ConnectToGame(RoomAccess);
            }
            else if (SwitchScenesIfWrongScene) // Switch to correct scene
            {
                ClientUIStateManager.requestGotoState(ClientUIStates.PlayingGame, RoomAccess.SceneName);
            }
        }
    }
 public void gotoLobbyBrowserButton()
 {
     ClientUIStateManager.requestGotoState(ClientUIStates.LobbyBrowser);
 }
 public void gotoGameLobbyButton()
 {
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
 }
Exemple #17
0
 public void onExitClick()
 {
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
     gameObject.SetActive(false);
 }
 private void handlePreGameKickMsg(IIncommingMessage message)
 {
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby, () => {
         onExitClick();
     });
 }
 public void onGameLobbyPressed()
 {
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
     setActive(false);
 }
Exemple #20
0
 public static void leaveCurrentTournament()
 {
     isInTournament = false;
     ClientUIStateManager.requestGotoState(ClientUIStates.GameLobby);
     Msf.Connection.SendMessage((short)CustomMasterServerMSG.leaveTournament);
 }
 public void onLogoutPressed()
 {
     ClientUIStateManager.requestLogout();
     setActive(false);
 }