public void Load(XElement fleet, FleetManager fleetManager, Empire empire, GameMain gameMain) { _empire = empire; _galaxyX = float.Parse(fleet.Attribute("X").Value); _galaxyY = float.Parse(fleet.Attribute("Y").Value); _adjacentSystem = gameMain.Galaxy.GetStarWithID(int.Parse(fleet.Attribute("AdjacentSystem").Value)); var travelNodes = fleet.Element("TravelNodes"); if (travelNodes != null) { _travelNodes = new List <TravelNode>(); StarSystem startingPlace = null; foreach (var travelNode in travelNodes.Elements()) { var destination = gameMain.Galaxy.GetStarWithID(int.Parse(travelNode.Attribute("Destination").Value)); if (startingPlace == null) { _travelNodes.Add(gameMain.Galaxy.GenerateTravelNode(_galaxyX, _galaxyY, destination)); } else { _travelNodes.Add(gameMain.Galaxy.GenerateTravelNode(startingPlace, destination)); } startingPlace = destination; } } foreach (var ship in fleet.Elements("Ship")) { AddShips(fleetManager.GetShipWithDesignID(int.Parse(ship.Attribute("ShipDesign").Value)), int.Parse(ship.Attribute("NumberOfShips").Value)); } foreach (var transport in fleet.Elements("Transport")) { AddTransport(gameMain.RaceManager.GetRace(transport.Attribute("Race").Value), int.Parse(transport.Attribute("Count").Value)); } }
public List <Fleet> CheckColonizableSystems(Galaxy galaxy) { List <Fleet> colonizingFleets = new List <Fleet>(); foreach (Fleet fleet in FleetManager.GetFleets()) { if (fleet.TravelNodes == null || fleet.TravelNodes.Count == 0) { if (fleet.AdjacentSystem.Planets[0].Owner != null) { continue; } int colonyReq = fleet.AdjacentSystem.Planets[0].ColonyRequirement; foreach (Ship ship in fleet.OrderedShips) { foreach (var special in ship.Specials) { if (special != null && special.Technology.Colony >= colonyReq) { colonizingFleets.Add(fleet); break; } } } } } return(colonizingFleets); }
public Empire() { FleetManager = new FleetManager(this); TechnologyManager = new TechnologyManager(); PlanetManager = new PlanetManager(); SitRepManager = new SitRepManager(); visibleOtherFleets = new List<Fleet>(); }
public Empire() { FleetManager = new FleetManager(this); TechnologyManager = new TechnologyManager(); PlanetManager = new PlanetManager(); SitRepManager = new SitRepManager(); visibleOtherFleets = new List <Fleet>(); }
public void SetHomeSystem(StarSystem homeSystem, Planet homePlanet) { selectedSystem = homeSystem; lastSelectedSystem = homeSystem; PlanetManager.AddOwnedPlanet(homePlanet); FleetManager.SetupStarterFleet(homeSystem); homePlanet.ShipBeingBuilt = FleetManager.CurrentDesigns[0]; homePlanet.SetCleanup(); homePlanet.UpdateOutputs(); }
public void Load(XElement empireToLoad, GameMain gameMain) { empireID = int.Parse(empireToLoad.Attribute("ID").Value); empireName = empireToLoad.Attribute("Name").Value; EmpireColor = Color.FromArgb(int.Parse(empireToLoad.Attribute("Color").Value)); EmpireRace = gameMain.RaceManager.GetRace(empireToLoad.Attribute("Race").Value); type = bool.Parse(empireToLoad.Attribute("IsHumanPlayer").Value) ? PlayerType.HUMAN : PlayerType.CPU; lastSelectedSystem = gameMain.Galaxy.GetStarWithID(int.Parse(empireToLoad.Attribute("SelectedSystem").Value)); TechnologyManager.Load(empireToLoad, gameMain.MasterTechnologyManager); FleetManager.Load(empireToLoad, this, gameMain); }
public void Save(XmlWriter writer) { writer.WriteStartElement("Empire"); writer.WriteAttributeString("ID", empireID.ToString()); writer.WriteAttributeString("Name", empireName); writer.WriteAttributeString("Color", empireColor.ToArgb().ToString()); writer.WriteAttributeString("Race", EmpireRace.RaceName); writer.WriteAttributeString("IsHumanPlayer", type == PlayerType.HUMAN ? "True" : "False"); writer.WriteAttributeString("SelectedSystem", lastSelectedSystem.ID.ToString()); TechnologyManager.Save(writer); FleetManager.Save(writer); //sitRepManager.Save(writer); writer.WriteEndElement(); }
public List <StarSystem> CheckExploredSystems(Galaxy galaxy) { List <StarSystem> exploredSystems = new List <StarSystem>(); foreach (Fleet fleet in FleetManager.GetFleets()) { if (fleet.TravelNodes == null || fleet.TravelNodes.Count == 0) { StarSystem systemExplored = fleet.AdjacentSystem; if (systemExplored != null && !systemExplored.IsThisSystemExploredByEmpire(this)) { SitRepManager.AddItem(new SitRepItem(Screen.Galaxy, systemExplored, null, new Point(systemExplored.X, systemExplored.Y), systemExplored.Name + " has been explored.")); systemExplored.AddEmpireExplored(this); exploredSystems.Add(systemExplored); } } } return(exploredSystems); }
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 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 LandTransports() { List <Fleet> fleetsToRemove = new List <Fleet>(); foreach (var fleet in FleetManager.GetFleets()) { if (fleet.TransportShips.Count > 0 && (fleet.TravelNodes == null || fleet.TravelNodes.Count == 0) && fleet.AdjacentSystem != null) { if (fleet.AdjacentSystem.Planets[0].Owner == this) { foreach (var transport in fleet.TransportShips) { fleet.AdjacentSystem.Planets[0].AddRacePopulation(transport.raceOnShip, transport.amount); } fleetsToRemove.Add(fleet); } } } foreach (var fleet in fleetsToRemove) { FleetManager.RemoveFleet(fleet); } }
public void Load(XElement fleet, FleetManager fleetManager, Empire empire, GameMain gameMain) { _empire = empire; _galaxyX = float.Parse(fleet.Attribute("X").Value); _galaxyY = float.Parse(fleet.Attribute("Y").Value); _adjacentSystem = gameMain.Galaxy.GetStarWithID(int.Parse(fleet.Attribute("AdjacentSystem").Value)); var travelNodes = fleet.Element("TravelNodes"); if (travelNodes != null) { _travelNodes = new List<TravelNode>(); StarSystem startingPlace = null; foreach (var travelNode in travelNodes.Elements()) { var destination = gameMain.Galaxy.GetStarWithID(int.Parse(travelNode.Attribute("Destination").Value)); if (startingPlace == null) { _travelNodes.Add(gameMain.Galaxy.GenerateTravelNode(_galaxyX, _galaxyY, destination)); } else { _travelNodes.Add(gameMain.Galaxy.GenerateTravelNode(startingPlace, destination)); } startingPlace = destination; } } foreach (var ship in fleet.Elements("Ship")) { AddShips(fleetManager.GetShipWithDesignID(int.Parse(ship.Attribute("ShipDesign").Value)), int.Parse(ship.Attribute("NumberOfShips").Value)); } foreach (var transport in fleet.Elements("Transport")) { AddTransport(gameMain.RaceManager.GetRace(transport.Attribute("Race").Value), int.Parse(transport.Attribute("Count").Value)); } }