/// <summary> /// Load: constructor to load EmpireData from an XmlNode representation. /// </summary> /// <param name="node">An XmlNode containing a EmpireData representation (from a save file).</param> public EmpireData(XmlNode node) { Initialize(); XmlNode mainNode = node.FirstChild; XmlNode subNode; while (mainNode != null) { switch (mainNode.Name.ToLower()) { case "id": empireId = ushort.Parse(mainNode.FirstChild.Value, System.Globalization.NumberStyles.HexNumber); break; case "fleetcounter": fleetCounter = long.Parse(mainNode.FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture); break; case "designcounter": designCounter = long.Parse(mainNode.FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture); break; case "turnyear": TurnYear = int.Parse(mainNode.FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture); break; case "turnsubmitted": TurnSubmitted = bool.Parse(mainNode.FirstChild.Value); break; case "lastturnsubmitted": LastTurnSubmitted = int.Parse(mainNode.FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture); break; case "race": race = new Race(); Race.LoadRaceFromXml(mainNode); break; case "research": subNode = mainNode.SelectSingleNode("Budget"); ResearchBudget = int.Parse(subNode.FirstChild.Value, System.Globalization.CultureInfo.InvariantCulture); subNode = mainNode.SelectSingleNode("AttainedLevels"); ResearchLevels = new TechLevel(subNode); subNode = mainNode.SelectSingleNode("SpentResources"); ResearchResources = new TechLevel(subNode); subNode = mainNode.SelectSingleNode("Topics"); ResearchTopics = new TechLevel(subNode); break; case "starreports": subNode = mainNode.FirstChild; while (subNode != null) { StarIntel report = new StarIntel(subNode); StarReports.Add(report.Name, report); subNode = subNode.NextSibling; } break; case "ownedstars": subNode = mainNode.FirstChild; while (subNode != null) { Star star = new Star(subNode); OwnedStars.Add(star); subNode = subNode.NextSibling; } break; case "fleetreports": subNode = mainNode.FirstChild; while (subNode != null) { FleetIntel report = new FleetIntel(subNode); FleetReports.Add(report.Key, report); subNode = subNode.NextSibling; } break; case "ownedfleets": subNode = mainNode.FirstChild; while (subNode != null) { Fleet fleet = new Fleet(subNode); OwnedFleets.Add(fleet); subNode = subNode.NextSibling; } break; case "otherempires": subNode = mainNode.FirstChild; while (subNode != null) { EmpireIntel report = new EmpireIntel(subNode); EmpireReports.Add(report.Id, report); subNode = subNode.NextSibling; } break; case "battleplan": BattlePlan plan = new BattlePlan(mainNode); BattlePlans[plan.Name] = plan; break; case "availablecomponents": subNode = mainNode.FirstChild; while (subNode != null) { AvailableComponents.Add(new Component(subNode)); subNode = subNode.NextSibling; } break; case "designs": subNode = mainNode.FirstChild; while (subNode != null) { ShipDesign design = new ShipDesign(subNode); Designs.Add(design.Key, design); subNode = subNode.NextSibling; } break; case "battlereport": BattleReport battle = new BattleReport(mainNode); BattleReports.Add(battle); break; } // If no orders have ever been turned in then ensure battle plans contain at least the default if (BattlePlans.Count == 0) { BattlePlans.Add("Default", new BattlePlan()); } mainNode = mainNode.NextSibling; } LinkReferences(); }
public FleetIntel GenerateReport(ScanLevel scan, int year) { FleetIntel report = new FleetIntel(this, scan, year); return(report); }