// The main game loop
 public void QueueInput(GameInputUpdate update)
 {
     if (update.ClientId == ClientA.PlayerId())
     {
         ClientA.QueueInput(update.Inputs);
         //Events.OnGuiLogMessageEvent($"Client A: Direction: {update.Inputs} Input Number: {update.Inputs.InputNumber}");
     }
     else if (update.ClientId == ClientB.PlayerId())
     {
         ClientB.QueueInput(update.Inputs);
         //Events.OnGuiLogMessageEvent($"Client B: Direction: {update.Inputs} Input Number: {update.Inputs.InputNumber}");
     }
 }
Exemple #2
0
        private void HandleSendInputEvent(object sender, InputSendEventArgs e)
        {
            var msg = new GameInputUpdate
            {
                ClientId = Client.ClientId,
                Inputs   = e.States
            };
            var roomMessage = new RoomMessage()
            {
                RoomMessageId = GameInputUpdate.MessageId, RoomId = e.RoomId, Contents = msg
            };
            var fullMsg = new Message()
            {
                MessageId = CommunicationMessageIds.RoomMessage, Contents = roomMessage
            };

            Events.OnSendMessageEvent(this, new ByteArrayEventArgs(fullMsg.Serialize()));
        }