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;
}
}