private void writeFormation() { // phony name LevelPipeline.LevelContent testValue = new LevelPipeline.LevelContent("editor" + _fileCount); // now we build the level data from our stored formation data ArrayList soldiers = _formation.getSoldiers(); List<int> soldierInts = new List<int>(30); foreach (Soldier soldat in soldiers) { soldierInts.Add(soldat.getClass()); } testValue.formations.Add(soldierInts); // remove starting motionlessness while (_pattern.ElementAt(0).actions.Count == 1 && _pattern[0].actions[0] == PatternAction.ACTION_RAISE) _pattern.RemoveAt(0); testValue.formationActions.Add(_pattern); testValue.formationPositions.Add(new Vector2(0f, 0f)); testValue.formationNames.Add("C**k"); testValue.formationActionNames.Add(new List<string>(32)); foreach (LevelPipeline.PatternActionContent p in _pattern) testValue.formationActionNames[0].Add("Balls"); testValue.formationTimes.Add(0f); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; using (XmlWriter xmlWriter = XmlWriter.Create("Content\\editor" + _fileCount + ".xml", settings)) { IntermediateSerializer.Serialize(xmlWriter, testValue, null); } }
private void saveButton_Click(object sender, EventArgs e) { // make levelContent from our level LevelPipeline.LevelContent testValue = new LevelPipeline.LevelContent(_levels[currLevel].levelName); testValue.formations = _levels[currLevel].formations; foreach (List<PatternAction> lp in _levels[currLevel].formationActions) { testValue.formationActions.Add(new List<LevelPipeline.PatternActionContent>(20)); foreach (PatternAction pa in lp) testValue.formationActions[testValue.formationActions.Count - 1].Add(new LevelPipeline.PatternActionContent(pa.actions, pa.duration)); } testValue.formationPositions = _levels[currLevel].formationPositions; testValue.formationTimes = _levels[currLevel].formationTimes; testValue.formationSides = _levels[currLevel].formationSides; testValue.formationNames = _levels[currLevel].formationNames; testValue.formationActionNames = _levels[currLevel].formationActionNames; testValue.terrains = _levels[currLevel].terrains; testValue.terrainPositions = _levels[currLevel].terrainPositions; testValue.terrainTimes = _levels[currLevel].terrainTimes; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; using (XmlWriter xmlWriter = XmlWriter.Create("Content\\" + testValue.levelName + ".xml", settings)) { IntermediateSerializer.Serialize(xmlWriter, testValue, null); } }