Beispiel #1
0
        void OnRequestForGameInformation(NetworkMessage netMsg)
        {
            RequestForGameInformationMessage msg = netMsg.ReadMessage <RequestForGameInformationMessage>();

            gameRoundRequest = msg.gameRound;

            if (Client.Instance.State.Value == ClientGameState.Playing ||
                Client.Instance.State.Value == ClientGameState.PlayingTutorial ||
                Client.Instance.State.Value == ClientGameState.WaitingForNextLevel)
            {
                if (gameRoundRequest == gameManager.Level.Value)
                {
                    if (gameManager.IsLevelCompleted.Value)
                    {
                        SendEndReached();
                    }
                    else
                    {
                        SendAlgorithm();
                        SendAlgorithmRespect(algorithmRespect.Respect);
                        SendPlayerPosition(controls.PlayerPosition.Value);
                        SendPlayerRotation(controls.BroadcastPlayerRotation.Value);
                        SendPlayerTilesToPaint(controls.PlayerTilesToPaint.Value);
                    }

                    return;
                }
            }

            if (!isRequestDelayed)
            {
                Client.Instance.State.OnValueChangedHandler += DelayedSendGameInformation;
                isRequestDelayed = true;
            }
        }
Beispiel #2
0
        void SendRequestForGameInformation()
        {
            RequestForGameInformationMessage msg = new RequestForGameInformationMessage();

            msg.gameRound = gameRound.Level.Value;

            client.Send(msg.GetMsgType(), msg);
        }
Beispiel #3
0
        void StartServer()
        {
            if (server == null)
            {
                server = new NetworkServerSimple();
                server.RegisterHandler(MsgType.Connect, OnConnect);
                server.RegisterHandler(MsgType.Disconnect, OnDisconnect);
                server.RegisterHandler(DirectiveMessage.GetCustomMsgType(), OnDirective);
                server.RegisterHandler(RequestForGameInformationMessage.GetCustomMsgType(), OnRequestForGameInformation);
                server.RegisterHandler(ReturnToDivergencePointRequestMessage.GetCustomMsgType(), OnReturnToDivergencePointRequest);

                server.Listen(serverPort);
            }
        }