Ejemplo n.º 1
0
        public Combat(Unit attacker, Unit defender, bool useRandomisedCombatEfficiency, List <Unit> antiAirUnits = null)
        {
            UseRandomisedCombatEfficiency = useRandomisedCombatEfficiency;
            Generator = new NormalDistribution(GameConstants.CombatEfficiencyMean, GameConstants.CombatEfficiencyDeviation);

            Attacker = new UnitCombatState(attacker, this);
            Defender = new UnitCombatState(defender, this);

            if (attacker.IsAirUnit())
            {
                AttackType   = AttackType.AirAttack;
                AntiAirUnits = antiAirUnits.Select((Unit x) => new UnitCombatState(x, this)).ToList();
                foreach (var unit in AntiAirUnits)
                {
                    unit.SetDamage(unit.Unit.Type.Stats.AirAttack.Value);
                }
            }
            else if (attacker.IsArtillery())
            {
                AttackType = AttackType.ArtilleryAttack;
            }
            else
            {
                AttackType = AttackType.GroundAttack;
            }

            // Calculate the outcome right away
            Attack();
        }
Ejemplo n.º 2
0
        public Combat(Unit attacker, Unit defender, bool useRandomisedCombatEfficiency, List<Unit> antiAirUnits = null)
        {
            UseRandomisedCombatEfficiency = useRandomisedCombatEfficiency;
            Generator = new NormalDistribution(GameConstants.CombatEfficiencyMean, GameConstants.CombatEfficiencyDeviation);

            Attacker = new UnitCombatState(attacker, this);
            Defender = new UnitCombatState(defender, this);

            if (attacker.IsAirUnit())
            {
                AttackType = AttackType.AirAttack;
                AntiAirUnits = antiAirUnits.Select((Unit x) => new UnitCombatState(x, this)).ToList();
                foreach (var unit in AntiAirUnits)
                    unit.SetDamage(unit.Unit.Type.Stats.AirAttack.Value);
            }
            else if (attacker.IsArtillery())
                AttackType = AttackType.ArtilleryAttack;
            else
                AttackType = AttackType.GroundAttack;

            // Calculate the outcome right away
            Attack();
        }
Ejemplo n.º 3
0
        // This multiplier is used for attacks that become weaker as the target becomes smaller (i.e. diminishes in strength)
        // This includes artillery fire, attacks by air units and anti-air fire
        double GetStrengthAdjustedDamageFactor(UnitCombatState target, double minimumEfficiency)
        {
            double efficiency = minimumEfficiency + target.Strength * (1 - minimumEfficiency);

            return(efficiency);
        }
Ejemplo n.º 4
0
 // This multiplier is used for attacks that become weaker as the target becomes smaller (i.e. diminishes in strength)
 // This includes artillery fire, attacks by air units and anti-air fire
 double GetStrengthAdjustedDamageFactor(UnitCombatState target, double minimumEfficiency)
 {
     double efficiency = minimumEfficiency + target.Strength * (1 - minimumEfficiency);
     return efficiency;
 }