public void SplitFleet(Empire empire) { Fleet fleet = new Fleet(); fleet.Empire = FleetToSplit.Empire; fleet.GalaxyX = FleetToSplit.GalaxyX; fleet.GalaxyY = FleetToSplit.GalaxyY; fleet.AdjacentSystem = FleetToSplit.AdjacentSystem; foreach (KeyValuePair<Ship, int> ship in FleetToSplit.Ships) { if (ship.Value > 0) { SelectedFleet.SubtractShips(ship.Key, ship.Value); fleet.AddShips(ship.Key, ship.Value); } } foreach (var transport in FleetToSplit.TransportShips) { if (transport.amount > 0) { SelectedFleet.SubtractTransport(transport.raceOnShip, transport.amount); fleet.AddTransport(transport.raceOnShip, transport.amount); } } SelectedFleet.ClearEmptyShips(); fleet.ClearEmptyShips(); fleet.TravelNodes = FleetToSplit.TravelNodes; if (SelectedFleet.Ships.Count == 0 && SelectedFleet.TransportShips.Count == 0) { Fleets.Remove(SelectedFleet); empire.FleetManager.RemoveFleet(SelectedFleet); } if (fleet.Ships.Count > 0 || fleet.TransportShips.Count > 0) { Fleets.Add(fleet); empire.FleetManager.AddFleet(fleet); } SelectedFleet = fleet; }
public void SelectFleet(int whichFleet) { if (whichFleet < Fleets.Count) { SelectedFleet = Fleets[whichFleet]; FleetToSplit = new Fleet(); FleetToSplit.Empire = SelectedFleet.Empire; FleetToSplit.TravelNodes = SelectedFleet.TravelNodes; FleetToSplit.TentativeNodes = SelectedFleet.TentativeNodes; FleetToSplit.AdjacentSystem = SelectedFleet.AdjacentSystem; FleetToSplit.GalaxyX = SelectedFleet.GalaxyX; FleetToSplit.GalaxyY = SelectedFleet.GalaxyY; foreach (KeyValuePair<Ship, int> ship in SelectedFleet.Ships) { FleetToSplit.AddShips(ship.Key, ship.Value); } foreach (var transport in SelectedFleet.TransportShips) { FleetToSplit.AddTransport(transport.raceOnShip, transport.amount); } } }
public void LaunchTransports() { foreach (var planet in PlanetManager.Planets) { if (planet.TransferSystem.Key.StarSystem != null) { Fleet newFleet = new Fleet(); newFleet.Empire = this; newFleet.GalaxyX = planet.System.X; newFleet.GalaxyY = planet.System.Y; newFleet.AddTransport(planet.Races[0], planet.TransferSystem.Value); newFleet.TravelNodes = new List<TravelNode> {planet.TransferSystem.Key }; planet.RemoveRacePopulation(planet.Races[0], planet.TransferSystem.Value); planet.TransferSystem = new KeyValuePair<TravelNode,int>(new TravelNode(), 0); newFleet.ResetMove(); FleetManager.AddFleet(newFleet); } } }
public void CheckForBuiltShips() { foreach (Planet planet in PlanetManager.Planets) { int amount; Ship result = planet.CheckIfShipBuilt(out amount); if (amount > 0 && result != null) { Fleet newFleet = new Fleet(); newFleet.Empire = this; newFleet.GalaxyX = planet.System.X; newFleet.GalaxyY = planet.System.Y; newFleet.AdjacentSystem = planet.System; newFleet.AddShips(result, amount); FleetManager.AddFleet(newFleet); SitRepManager.AddItem(new SitRepItem(Screen.Galaxy, planet.System, planet, new Point(planet.System.X, planet.System.Y), planet.Name + " has produced " + amount + " " + result.Name + " ship" + (amount > 1 ? "s." : "."))); } } FleetManager.MergeIdleFleets(); }
public void AddFleet(Fleet fleet) { _fleets.Add(fleet); }
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); }
public void RemoveFleet(Fleet fleet) { _fleets.Remove(fleet); }
public void Load(XElement empireDoc, Empire empire, GameMain gameMain) { var currentDesigns = empireDoc.Element("CurrentShipDesigns"); foreach (var currentDesign in currentDesigns.Elements()) { var currentShip = new Ship(); currentShip.Load(currentDesign, gameMain); currentShip.Owner = empire; CurrentDesigns.Add(currentShip); } /*var obsoleteDesigns = empireDoc.Element("ObsoleteShipDesigns"); foreach (var obsoleteDesign in obsoleteDesigns.Elements()) { var obsoleteShip = new Ship(); obsoleteShip.Load(obsoleteDesign, gameMain); obsoleteShip.Owner = empire; ObsoleteDesigns.Add(obsoleteShip); }*/ var fleets = empireDoc.Element("Fleets"); foreach (var fleet in fleets.Elements()) { var newFleet = new Fleet(); newFleet.Load(fleet, this, empire, gameMain); _fleets.Add(newFleet); } }
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); }