void OnDeployUnit(ClientToServerMessage message) { UnitDeployment deployment = message.UnitDeployment; if (deployment == null) { throw new ServerClientException("Invalid unit deployment"); } Unit unit = PlayerState.GetUnit(deployment.Unit.UnitId); if (unit == null) { throw new ServerClientException("Encountered an invalid unit ID in a deployment request"); } PlayerState.DeployUnit(unit, deployment.Unit.Position); ServerToClientMessage broadcast = new ServerToClientMessage(deployment); BroadcastMessage(broadcast); }
public ServerToClientMessage(UnitDeployment deployment) { Type = ServerToClientMessageType.UnitDeployed; UnitDeployment = deployment; }
public ClientToServerMessage(UnitDeployment deployment) { Type = ClientToServerMessageType.DeployUnit; UnitDeployment = deployment; }