Пример #1
0
        public static AirFightPower Sum <TSource>(this IEnumerable <TSource> source, Func <TSource, AirFightPower> selector)
        {
            AirFightPower result = default;

            foreach (var item in source)
            {
                result += selector(item);
            }
            return(result);
        }
Пример #2
0
        internal void DoCalculations()
        {
            using (EnterBatchNotifyScope())
            {
                if (Equipment?.Info?.Type is null)
                {
                    AirFightPower = default;
                    EffectiveLoS  = 0;
                    return;
                }

                var id = (KnownEquipmentType)Equipment.Info.Type.Id;

                double losFactor = id switch
                {
                    KnownEquipmentType.TorpedoBomber => 0.8,
                    KnownEquipmentType.ReconnaissanceAircraft => 1,
                    KnownEquipmentType.ReconnaissanceSeaplane => 1.2,
                    KnownEquipmentType.SeaplaneBomber => 1.1,
                    _ => 0.6,
                };
                double losImprovementFactor = id switch
                {
                    KnownEquipmentType.ReconnaissanceSeaplane => 1.2,
                    KnownEquipmentType.SmallRadar => 1.25,
                    KnownEquipmentType.LargeRadar => 1.4,
                    KnownEquipmentType.VeryLargeRadar => 1.4,
                    _ => 0
                };
                int[] afpBonusTable = id switch
                {
                    KnownEquipmentType.DiveBomber => afpBonus0,
                    KnownEquipmentType.JetBomber => afpBonus0,
                    KnownEquipmentType.TorpedoBomber => afpBonus0,
                    KnownEquipmentType.SeaplaneBomber => afpBonus1,
                    KnownEquipmentType.FighterAircraft => afpBonus2,
                    KnownEquipmentType.SeaplaneFighter => afpBonus2,
                    _ => null
                };

                EffectiveLoS = losFactor * (Equipment.Info.LineOfSight + Math.Sqrt(Equipment.ImprovementLevel) * losImprovementFactor);

                if (afpBonusTable == null || Aircraft.Current == 0)
                {
                    AirFightPower = default;
                }
                else
                {
                    double afpImprovementFactor = id switch
                    {
                        KnownEquipmentType.FighterAircraft => 0.2,
                        KnownEquipmentType.SeaplaneFighter => 0.2,
                        KnownEquipmentType.LandBasedFighter => 0.2,
                        KnownEquipmentType.DiveBomber => 0.25,
                        _ => 0
                    };
                    double afpRaw = (Equipment.Info.AntiAir + afpImprovementFactor * Equipment.ImprovementLevel) * Math.Sqrt(Aircraft.Current);
                    AirFightPower = new AirFightPower(afpRaw,
                                                      afpRaw + Math.Sqrt(airProficiencyCore[Equipment.AirProficiency] / 10.0) + afpBonusTable[Equipment.AirProficiency],
                                                      afpRaw + Math.Sqrt((airProficiencyCore[Equipment.AirProficiency + 1] - 1) / 10.0) + afpBonusTable[Equipment.AirProficiency]);
                }
            }
        }
    }
}
Пример #3
0
        private void UpdateCalculations()
        {
            if (Equipment == null)
            {
                AirFightPower = default;
                EffectiveLoS  = 0;
                return;
            }

            double losFactor = 0.6, losImprovementFactor = 0;

            int[] afpBonusTable = null;
            switch ((KnownEquipmentType)Equipment.Info.Type.Id)
            {
            case KnownEquipmentType.FighterAircraft:
            case KnownEquipmentType.SeaplaneFighter:
                afpBonusTable = afpBonus2;
                break;

            case KnownEquipmentType.DiveBomber:
            case KnownEquipmentType.JetBomber:
                afpBonusTable = afpBonus0;
                break;

            case KnownEquipmentType.TorpedoBomber:
                losFactor     = 0.8;
                afpBonusTable = afpBonus0;
                break;

            case KnownEquipmentType.ReconnaissanceAircraft:
                losFactor = 1;
                break;

            case KnownEquipmentType.ReconnaissanceSeaplane:
                losFactor            = 1.2;
                losImprovementFactor = 1.2;
                break;

            case KnownEquipmentType.SeaplaneBomber:
                losFactor     = 1.1;
                afpBonusTable = afpBonus1;
                break;

            case KnownEquipmentType.SmallRadar:
                losImprovementFactor = 1.25;
                break;

            case KnownEquipmentType.LargeRadar:
            case KnownEquipmentType.VeryLargeRadar:
                losImprovementFactor = 1.4;
                break;
            }

            EffectiveLoS = losFactor * (Equipment.Info.LineOfSight + Equipment.ImprovementLevel * losImprovementFactor);
            if (afpBonusTable == null || Aircraft.Current == 0)
            {
                AirFightPower = default;
            }
            else
            {
                double afpRaw = Equipment.Info.AntiAir * Math.Sqrt(Aircraft.Current);
                AirFightPower = new AirFightPower(afpRaw,
                                                  afpRaw + Math.Sqrt(airProficiencyCore[Equipment.AirProficiency] / 10.0) + afpBonusTable[Equipment.AirProficiency],
                                                  afpRaw + Math.Sqrt((airProficiencyCore[Equipment.AirProficiency + 1] - 1) / 10.0) + afpBonusTable[Equipment.AirProficiency]);
            }
        }