public static Door FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); Door entity = new Door(node.Attr("type", "wood")); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static LockBlock FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); LockBlock entity = new LockBlock(node.Attr("sprite", "wood")); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static JumpThru FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); int width = node.AttrInt("width", 0); JumpThru entity = new JumpThru(node.Attr("texture", "default"), width); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static ColorSwitch FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); string type = node.Attr("type", "green"); ColorSwitch entity = new ColorSwitch(type.Equals("green", StringComparison.OrdinalIgnoreCase) ? BlockColor.Green : type.Equals("red", StringComparison.OrdinalIgnoreCase) ? BlockColor.Red : BlockColor.Yellow); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static CrumbleBlock FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); int width = node.AttrInt("width", 0); string texture = node.Attr("texture", "default"); CrumbleBlock entity = new CrumbleBlock(texture, width); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static NPC FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); string name = node.Attr("npc"); NPC entity = new NPC(name); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static SwitchGate FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); string texture = node.Attr("sprite", "block"); int width = node.AttrInt("width", 0); int height = node.AttrInt("height", 0); SwitchGate entity = new SwitchGate(width, height, texture); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static Bonfire FromElement(MapElement node) { int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); string mode = node.Attr("mode", "unlit"); if (!Enum.TryParse <Fire>(mode, true, out Fire fireType)) { return(null); } Bonfire entity = new Bonfire(fireType); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); }
public static Spikes FromElement(MapElement node) { string direction = node.Name.Substring(6); if (!Enum.TryParse <Direction>(direction, true, out Direction spikeDir)) { return(null); } string type = node.Attr("type", "default"); int size = spikeDir == Direction.Up || spikeDir == Direction.Down ? node.AttrInt("width", 0) : node.AttrInt("height", 0); if (size > 0) { Spikes entity = new Spikes(spikeDir, type, size); int x = node.AttrInt("x", 0); int y = node.AttrInt("y", 0); entity.Position = new Vector2(x, y); entity.ID = node.AttrInt("id", 0); return(entity); } return(null); }
private static Backdrop ParseBackdrop(List <MapElement> levels, MapElement child, MapElement above) { Backdrop backdrop; if (child.Name.Equals("parallax", StringComparison.OrdinalIgnoreCase)) { string id = child.Attr("texture", ""); string a = child.Attr("atlas", "game"); Bitmap texture = null; if (a == "game") { texture = Gameplay.GetImage(id); } Parallax parallax = new Parallax(texture); backdrop = parallax; backdrop.Name = id; string text = ""; if (child.HasAttr("blendmode")) { text = child.Attr("blendmode", "alphablend").ToLower(); } else if (above != null && above.HasAttr("blendmode")) { text = above.Attr("blendmode", "alphablend").ToLower(); } if (text.Equals("additive")) { parallax.BlendState = BlendState.Additive; } } else if (child.Name.Equals("snowfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new Snow(true); } else if (child.Name.Equals("snowbg", StringComparison.OrdinalIgnoreCase)) { backdrop = new Snow(false); } else if (child.Name.Equals("windsnow", StringComparison.OrdinalIgnoreCase)) { backdrop = new WindSnowFG(); } else if (child.Name.Equals("dreamstars", StringComparison.OrdinalIgnoreCase)) { backdrop = new DreamStars(); } else if (child.Name.Equals("stars", StringComparison.OrdinalIgnoreCase)) { backdrop = new StarsBG(); } else if (child.Name.Equals("mirrorfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new MirrorFG(); } else if (child.Name.Equals("reflectionfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new ReflectionFG(); } else if (child.Name.Equals("godrays", StringComparison.OrdinalIgnoreCase)) { backdrop = new Godrays(); } else if (child.Name.Equals("tentacles", StringComparison.OrdinalIgnoreCase)) { backdrop = new Tentacles((Tentacles.Side)Enum.Parse(typeof(Tentacles.Side), child.Attr("side", "Right")), Util.HexToColor(child.Attr("color", "")), child.AttrFloat("offset", 0f)); } else if (child.Name.Equals("northernlights", StringComparison.OrdinalIgnoreCase)) { backdrop = new NorthernLights(); } else if (child.Name.Equals("bossStarField", StringComparison.OrdinalIgnoreCase)) { backdrop = new FinalBossStarfield(); } else if (child.Name.Equals("petals", StringComparison.OrdinalIgnoreCase)) { backdrop = new Petals(); } else if (child.Name.Equals("heatwave", StringComparison.OrdinalIgnoreCase)) { backdrop = new HeatWave(); } else if (child.Name.Equals("corestarsfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new CoreStarsFG(); } else { return(null); } if (child.HasAttr("x")) { backdrop.Position.X = child.AttrFloat("x", 0f); } else if (above != null && above.HasAttr("x")) { backdrop.Position.X = above.AttrFloat("x", 0f); } if (child.HasAttr("y")) { backdrop.Position.Y = child.AttrFloat("y", 0f); } else if (above != null && above.HasAttr("y")) { backdrop.Position.Y = above.AttrFloat("y", 0f); } if (child.HasAttr("scrollx")) { backdrop.Scroll.X = child.AttrFloat("scrollx", 0f); } else if (above != null && above.HasAttr("scrollx")) { backdrop.Scroll.X = above.AttrFloat("scrollx", 0f); } if (child.HasAttr("scrolly")) { backdrop.Scroll.Y = child.AttrFloat("scrolly", 0f); } else if (above != null && above.HasAttr("scrolly")) { backdrop.Scroll.Y = above.AttrFloat("scrolly", 0f); } if (child.HasAttr("speedx")) { backdrop.Speed.X = child.AttrFloat("speedx", 0f); } else if (above != null && above.HasAttr("speedx")) { backdrop.Speed.X = above.AttrFloat("speedx", 0f); } if (child.HasAttr("speedy")) { backdrop.Speed.Y = child.AttrFloat("speedy", 0f); } else if (above != null && above.HasAttr("speedy")) { backdrop.Speed.Y = above.AttrFloat("speedy", 0f); } backdrop.Color = Color.White; if (child.HasAttr("color")) { backdrop.Color = Util.HexToColor(child.Attr("color", "")); } else if (above != null && above.HasAttr("color")) { backdrop.Color = Util.HexToColor(above.Attr("color", "")); } if (child.HasAttr("alpha")) { backdrop.Color = Color.FromArgb((int)(child.AttrFloat("alpha", 0f) * 255), backdrop.Color); } else if (above != null && above.HasAttr("alpha")) { backdrop.Color = Color.FromArgb((int)(above.AttrFloat("alpha", 0f) * 255), backdrop.Color); } if (child.HasAttr("flipx")) { backdrop.FlipX = child.AttrBool("flipx", false); } else if (above != null && above.HasAttr("flipx")) { backdrop.FlipX = above.AttrBool("flipx", false); } if (child.HasAttr("flipy")) { backdrop.FlipY = child.AttrBool("flipy", false); } else if (above != null && above.HasAttr("flipy")) { backdrop.FlipY = above.AttrBool("flipy", false); } if (child.HasAttr("loopx")) { backdrop.LoopX = child.AttrBool("loopx", false); } else if (above != null && above.HasAttr("loopx")) { backdrop.LoopX = above.AttrBool("loopx", false); } if (child.HasAttr("loopy")) { backdrop.LoopY = child.AttrBool("loopy", false); } else if (above != null && above.HasAttr("loopy")) { backdrop.LoopY = above.AttrBool("loopy", false); } string text2 = null; if (child.HasAttr("exclude")) { text2 = child.Attr("exclude", ""); } else if (above != null && above.HasAttr("exclude")) { text2 = above.Attr("exclude", ""); } if (text2 != null) { backdrop.ExcludeFrom = ParseLevelsList(levels, text2); } string text3 = null; if (child.HasAttr("only")) { text3 = child.Attr("only", ""); } else if (above != null && above.HasAttr("only")) { text3 = above.Attr("only", ""); } if (text3 != null) { backdrop.OnlyIn = ParseLevelsList(levels, text3); } string text4 = null; if (child.HasAttr("flag")) { text4 = child.Attr("flag", ""); } else if (above != null && above.HasAttr("flag")) { text4 = above.Attr("flag", ""); } if (text4 != null) { backdrop.OnlyIfFlag = text4; } string text5 = null; if (child.HasAttr("notflag")) { text5 = child.Attr("notflag", ""); } else if (above != null && above.HasAttr("notflag")) { text5 = above.Attr("notflag", ""); } if (text5 != null) { backdrop.OnlyIfNotFlag = text5; } string text6 = null; if (child.HasAttr("always")) { text6 = child.Attr("always", ""); } else if (above != null && above.HasAttr("always")) { text6 = above.Attr("always", ""); } if (text6 != null) { backdrop.AlsoIfFlag = text6; } bool?dreaming = null; if (child.HasAttr("dreaming")) { dreaming = new bool?(child.AttrBool("dreaming", false)); } else if (above != null && above.HasAttr("dreaming")) { dreaming = new bool?(above.AttrBool("dreaming", false)); } if (dreaming != null) { backdrop.Dreaming = dreaming; } if (child.HasAttr("instantIn")) { backdrop.InstantIn = child.AttrBool("instantIn", false); } else if (above != null && above.HasAttr("instantIn")) { backdrop.InstantIn = above.AttrBool("instantIn", false); } if (child.HasAttr("instantOut")) { backdrop.InstantOut = child.AttrBool("instantOut", false); } else if (above != null && above.HasAttr("instantOut")) { backdrop.InstantOut = above.AttrBool("instantOut", false); } string text7 = null; if (child.HasAttr("fadex")) { text7 = child.Attr("fadex", ""); } else if (above != null && above.HasAttr("fadex")) { text7 = above.Attr("fadex", ""); } if (text7 != null) { backdrop.FadeX = new Fader(); string[] array = text7.Split(':'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(','); if (array2.Length == 2) { string[] array3 = array2[0].Split('-'); string[] array4 = array2[1].Split('-'); float fadeFrom = float.Parse(array4[0], CultureInfo.InvariantCulture); float fadeTo = float.Parse(array4[1], CultureInfo.InvariantCulture); int num = 1; int num2 = 1; if (array3[0][0] == 'n') { num = -1; array3[0] = array3[0].Substring(1); } if (array3[1][0] == 'n') { num2 = -1; array3[1] = array3[1].Substring(1); } backdrop.FadeX.Add((float)(num * int.Parse(array3[0])), (float)(num2 * int.Parse(array3[1])), fadeFrom, fadeTo); } } } string text8 = null; if (child.HasAttr("fadey")) { text8 = child.Attr("fadey", ""); } else if (above != null && above.HasAttr("fadey")) { text8 = above.Attr("fadey", ""); } if (text8 != null) { backdrop.FadeY = new Fader(); string[] array = text8.Split(':'); for (int i = 0; i < array.Length; i++) { string[] array5 = array[i].Split(','); if (array5.Length == 2) { string[] array6 = array5[0].Split('-'); string[] array7 = array5[1].Split('-'); float fadeFrom2 = float.Parse(array7[0], CultureInfo.InvariantCulture); float fadeTo2 = float.Parse(array7[1], CultureInfo.InvariantCulture); int num3 = 1; int num4 = 1; if (array6[0][0] == 'n') { num3 = -1; array6[0] = array6[0].Substring(1); } if (array6[1][0] == 'n') { num4 = -1; array6[1] = array6[1].Substring(1); } backdrop.FadeY.Add((float)(num3 * int.Parse(array6[0])), (float)(num4 * int.Parse(array6[1])), fadeFrom2, fadeTo2); } } } return(backdrop); }