Пример #1
0
        /// <Summary>
        /// Deal with weapons being fired.
        /// </Summary>
        /// <param name="weapons">Weapon to display.</param>
        private void DoBattleStepFireWeapon(BattleStepWeapons weapons)
        {
            if (weapons == null)
            {
                Report.Error("BattleViewer.cs DoBattleStepFireWeapon() weapons is null.");
                ClearWeapons();
            }
            else
            {
                BattleStepTarget target = weapons.WeaponTarget;

                Stack lamb = null;
                Stack wolf = null;

                theBattle.Stacks.TryGetValue(target.TargetKey, out lamb);
                theBattle.Stacks.TryGetValue(target.StackKey, out wolf);

                UpdateStackDetails(wolf);
                UpdateTargetDetails(lamb);
                ClearMovementDetails();

                // damge taken
                weaponPower.Text = weapons.Damage.ToString(System.Globalization.CultureInfo.InvariantCulture);

                // "Damage to shields" or "Damage to armor"
                if (weapons.Targeting == BattleStepWeapons.TokenDefence.Shields)
                {
                    componentTarget.Text = "Damage to shields";
                    damage.Text          = weaponPower.Text + " " + componentTarget.Text;
                    lamb.Token.Shields  -= weapons.Damage;
                    UpdateTargetDetails(lamb);
                }
                else
                {
                    componentTarget.Text = "Damage to armor";
                    damage.Text          = weaponPower.Text + " " + componentTarget.Text;
                    lamb.Token.Armor    -= weapons.Damage;
                    UpdateTargetDetails(lamb);
                }
            }
        }
Пример #2
0
        /// <Summary>
        /// Update the current target (and stack) details.
        /// </Summary>
        /// <param name="target">Target ship to display.</param>
        private void DoBattleStepTarget(BattleStepTarget battleStep)
        {
            if (battleStep == null)
            {
                Report.Error("BattleViewer.cs DoBattleStepTarget(): battleStep is null.");
                ClearTargetDetails();
            }
            else
            {
                Stack lamb = null;
                Stack wolf = null;

                theBattle.Stacks.TryGetValue(battleStep.TargetKey, out lamb);
                theBattle.Stacks.TryGetValue(battleStep.StackKey, out wolf);

                UpdateStackDetails(wolf);
                ClearMovementDetails();
                ClearWeapons();
                UpdateTargetDetails(lamb);
            }
        }
Пример #3
0
        /// <summary>
        /// DischargeWeapon. We know the weapon and we know the target stack so attack.
        /// </summary>
        /// <param name="ship">The firing stack.</param>
        /// <param name="details">The weapon being fired.</param>
        /// <param name="target">The target stack.</param>
        private void ExecuteAttack(WeaponDetails attack)
        {
            // the two stacks involved in the attack
            Stack attacker = attack.SourceStack;
            Stack target   = attack.TargetStack;

            // Report on the targeting.
            BattleStepTarget report = new BattleStepTarget();

            report.StackKey  = attack.SourceStack.Key;
            report.TargetKey = attack.TargetStack.Key;
            battle.Steps.Add(report);

            // Identify the attack parameters that have to take into account
            // factors other than the base values (e.g. jammers, capacitors, etc.)
            double hitPower = CalculateWeaponPower(attacker.Token.Design, attack.Weapon, target.Token.Design);
            double accuracy = CalculateWeaponAccuracy(attacker.Token.Design, attack.Weapon, target.Token.Design);

            if (attack.Weapon.IsMissile)
            {
                FireMissile(attacker, target, hitPower, accuracy);
            }
            else
            {
                FireBeam(attacker, target, hitPower);
            }

            // If we still have some Armor then the stack hasn't been destroyed
            // yet so this is the end of this shot.

            // FIXME (Priority 7) What about losses of a single ship within the token???
            if (target.Token.Armor <= 0)
            {
                DestroyStack(attacker, target);
            }
        }