Ejemplo n.º 1
0
 public static Level fromXML(XmlElement node, Game gameref, String campaignPath)
 {
     Level newLvl = new Level();
     newLvl.number = int.Parse(node.GetElementsByTagName("number")[0].FirstChild.Value);
     if (node.HasAttribute("autoProgress"))
         newLvl.autoProgress = bool.Parse(node.GetAttribute("autoProgress"));
     newLvl.name = node.GetAttribute("name");
     foreach (string singleAdj in node.GetElementsByTagName("adj")[0].FirstChild.Value.Split(','))
         newLvl.adjacent.Add(Int32.Parse(singleAdj));
     XmlNodeList list = node.GetElementsByTagName("prereq");
     if (list.Count > 0 && list[0].FirstChild != null)
         foreach (string singlePrereq in node.GetElementsByTagName("prereq")[0].FirstChild.Value.Split(','))
             newLvl.prereq.Add(Int32.Parse(singlePrereq));
     newLvl.loc = XMLUtil.fromXMLVector2(node.GetElementsByTagName("location")[0]);
     if (node.GetElementsByTagName("horizonPath").Count > 0)
         newLvl.horizon = node.GetElementsByTagName("horizonPath")[0].FirstChild.Value;
     if (node.GetElementsByTagName("items").Count > 0)
         foreach (XmlElement item in node.GetElementsByTagName("items")[0].ChildNodes)
             newLvl.items.Add(GameItem.fromXML(item));
     if (node.GetElementsByTagName("spawns").Count > 0)
         foreach (XmlElement item in node.GetElementsByTagName("spawns")[0].ChildNodes)
             newLvl.spawns.Add(SpawnPoint.fromXML(item));
     /*XmlNodeList storyNodes = node.GetElementsByTagName("story");
     if (storyNodes.Count > 0 && storyNodes[0].ChildNodes.Count > 0)
         foreach (XmlNode item in storyNodes[0].ChildNodes)
             newLvl.storyElements.Add(StoryElement.fromXML(item, gameref));*/
     newLvl.levelLength = int.Parse(node.GetAttribute("length"));
     foreach (XmlElement graphic in node.GetElementsByTagName("graphic"))
         newLvl.backgroundItems.Add(BackgroundItemStruct.fromXML(graphic));
     return newLvl;
 }
Ejemplo n.º 2
0
 public void addLevel()
 {
     Level item = new Level();
     selectedLevelIndex = levels.Count;
     item.number = selectedLevelIndex;
     item.loc.X = Mouse.GetState().X;
     item.loc.Y = Mouse.GetState().Y;
     levels.Add(item);
     control.setLevelInfo(item.loc.X, item.loc.Y, item.name, item.number, false);
 }