コード例 #1
0
ファイル: MessageManager.cs プロジェクト: Luciano94/IA
    public void SendGameState(GameState gState, uint objectId)
    {
        GameStatePacket packet = new GameStatePacket();

        packet.payload = gState;

        PacketManager.Instance.SendPacket(packet, objectId, false);
    }
コード例 #2
0
        /// <summary>
        /// Sets the current state of the game.
        /// </summary>
        /// <param name="gameState">The desired state.</param>
        public static void SetGameStatePacket(GameStatePacket gameState)
        {
            byte[] data   = gameState.Data;
            int    status = SetGameState(data, data.Length);

            if (status > 0)
            {
                throw NewRLBotCoreException((RLBotCoreStatus)status);
            }
        }
コード例 #3
0
ファイル: Arena.cs プロジェクト: itrygoodlife/CSANCoursework
        // Sends information about the current game state to the players
        // resendTimeout is how long to wait until sending another GameStatePacket
        private void _sendGameState(PlayerInfo player, TimeSpan resendTimeout)
        {
            if (DateTime.Now >= (player.LastPacketSentTime.Add(resendTimeout)))
            {
                // Set the data
                GameStatePacket gsp = new GameStatePacket();
                gsp.LeftY        = LeftPlayer.Paddle.Position.Y;
                gsp.RightY       = RightPlayer.Paddle.Position.Y;
                gsp.BallPosition = _ball.Position;
                gsp.LeftScore    = LeftPlayer.Paddle.Score;
                gsp.RightScore   = RightPlayer.Paddle.Score;

                _sendTo(player, gsp);
            }
        }
コード例 #4
0
ファイル: SynchronousGameStart.cs プロジェクト: Luciano94/IA
    void OnReceivePacket(ushort type, Stream stream)
    {
        switch (type)
        {
        case (ushort)UserPacketType.GameState:
            GameStatePacket gStateMessage = new GameStatePacket();
            gStateMessage.Deserialize(stream);
            switch (gStateMessage.payload)
            {
            case GameState.GameStart:
                PongManager.Instance.StartGame();
                break;

            case GameState.GameEnd:
                PongManager.Instance.GameEnd();
                break;
            }
            break;
        }
    }
コード例 #5
0
 /// <summary>
 /// Sets the current state of the game.
 /// </summary>
 /// <param name="gameState">The desired state.</param>
 public static void SetGameStatePacket(GameStatePacket gameState)
 {
     byte[] data = gameState.Data;
     SetGameState(data, data.Length);
 }