コード例 #1
0
        private void CalculateShield(Ship ship)
        {
            double shield          = 0;
            double absorptionSum   = 0;
            double regenerationSum = 0;
            int    count           = 0;

            foreach (var sgen in Shields.GroupBy(x => x))
            {
                shield          += sgen.Key.FromShields().Strength *sgen.Count();
                absorptionSum   += sgen.Key.FromShields().Absorption *sgen.Count();
                regenerationSum += sgen.Key.FromShields().Regeneration *sgen.Count();
                count           += sgen.Count();
            }

            foreach (double amount in ship.Boosts.Where(x => x.Type == BoosterType.SHIELD).Select(x => x.Amount))
            {
                shield *= amount;
            }

            bool isFullDroneDesign = Drones.GroupBy(x => x.StatsDesignID).Count() == 1;

            foreach (var dronePair in Drones)
            {
                double inner_shield = 0;
                foreach (var sgen in dronePair.ShieldItems.GroupBy(x => x))
                {
                    inner_shield    += sgen.Key.FromShields().Strength *sgen.Count();
                    absorptionSum   += sgen.Key.FromShields().Absorption *sgen.Count();
                    regenerationSum += sgen.Key.FromShields().Regeneration *sgen.Count();
                    count           += sgen.Count();
                }
                inner_shield *= dronePair.DroneID.FromDrones().ShieldBoost;

                if (dronePair.StatsDesignID != DroneDesign.NONE.ID)
                {
                    DroneDesign design = dronePair.StatsDesignID.FromDroneDesigns();
                    if (isFullDroneDesign)
                    {
                        foreach (double amount in design.Full.Where(x => x.Type == BoosterType.SHIELD).Select(x => x.Amount))
                        {
                            inner_shield *= amount;
                        }
                    }
                    else
                    {
                        foreach (double amount in design.Single.Where(x => x.Type == BoosterType.SHIELD).Select(x => x.Amount))
                        {
                            inner_shield *= amount;
                        }
                    }
                }

                shield += inner_shield;
            }

            Shield = (int)shield;

            if (count > 0)
            {
                Absorption   = absorptionSum / count;
                Regeneration = regenerationSum / count;
            }
        }