void OnUpgradeUnit(ClientToServerMessage message) { UpgradeUnitRequest request = message.UpgradeUnitRequest; if (request == null) { throw new ServerClientException("Invalid upgrade unit request"); } Unit unit = PlayerState.GetUnit(request.UnitId); if (unit == null) { throw new ServerClientException("Encountered an invalid unit ID in an upgrade request"); } PlayerState.UpgradeUnit(unit, unit.GetUpgrade(request.UpgradeId)); UnitUpgradedBroadcast unitUpgraded = new UnitUpgradedBroadcast(new ReinforcementState(PlayerState), unit.Id); ServerToClientMessage broadcast = new ServerToClientMessage(unitUpgraded); BroadcastMessage(broadcast); }
public ClientToServerMessage(UpgradeUnitRequest request) { Type = ClientToServerMessageType.UpgradeUnit; UpgradeUnitRequest = request; }