コード例 #1
0
ファイル: ServerClient.cs プロジェクト: jascou/PanzerKontrol
        void OnAttackUnit(ClientToServerMessage message)
        {
            AttackUnitRequest request = message.AttackUnitRequest;

            if (request == null)
            {
                throw new ServerClientException("Invalid attack unit request");
            }
            Unit attacker = PlayerState.GetUnit(request.AttackerUnitId);

            if (attacker == null)
            {
                throw new ServerClientException("Encountered an invalid attacking unit ID in an attack request");
            }
            Unit defender = Opponent.PlayerState.GetUnit(request.DefenderUnitId);

            if (defender == null)
            {
                throw new ServerClientException("Encountered an invalid target unit ID in an attack request");
            }
            PlayerState.AttackUnit(attacker, defender);
            UnitCasualties        attackerCasualties = new UnitCasualties(attacker.Id, attacker.Strength);
            UnitCasualties        defenderCasualties = new UnitCasualties(defender.Id, defender.Strength);
            UnitCombatBroadcast   casualties         = new UnitCombatBroadcast(attackerCasualties, defenderCasualties);
            ServerToClientMessage broadcast          = new ServerToClientMessage(casualties);

            BroadcastMessage(broadcast);
            AnnihilationCheck();
        }
コード例 #2
0
ファイル: Message.cs プロジェクト: jascou/PanzerKontrol
 public UnitCombatBroadcast(UnitCasualties attackerCasualties, UnitCasualties defenderCasualties)
 {
     AttackerCasualties = attackerCasualties;
     DefenderCasualties = defenderCasualties;
 }