public void GiveCommandsFromClient(GameActCommands commands) { if (commands != null) { CommandsFromClient = commands; } }
private void SendCommandsToServer(GameActCommands commands) { var clientUpdate = new ClientUpdate(commands); Network.SendPacket(clientUpdate, serverConnection); /* * try * { * Network.SendPacket(clientUpdate, server.GetStream()); * } * catch (Exception e) * { * disconnectedActs++; * } */ }
private void BeginSessionAct() { var commands = new GameActCommands(controlSettings, GameForm.PressedKeys); Task.Run(() => SendCommandsToServer(commands)); lock (bottomSideState) { bottomSideState.GiveCommandsFromClient(commands); GameEngine.BeginAct(bottomSideState); lock (GameForm.BottomSideHUD) { GameForm.BottomSideHUD.Clear(); if (!bottomSideState.GameOver) { Visual.UpdatePlayerHUD(GameForm.BottomSideHUD, bottomSideState.PlayerEntity, GameForm.ClientSize, true); } } if (!bottomSideState.GameOver) { Sound.PlaySoundsAtBeginAct(bottomSideState.PlayerEntity); } } lock (topSideState) { GameEngine.BeginAct(topSideState); lock (GameForm.TopSideHUD) { GameForm.TopSideHUD.Clear(); if (!topSideState.GameOver) { Visual.UpdatePlayerHUD(GameForm.TopSideHUD, topSideState.PlayerEntity, GameForm.ClientSize, false); } } } }
public ClientUpdate(GameActCommands commands) { Commands = commands; }