Beispiel #1
0
        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);
        }
Beispiel #2
0
 public ServerToClientMessage(UnitUpgradedBroadcast unitUpgraded)
 {
     Type         = ServerToClientMessageType.UnitUpgraded;
     UnitUpgraded = unitUpgraded;
 }