public Ship(Ship shipToCopy) { Name = shipToCopy.Name; DesignID = shipToCopy.DesignID; Owner = shipToCopy.Owner; Size = shipToCopy.Size; WhichStyle = shipToCopy.WhichStyle; Engine = new KeyValuePair<Equipment, float>(shipToCopy.Engine.Key, shipToCopy.Engine.Value); Shield = shipToCopy.Shield; Armor = shipToCopy.Armor; Computer = shipToCopy.Computer; ECM = shipToCopy.ECM; Array.Copy(shipToCopy.Weapons, Weapons, Weapons.Length); Array.Copy(shipToCopy.Specials, Specials, Specials.Length); }
public void Clear(List<Technology> availableArmorTechs, List<Technology> availableEngineTechs) { //Used by ship design screen to clear out everything for (int i = 0; i < Weapons.Length; i++) { Weapons[i] = new KeyValuePair<Equipment, int>(); } for (int i = 0; i < Specials.Length; i++) { Specials[i] = null; } ECM = null; Computer = null; Shield = null; ManeuverSpeed = 1; Armor = new Equipment(availableArmorTechs[0], false); Engine = new KeyValuePair<Equipment, float>(new Equipment(availableEngineTechs[0], false), 0); UpdateEngineNumber(); }
public void Load(XElement shipDesign, GameMain gameMain) { Name = shipDesign.Attribute("Name").Value; DesignID = int.Parse(shipDesign.Attribute("DesignID").Value); Size = int.Parse(shipDesign.Attribute("Size").Value); WhichStyle = int.Parse(shipDesign.Attribute("WhichStyle").Value); Engine = new KeyValuePair<Equipment, float>(LoadEquipment(shipDesign.Attribute("Engine").Value, gameMain), float.Parse(shipDesign.Attribute("NumOfEngines").Value)); Armor = LoadEquipment(shipDesign.Attribute("Armor").Value, gameMain); Shield = LoadEquipment(shipDesign.Attribute("Shield").Value, gameMain); Computer = LoadEquipment(shipDesign.Attribute("Computer").Value, gameMain); ECM = LoadEquipment(shipDesign.Attribute("ECM").Value, gameMain); int iter = 0; foreach (var weapon in shipDesign.Elements("Weapon")) { if (weapon.Attribute("Name").Value == "null") { Weapons[iter] = new KeyValuePair<Equipment, int>(); } else { var weaponTech = LoadEquipment(weapon.Attribute("Name").Value, gameMain); weaponTech.UseSecondary = bool.Parse(weapon.Attribute("IsSecondary").Value); Weapons[iter] = new KeyValuePair<Equipment, int>(weaponTech, int.Parse(weapon.Attribute("NumOfMounts").Value)); } iter++; } iter = 0; foreach (var special in shipDesign.Elements("Special")) { if (special.Attribute("Name").Value == "null") { Specials[iter] = null; } else { var specialTech = LoadEquipment(special.Attribute("Name").Value, gameMain); Specials[iter] = specialTech; } iter++; } }
private void UpdateValues() { //After researching or obtaining a technology, update all values FuelRange = 3; RoboticControls = 2; IndustryWasteRate = 1.0f; IndustryCleanupPerBC = 2; MaxTerraformPop = 0; TerraformCost = 6; CloningCost = 20; FactoryCost = 10; FactoryDiscount = 10; HighestPlanetaryShield = 0; Technology bestArmor = null; Technology bestBattleComputer = null; Technology bestMissile = null; Technology bestShield = null; Technology bestECM = null; int bestScanner = 0; foreach (var tech in ResearchedPropulsionTechs) { if (tech.FuelRange > FuelRange) { FuelRange = tech.FuelRange; } } foreach (var tech in ResearchedComputerTechs) { if (tech.RoboticControl > RoboticControls) { RoboticControls = tech.RoboticControl; FactoryCost = RoboticControls * 5; } if (tech.BattleComputer > 0 && (bestBattleComputer == null || bestBattleComputer.BattleComputer < tech.BattleComputer)) { bestBattleComputer = tech; } if (tech.ECM > 0 && (bestECM == null || bestECM.ECM < tech.ECM)) { bestECM = tech; } if (tech.SpaceScanner > bestScanner) { bestScanner = tech.SpaceScanner; } } switch (bestScanner) { case 0: FleetRadarRange = 0; PlanetRadarRange = 3; ShowEnemyETA = false; RadarExplorePlanets = false; break; case Technology.DEEP_SPACE_SCANNER: FleetRadarRange = 1; PlanetRadarRange = 5; ShowEnemyETA = false; RadarExplorePlanets = false; break; case Technology.IMPROVED_SPACE_SCANNER: FleetRadarRange = 2; PlanetRadarRange = 7; ShowEnemyETA = true; RadarExplorePlanets = false; break; case Technology.ADVANCED_SPACE_SCANNER: FleetRadarRange = 3; PlanetRadarRange = 9; ShowEnemyETA = true; RadarExplorePlanets = true; break; } foreach (var tech in ResearchedConstructionTechs) { if (tech.IndustrialWaste / 100.0f < IndustryWasteRate) { IndustryWasteRate = tech.IndustrialWaste / 100.0f; } if (tech.IndustrialTech < FactoryDiscount) { FactoryDiscount = tech.IndustrialTech; } if (tech.Armor > 0 && (bestArmor == null || bestArmor.Armor < tech.Armor)) { bestArmor = tech; } } foreach (var tech in ResearchedForceFieldTechs) { if (tech.PlanetaryShield > HighestPlanetaryShield) { HighestPlanetaryShield = tech.PlanetaryShield; } if (tech.Shield > 0 && (bestShield == null || bestShield.Shield < tech.Shield)) { bestShield = tech; } } //Convert FactoryDiscount to a decimal for less math later on FactoryDiscount *= 0.1f; foreach (var tech in ResearchedPlanetologyTechs) { if (tech.EcoCleanup > IndustryCleanupPerBC) { IndustryCleanupPerBC = tech.EcoCleanup; } if (tech.Enrichment == Technology.SOIL_ENRICHMENT) { HasSoilEnrichment = true; } if (tech.Enrichment == Technology.ADV_SOIL_ENRICHMENT) { HasAdvancedSoilEnrichment = true; } if (tech.Enrichment == Technology.ATMOSPHERIC_TERRAFORMING) { HasAtmosphericTerraform = true; } if (tech.Terraforming > MaxTerraformPop) { MaxTerraformPop = tech.Terraforming; } if (tech.TerraformCost < TerraformCost) { TerraformCost = tech.TerraformCost; } if (tech.Cloning < CloningCost) { CloningCost = tech.Cloning; } } foreach (var tech in ResearchedWeaponTechs) { if (tech.WeaponType == Technology.MISSILE_WEAPON && (bestMissile == null || bestMissile.MaximumWeaponDamage < tech.MaximumWeaponDamage)) { bestMissile = tech; } } //Now add up the cost for missile base this turn /* Missile base cost is broken down as following: * Battle Scanner and Subspace Interdictor are free * Armor = 60% of Large Ship Cost, 1/2 HP of Large Ship HP * Missiles = 540% of base cost, 3 missiles fired per base, +1 speed and double range * Shields = 61% of Large Ship Cost * Battle Computers = 61% of Large Ship Cost * ECM = 62% of Large Ship Cost * Base Slab (Construction Tech Level 1) = 120 BC * */ Dictionary<TechField, int> techLevels = new Dictionary<TechField, int>(); techLevels.Add(TechField.FORCE_FIELD, ForceFieldLevel); techLevels.Add(TechField.WEAPON, WeaponLevel); techLevels.Add(TechField.PROPULSION, PropulsionLevel); techLevels.Add(TechField.COMPUTER, ComputerLevel); techLevels.Add(TechField.CONSTRUCTION, ConstructionLevel); techLevels.Add(TechField.PLANETOLOGY, PlanetologyLevel); //Factor in Slab's base price of 120, minus minizaturation int levelDifference = ConstructionLevel; if (levelDifference > 50) { levelDifference = 50; //Cap the miniaturization at 50 levels } MissileBaseCost = (float)(120 * (Math.Pow(0.5, (levelDifference / 10.0)))); if (bestArmor != null) { var armor = new Equipment(bestArmor, false); MissileBaseCost += armor.GetCost(techLevels, 2) * 0.6f; } if (bestMissile != null) { var missile = new Equipment(bestMissile, false); MissileBaseCost += missile.GetCost(techLevels, 2) * 5.4f; } if (bestBattleComputer != null) { var battleComputer = new Equipment(bestBattleComputer, false); MissileBaseCost += battleComputer.GetCost(techLevels, 2) * 0.61f; } if (bestECM != null) { var ecm = new Equipment(bestECM, false); MissileBaseCost += ecm.GetCost(techLevels, 2) * 0.62f; } MissileBaseCostInNebula = MissileBaseCost; //Since shields don't work in nebulaes, doesn't make sense to build shields if (bestShield != null) { var shield = new Equipment(bestShield, false); MissileBaseCost += shield.GetCost(techLevels, 2) * 0.61f; } }