Esempio n. 1
0
 private void SetPlayerControls(ClientGameStateUpdateMessage message)
 {
     var player = DataEngine.LocalPlayer;
     if (player == null || player.ID == Spectator.UNINITIALIZED_ID) return;
     message.PlayerID = player.ID;
     foreach (PlayerControlType controlType in Enum.GetValues(typeof(PlayerControlType)))
         message.AddControlState(controlType, player.Controls[controlType].State);
 }
Esempio n. 2
0
 public override void StartArena()
 {
     Stats.BasicInfoSent = false;
     WebData.Feed("2" + (int)NetworkMode);
     switch (NetworkMode)
     {
         case NetworkMode.Server:
             MessageHandlers.ActivateHandlers(MessageHandlers.GetServerGameplayHandlers());
             _pendingGobDeletionMessage = null;
             DataEngine.Arena.GobRemoved += GobRemovedFromArenaHandler;
             break;
         case NetworkMode.Client:
             _pendingClientGameStateUpdateMessage = new ClientGameStateUpdateMessage();
             break;
     }
     Logic.StartArena();
 }
Esempio n. 3
0
 private void SendGobUpdateMessageOnClient()
 {
     if ((DataEngine.ArenaFrameCount % 2) != 0) return;
     PopulateGobUpdateMessage(_pendingClientGameStateUpdateMessage,
         DataEngine.Minions.Where(gob => gob.Owner != null && gob.Owner.IsLocal),
         SerializationModeFlags.VaryingDataFromClient);
     NetworkEngine.GameServerConnection.Send(_pendingClientGameStateUpdateMessage);
     _pendingClientGameStateUpdateMessage = new ClientGameStateUpdateMessage();
 }
Esempio n. 4
0
 private void HandleClientGameStateUpdateMessage(ClientGameStateUpdateMessage mess, int framesAgo)
 {
     HandleGobUpdateMessageOnServer(mess, framesAgo);
     var player = Game.DataEngine.Players.FirstOrDefault(plr => plr.ID == mess.PlayerID);
     if (player == null || player.ConnectionID != mess.ConnectionID)
     {
         // A client sent controls for a nonexisting player or a player that
         // lives on another game instance. We silently ignore the controls.
         return;
     }
     Action<RemoteControl, ControlState> setRemoteControlState =
         (control, state) => control.SetControlState(state.Force, state.Pulse);
     foreach (PlayerControlType control in System.Enum.GetValues(typeof(PlayerControlType)))
         setRemoteControlState((RemoteControl)player.Controls[control], mess.GetControlState(control));
     var playerPlayer = player as Player;
     if (playerPlayer != null && playerPlayer.Ship != null && playerPlayer.Ship.LocationPredicter != null)
         playerPlayer.Ship.LocationPredicter.StoreControlStates(mess.ControlStates, Game.NetworkEngine.GetMessageGameTime(mess));
 }