private void CalculateDamage(Ship ship) { double damage = 0; foreach (var weapon in Weapons.GroupBy(x => x)) { int weaponCount = weapon.Count(); damage += weapon.Key.FromWeapons().Damage *weaponCount; LaserEquippedCount += weaponCount; } foreach (double amount in ship.Boosts.Where(x => x.Type == BoosterType.DAMAGE).Select(x => x.Amount)) { damage *= amount; } bool isFullDroneDesign = Drones.GroupBy(x => x.StatsDesignID).Count() == 1; foreach (var dronePair in Drones) { double inner_damage = 0; foreach (var weapon in dronePair.WeaponItems.GroupBy(x => x)) { int weaponCount = weapon.Count(); inner_damage += weapon.Key.FromWeapons().Damage *weaponCount; LaserEquippedCount += weaponCount; } inner_damage *= dronePair.DroneID.FromDrones().DamageBoost; if (dronePair.StatsDesignID != DroneDesign.NONE.ID) { DroneDesign design = dronePair.StatsDesignID.FromDroneDesigns(); if (isFullDroneDesign) { foreach (double amount in design.Full.Where(x => x.Type == BoosterType.DAMAGE).Select(x => x.Amount)) { inner_damage *= amount; } } else { foreach (double amount in design.Single.Where(x => x.Type == BoosterType.DAMAGE).Select(x => x.Amount)) { inner_damage *= amount; } } } damage += inner_damage; } Damage = (int)damage; }
protected internal List <EquipmentSlotItemController> GetItems() { List <EquipmentSlotItemController> result = new List <EquipmentSlotItemController>(); foreach (var pair in Vault.DroneDesigns) { DroneDesign design = pair.Key.FromDroneDesigns(); int equiped = Configuration.Drones.Count(x => x.StatsDesignID == pair.Key); for (int i = 0; i < pair.Value - equiped; i++) { result.Add(new EquipmentSlotItemController { Type = 0, ID = pair.Key, Name = design.Name }); } } foreach (var pair in Vault.Weapons) { Weapon weapon = pair.Key.FromWeapons(); int equiped = Configuration.Weapons.Count(x => x == pair.Key) + Configuration.Drones.Sum(x => x.WeaponItems.Count(y => y == pair.Key)); for (int i = 0; i < pair.Value - equiped; i++) { result.Add(new EquipmentSlotItemController { Type = 1, ID = pair.Key, Name = weapon.Name }); } } foreach (var pair in Vault.Shields) { Shield shield = pair.Key.FromShields(); int equiped = Configuration.Shields.Count(x => x == pair.Key) + Configuration.Drones.Sum(x => x.ShieldItems.Count(y => y == pair.Key)); for (int i = 0; i < pair.Value - equiped; i++) { result.Add(new EquipmentSlotItemController { Type = 2, ID = pair.Key, Name = shield.Name }); } } return(result); }
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; } }