//This stores whether or not the secondary technology item is used, as well as store other useful data for use in space combat public Equipment(Technology whichTech, bool useSecondary) { Technology = whichTech; UseSecondary = useSecondary; }
public void Load(XElement empire, MasterTechnologyManager MTM) { var technologies = empire.Element("Technologies"); var compTechs = technologies.Element("Computer"); var constTechs = technologies.Element("Construction"); var ffTechs = technologies.Element("ForceField"); var planetTechs = technologies.Element("Planetology"); var propTechs = technologies.Element("Propulsion"); var weaponTechs = technologies.Element("Weapon"); WhichComputerBeingResearched = MTM.GetTechnologyWithName(compTechs.Attribute("Researching").Value); WhichConstructionBeingResearched = MTM.GetTechnologyWithName(constTechs.Attribute("Researching").Value); WhichForceFieldBeingResearched = MTM.GetTechnologyWithName(ffTechs.Attribute("Researching").Value); WhichPlanetologyBeingResearched = MTM.GetTechnologyWithName(planetTechs.Attribute("Researching").Value); WhichPropulsionBeingResearched = MTM.GetTechnologyWithName(propTechs.Attribute("Researching").Value); WhichWeaponBeingResearched = MTM.GetTechnologyWithName(weaponTechs.Attribute("Researching").Value); ComputerPercentage = int.Parse(compTechs.Attribute("Percentage").Value); ConstructionPercentage = int.Parse(constTechs.Attribute("Percentage").Value); ForceFieldPercentage = int.Parse(ffTechs.Attribute("Percentage").Value); PlanetologyPercentage = int.Parse(planetTechs.Attribute("Percentage").Value); PropulsionPercentage = int.Parse(propTechs.Attribute("Percentage").Value); WeaponPercentage = int.Parse(weaponTechs.Attribute("Percentage").Value); ComputerLocked = bool.Parse(compTechs.Attribute("Locked").Value); ConstructionLocked = bool.Parse(constTechs.Attribute("Locked").Value); ForceFieldLocked = bool.Parse(ffTechs.Attribute("Locked").Value); PlanetologyLocked = bool.Parse(planetTechs.Attribute("Locked").Value); PropulsionLocked = bool.Parse(propTechs.Attribute("Locked").Value); WeaponLocked = bool.Parse(weaponTechs.Attribute("Locked").Value); ComputerResearchAmount = float.Parse(compTechs.Attribute("Invested").Value); ConstructionResearchAmount = float.Parse(constTechs.Attribute("Invested").Value); ForceFieldResearchAmount = float.Parse(ffTechs.Attribute("Invested").Value); PlanetologyResearchAmount = float.Parse(planetTechs.Attribute("Invested").Value); PropulsionResearchAmount = float.Parse(propTechs.Attribute("Invested").Value); WeaponResearchAmount = float.Parse(weaponTechs.Attribute("Invested").Value); foreach (var researched in compTechs.Element("Researched").Elements()) { ResearchedComputerTechs.Add(MTM.GetTechnologyWithName(researched.Value)); } foreach (var unresearched in compTechs.Element("Unresearched").Elements()) { UnresearchedComputerTechs.Add(MTM.GetTechnologyWithName(unresearched.Value)); } foreach (var researched in constTechs.Element("Researched").Elements()) { ResearchedConstructionTechs.Add(MTM.GetTechnologyWithName(researched.Value)); } foreach (var unresearched in constTechs.Element("Unresearched").Elements()) { UnresearchedConstructionTechs.Add(MTM.GetTechnologyWithName(unresearched.Value)); } foreach (var researched in ffTechs.Element("Researched").Elements()) { ResearchedForceFieldTechs.Add(MTM.GetTechnologyWithName(researched.Value)); } foreach (var unresearched in ffTechs.Element("Unresearched").Elements()) { UnresearchedForceFieldTechs.Add(MTM.GetTechnologyWithName(unresearched.Value)); } foreach (var researched in planetTechs.Element("Researched").Elements()) { ResearchedPlanetologyTechs.Add(MTM.GetTechnologyWithName(researched.Value)); } foreach (var unresearched in planetTechs.Element("Unresearched").Elements()) { UnresearchedPlanetologyTechs.Add(MTM.GetTechnologyWithName(unresearched.Value)); } foreach (var researched in propTechs.Element("Researched").Elements()) { ResearchedPropulsionTechs.Add(MTM.GetTechnologyWithName(researched.Value)); } foreach (var unresearched in propTechs.Element("Unresearched").Elements()) { UnresearchedPropulsionTechs.Add(MTM.GetTechnologyWithName(unresearched.Value)); } foreach (var researched in weaponTechs.Element("Researched").Elements()) { ResearchedWeaponTechs.Add(MTM.GetTechnologyWithName(researched.Value)); } foreach (var unresearched in weaponTechs.Element("Unresearched").Elements()) { UnresearchedWeaponTechs.Add(MTM.GetTechnologyWithName(unresearched.Value)); } UpdateValues(); }
public void SetupStarterFleet(StarSystem homeSystem) { Technology retroEngine = null; Technology titaniumArmor = null; Technology laser = null; Technology nuclearMissile = null; Technology nuclearBomb = null; foreach (var tech in _empire.TechnologyManager.ResearchedPropulsionTechs) { if (tech.Speed == 1) { retroEngine = tech; break; } } foreach (var tech in _empire.TechnologyManager.ResearchedConstructionTechs) { if (tech.Armor == Technology.TITANIUM_ARMOR) { titaniumArmor = tech; break; } } foreach (var tech in _empire.TechnologyManager.ResearchedWeaponTechs) { if (tech.TechName == "Laser") { laser = tech; } else if (tech.TechName == "Nuclear Missile") { nuclearMissile = tech; } else if (tech.TechName == "Nuclear Bomb") { nuclearBomb = tech; } } Ship scout = new Ship(); scout.Name = "Scout"; scout.Owner = _empire; scout.Size = Ship.SMALL; scout.WhichStyle = 0; scout.Armor = new Equipment(titaniumArmor, false); foreach (var tech in _empire.TechnologyManager.ResearchedConstructionTechs) { if (tech.ReserveFuelTanks) { scout.Specials[0] = new Equipment(tech, false); break; } } scout.Engine = new KeyValuePair <Equipment, float>(new Equipment(retroEngine, false), scout.PowerUsed / (retroEngine.Speed * 10)); scout.DesignID = _currentShipDesignID; CurrentDesigns.Add(scout); _currentShipDesignID++; Ship fighter = new Ship(); fighter.Name = "Fighter"; fighter.Owner = _empire; fighter.Size = Ship.SMALL; fighter.WhichStyle = 1; fighter.Weapons[0] = new KeyValuePair <Equipment, int>(new Equipment(laser, false), 1); fighter.Armor = new Equipment(titaniumArmor, false); fighter.Engine = new KeyValuePair <Equipment, float>(new Equipment(retroEngine, false), fighter.PowerUsed / (retroEngine.Speed * 10)); CurrentDesigns.Add(fighter); _currentShipDesignID++; Ship destroyer = new Ship(); destroyer.Name = "Destroyer"; destroyer.Owner = _empire; destroyer.Size = Ship.MEDIUM; destroyer.WhichStyle = 0; destroyer.Weapons[0] = new KeyValuePair <Equipment, int>(new Equipment(nuclearMissile, false), 1); destroyer.Weapons[1] = new KeyValuePair <Equipment, int>(new Equipment(laser, false), 3); destroyer.Armor = new Equipment(titaniumArmor, false); destroyer.Engine = new KeyValuePair <Equipment, float>(new Equipment(retroEngine, false), destroyer.PowerUsed / (retroEngine.Speed * 10)); CurrentDesigns.Add(destroyer); _currentShipDesignID++; Ship bomber = new Ship(); bomber.Name = "Bomber"; bomber.Owner = _empire; bomber.Size = Ship.MEDIUM; bomber.WhichStyle = 1; bomber.Weapons[0] = new KeyValuePair <Equipment, int>(new Equipment(nuclearBomb, false), 2); bomber.Weapons[1] = new KeyValuePair <Equipment, int>(new Equipment(laser, false), 2); bomber.Armor = new Equipment(titaniumArmor, false); bomber.Engine = new KeyValuePair <Equipment, float>(new Equipment(retroEngine, false), bomber.PowerUsed / (retroEngine.Speed * 10)); CurrentDesigns.Add(bomber); _currentShipDesignID++; Ship colonyShip = new Ship(); colonyShip.Name = "Colony Ship"; colonyShip.Owner = _empire; colonyShip.Size = Ship.LARGE; colonyShip.WhichStyle = 0; colonyShip.Armor = new Equipment(titaniumArmor, false); foreach (var tech in _empire.TechnologyManager.ResearchedPlanetologyTechs) { if (tech.Colony == Technology.STANDARD_COLONY) { colonyShip.Specials[0] = new Equipment(tech, false); break; } } colonyShip.Engine = new KeyValuePair <Equipment, float>(new Equipment(retroEngine, false), colonyShip.PowerUsed / (retroEngine.Speed * 10)); colonyShip.DesignID = _currentShipDesignID; CurrentDesigns.Add(colonyShip); _currentShipDesignID++; LastShipDesign = new Ship(scout); //Make a copy so we don't accidentally modify the original ship Fleet starterFleet = new Fleet(); starterFleet.GalaxyX = homeSystem.X; starterFleet.GalaxyY = homeSystem.Y; starterFleet.AdjacentSystem = homeSystem; starterFleet.Empire = _empire; starterFleet.AddShips(CurrentDesigns[0], 2); starterFleet.AddShips(CurrentDesigns[4], 1); _fleets.Add(starterFleet); }