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