private static Unit CreateUnit(UnitTemplate template) { Unit unit = template.GenerateUnitFromTemplateWithoutChildren(template.Name); foreach (UnitTemplate childUnit in template.GetChildUnits()) { unit.ChildUnits.Add(CreateUnit(childUnit)); } if (unit.HQSquad != null) { AddSquad(unit.HQSquad); } foreach (Squad squad in unit.Squads) { AddSquad(squad); } return(unit); }
private static void BuildUnitTreeHelper(Unit rootUnit, UnitTemplate rootTemplate) { string[] companyStrings = { "First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth" }; int stringIndex = 0; foreach (UnitTemplate child in rootTemplate.GetChildUnits()) { string name; if (child.Name.Contains("Company")) { name = companyStrings[stringIndex] + " Company"; stringIndex++; } else { name = child.Name; } Unit newUnit = child.GenerateUnitFromTemplateWithoutChildren(name); rootUnit.ChildUnits.Add(newUnit); newUnit.ParentUnit = rootUnit; BuildUnitTreeHelper(newUnit, child); } }