Example #1
0
        public void readData(NetIncomingMessage msg)
        {
            while (msg.PositionInBytes < msg.LengthBytes)
            {
                Console.WriteLine("Data in buffer : " + (msg.LengthBytes - msg.PositionInBytes));
                PacketTypes pa = (PacketTypes)msg.ReadByte();

                Console.WriteLine(pa);
                switch (pa)
                {
                    case PacketTypes.ClientInput:

                        InputObject input = new InputObject();
                        InputParser.readBytes(msg, ref input);

                        Player p = Players[msg.SenderConnection.RemoteUniqueIdentifier];
                        p.Input = input;

                        break;
                    default:
                        Console.WriteLine("overflow : " + msg.ReadByte());
                        break;
                }
            }
        }
Example #2
0
 public static void readBytes(NetIncomingMessage data, ref InputObject io)
 {
     data.ReadByte();
     Console.WriteLine(io.HorizontalAxis = data.ReadFloat());
     Console.WriteLine(io.VerticalAxis = data.ReadFloat());
     Console.WriteLine(io.AmingAngle = data.ReadFloat());
     Console.WriteLine(io.Buttons = data.ReadByte());
 }
Example #3
0
 public static void writeBytes(NetOutgoingMessage om, InputObject input)
 {
     om.Write((byte)PacketTypes.ClientInput);
     om.Write((byte)13);
     // 3 floats:
     //4   move horisontal
     //4   move vertical
     //4   aming angle
     // 8 bits:
     //1  buttons
     om.Write(input.HorizontalAxis);
     om.Write(input.VerticalAxis);
     om.Write(input.AmingAngle);
     om.Write(input.Buttons);
 }
 public InputController(Game game)
     : base(game)
 {
     inputObject = new InputObject();
 }