public XMLcastlewall(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.width = int.Parse(tree.Attribute("width")); this.height = int.Parse(tree.Attribute("height")); }
public LevelParser2(String levelname) { XMLTree tree = new XMLTree(); tree.GetData("levels.xml"); this.levelData = new XMLLevel(tree); if (this.levelData.HasIntro(levelname)) { this.levelData.SetLevel(levelname + (HUD.firstLevelEntrance[HUD.currentPlayer] ? "" : HotDAMN.TAG_SUBLEVEL + "main")); } else { this.levelData.SetLevel(levelname); } this.levelname = levelname; HUD.setting = GetSetting(); addedMario = false; addedBackground = false; addedTitlecard = levelData.GetLevelProperty("start", "title") == null; String ceiling = levelData.GetLevelProperty("setting", "type"); addedCeiling = ceiling == null || !ceiling.Equals("underwater"); SetPhysics(); this.levelMatrix = new List <List <Object> >(); for (int i = 0; i < Size().Width; i++) { this.levelMatrix.Add(new List <Object>()); } do /* party */ } {
// will only be called when tokens[index] is an opening tag public static int ParseTree(XMLTree tree, List <String> tokens, int index) { int startIndex = index; if (ParseTagName(tree, tokens[index])) { index++; while (tokens[index].IndexOf(">") == -1) { ParseAttribute(tree, tokens[index]); index++; } } bool hasChildren = tokens[index].IndexOf("/") == -1; index++; while (hasChildren && index < tokens.Count && tokens[index].IndexOf("/" + tree.name) == -1) { XMLTree child = new XMLTree(); tree.children.Add(child); int subConsumed = ParseTree(child, tokens, index); index += subConsumed; } if (hasChildren) { index++; } return(index - startIndex); }
public static void PrintTree(XMLTree tree, int i) { for (int j = 0; j < i; j++) { Console.Write(" "); } Console.Write("<" + tree.name); foreach (KeyValuePair <String, String> p in tree.attributes) { Console.Write(" " + p.Key + "=\"" + p.Value + "\""); } if (tree.children.Count > 0) { Console.WriteLine(">"); foreach (XMLTree child in tree.children) { PrintTree(child, i + 3); } for (int j = 0; j < i; j++) { Console.Write(" "); } Console.WriteLine("</" + tree.name + ">"); } else { Console.WriteLine(" />"); } }
public XMLgrassledge(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.width = int.Parse(tree.Attribute("width")); this.height = int.Parse(tree.Attribute("height")); }
public XMLgenerator(XMLTree tree) { this.xStart = int.Parse(tree.Attribute("xstart")); String e = tree.Attribute("xend"); this.xEnd = e == null ? 10000 : int.Parse(e); this.type = tree.Attribute("type"); }
public XMLhammerbro(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String a = tree.Attribute("action"); this.action = a == null ? "stay" : a; }
public XMLgoomba(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String c = tree.Attribute("count"); this.count = c == null ? 1 : int.Parse(c); }
public XMLstaircase(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.width = int.Parse(tree.Attribute("width")); this.height = int.Parse(tree.Attribute("height")); this.left = tree.Attribute("direction").Equals("left"); }
// return true if attributes present public static bool ParseTagName(XMLTree tree, String token) { int i = token.IndexOf('<'); int j = token.IndexOf('>'); tree.name = token.Substring(i + 1, j == -1 ? token.Length - i - 1 : j - i - 1); return(j == -1); }
public XMLlakitu(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String s = tree.Attribute("stop"); this.stop = s == null ? 10000 : int.Parse(s); }
public XMLmovingplatform(XMLTree tree) { this.x1 = int.Parse(tree.Attribute("x1")); this.y1 = int.Parse(tree.Attribute("y1")); this.x2 = int.Parse(tree.Attribute("x2")); this.y2 = int.Parse(tree.Attribute("y2")); this.width = int.Parse(tree.Attribute("width")); }
public XMLscaleplatforms(XMLTree tree) { this.x1 = int.Parse(tree.Attribute("x1")); this.y1 = int.Parse(tree.Attribute("y1")); this.x2 = int.Parse(tree.Attribute("x2")); this.y2 = int.Parse(tree.Attribute("y2")); this.y3 = int.Parse(tree.Attribute("y3")); this.width = int.Parse(tree.Attribute("width")); }
public XMLcoin(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String w = tree.Attribute("width"); String h = tree.Attribute("height"); this.width = w == null ? 1 : int.Parse(w); this.height = h == null ? 1 : int.Parse(h); }
public XMLfirebar(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String c = tree.Attribute("direction"); this.ccw = c != null && c.Equals("counterclockwise"); String s = tree.Attribute("size"); this.size = s != null ? (s.Equals("small") ? 6 : 10) : 0; }
public XMLinfiniteplatform(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.width = int.Parse(tree.Attribute("width")); this.frequency = double.Parse(tree.Attribute("frequency")); String d = tree.Attribute("direction"); this.up = d == null ? false : d.Equals("up"); String s = tree.Attribute("showpath"); this.showpath = s == null ? false : bool.Parse(s); }
public XMLbowser(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String h = tree.Attribute("hammers"); String f = tree.Attribute("fireballs"); String t = tree.Attribute("trueform"); this.hammers = h == null ? false : bool.Parse(h); this.fireballs = f == null ? false : bool.Parse(f); this.trueform = t == null ? "bowser" : t; }
public XMLpipe(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.height = int.Parse(tree.Attribute("height")); String w = tree.Attribute("width"); this.width = w == null ? 0 : int.Parse(w); this.name = tree.Attribute("name"); this.go = tree.Attribute("goto"); String s = tree.Attribute("showtop"); this.showtop = s != null; }
public XMLhiddenblock(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); String w = tree.Attribute("width"); String h = tree.Attribute("height"); this.width = w == null ? 1 : int.Parse(w); this.height = h == null ? 1 : int.Parse(h); String c = tree.Attribute("contains"); this.contains = c == null ? "coin" : c; this.go = tree.Attribute("goto"); }
// return true if flag attribute (no value) public static bool ParseAttribute(XMLTree tree, String token) { int i = token.IndexOf("="); if (i == -1) { tree.attributes.Add(token, "true"); return(true); } else { int j = token.IndexOf("\""); tree.attributes.Add(token.Substring(0, i), token.Substring(j + 1, token.IndexOf("\"", j + 1) - j - 1)); return(false); } }
public XMLloop(XMLTree tree) { checkpoints = new List <Tuple <int, int, int> >(); for (int i = 0; i < tree.ChildCount(); i++) { XMLTree t = tree.Child(i); if (t.Name().Equals("finish")) { finish = new Tuple <int, int>(int.Parse(t.Attribute("x")), int.Parse(t.Attribute("setback"))); } else { checkpoints.Add(new Tuple <int, int, int>( int.Parse(t.Attribute("x")), int.Parse(t.Attribute("y")), int.Parse(t.Attribute("height")) )); } } }
public bool HasIntro(String levelname) { LevelTag name = new LevelTag(levelname); levelTag = name; XMLTree foundLevel = tree.SomeChild("level", name.Level); if (foundLevel == null) { return(false); } XMLTree foundSubLevel = foundLevel.SomeChild("sublevel", "main"); if (foundSubLevel == null) { return(false); } return(true); }
public bool SetLevel(String tag) { LevelTag name = new LevelTag(tag); levelTag = name; XMLTree foundLevel = tree.SomeChild("level", name.Level); if (foundLevel == null) { return(false); } this.currentLevel = foundLevel; XMLTree foundSubLevel = foundLevel.SomeChild("sublevel", name.Sublevel); if (foundSubLevel == null) { return(false); } this.currentSublevel = foundSubLevel; return(true); }
public XMLbouncingkoopa(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); }
public XMLvine(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.height = int.Parse(tree.Attribute("height")); }
public XMLflagpole(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); }
public XMLridingplatform(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.width = int.Parse(tree.Attribute("width")); }
public XMLspringboard(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); }
public XMLtoad(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); }
public XMLbowserbridge(XMLTree tree) { this.x = int.Parse(tree.Attribute("x")); this.y = int.Parse(tree.Attribute("y")); this.width = int.Parse(tree.Attribute("width")); }