internal void MovePlayer(NetIncomingMessage msg)
        {
            int msgLength = msg.ReadInt32();

            byte[]            msgContents = msg.ReadBytes(msgLength);
            PlayerMoveMessage moveMsg     = (PlayerMoveMessage)SerializationHandler.ByteArrayToObject(msgContents);
            PlayerMove        move        = moveMsg.move; // TODO Do something with this

            gameServer.sendMsgToAll(moveMsg);
        }
Example #2
0
        internal void AddPlayer(NetIncomingMessage msg)
        {
            int msgLength = msg.ReadInt32();

            byte[]            msgContents = msg.ReadBytes(msgLength);
            PlayerJoinMessage joinMsg     = (PlayerJoinMessage)SerializationHandler.ByteArrayToObject(msgContents);
            PlayerAttributes  player      = new PlayerAttributes(joinMsg.name, joinMsg.playerID, joinMsg.isHost, new Vector2(joinMsg.posX, joinMsg.posY));

            game.GameData.players.Add(player);
        }
Example #3
0
        internal void MovePlayer(NetIncomingMessage msg)
        {
            int msgLength = msg.ReadInt32();

            byte[]            msgContents = msg.ReadBytes(msgLength);
            PlayerMoveMessage moveMsg     = (PlayerMoveMessage)SerializationHandler.ByteArrayToObject(msgContents);
            PlayerMove        move        = moveMsg.move;

            if (game.GameData.clientsPlayerID != moveMsg.playerID)
            {
                game.GameData.getPlayer(moveMsg.playerID).currentMove = move;
            }
        }
        public void PlayerJoined(NetIncomingMessage msg)
        {
            int msgLength = msg.ReadInt32();

            byte[]            msgContents = msg.ReadBytes(msgLength);
            PlayerJoinMessage joinMsg     = (PlayerJoinMessage)SerializationHandler.ByteArrayToObject(msgContents);
            PlayerAttributes  player      = new PlayerAttributes(joinMsg.name, joinMsg.playerID, joinMsg.isHost);

            player.position = game.GameData.getSpawnPos();
            game.GameData.players.Add(player);
            gameServer.clientList.Add(new ClientInfo(msg.SenderConnection, player));
            logger.Debug("Player with name " + player.playerName + " added");
            ClientPlayerUpdate();
        }