private Level(string path) : this() { var element = XHelper.Load(path + ".xml").GetElement("Level"); ID = element.GetAttributeValue <int>("ID"); Name = element.GetAttributeValueWithDefault("Name", string.Empty); var thresholds = element.GetAttributeValueWithDefault("TimeThresholds", "1,2,3,4,5").Split(',') .Select(str => ushort.Parse(str.Trim())).ToArray(); SPlusTime = thresholds[0]; STime = thresholds[1]; ATime = thresholds[2]; BTime = thresholds[3]; CTime = thresholds[4]; CheckTime(); Size = element.GetAttributeValue <Size3D>("Size"); LegacyMinimap = new Flat(path + ".png", LegacyMinimapSize); CollisionMap = new Cube(path + ".{0}.png", Size); SpawnPoint = element.GetAttributeValue <Point3D16>("SpawnPoint"); ExitPoint = element.GetAttributeValue <Point3D16>("ExitPoint"); Theme = element.GetAttributeValueWithDefault <byte>("Theme"); ModelTheme = element.GetAttributeValueWithDefault("ModelTheme", Theme); MusicJava = element.GetAttributeValueWithDefault <byte>("MusicJava"); Music = element.GetAttributeValueWithDefault("Music", (byte)6); Zoom = element.GetAttributeValueWithDefault("Zoom", (short)-1); var advanced = true; if (ValueIsAngle = element.AttributeCaseInsensitive("Angle") != null) { Value = element.GetAttributeValueWithDefault <short>("Angle", 22); if (element.AttributeCaseInsensitive("FieldOfView") != null) { Warning.WriteLine(string.Format(Localization.FieldOfViewIgnored, "Level")); } } else if (element.AttributeCaseInsensitive("FieldOfView") != null) { Value = element.GetAttributeValueWithDefault <short>("FieldOfView", 22); } else if (Zoom < 0) { Value = 22; } else { advanced = false; } if (Zoom >= 0 && advanced) { Warning.WriteLine(string.Format(Localization.AdvancedCameraModeDisabled, "Level", "@Angle, @FieldOfView")); } Buttons = new Buttons(this); foreach (var e in element.Elements()) { switch (e.Name.LocalName.ToLower()) { case "movingplatform": MovingPlatforms.Add(new MovingPlatform(MovingPlatforms, e)); break; case "bumper": Bumpers.Add(new Bumper(Bumpers, e)); break; case "fallingplatform": FallingPlatforms.Add(new FallingPlatform(this, e)); break; case "checkpoint": Checkpoints.Add(new Checkpoint(e)); break; case "cameratrigger": CameraTriggers.Add(new CameraTrigger(e)); break; case "prism": Prisms.Add(new Prism(e)); break; case "fan": Fans.Add(new Fan(e)); Warning.WriteLine(string.Format(Localization.DeprecatedElement, "Fan")); break; case "button": case "buttonsequence": // ReSharper disable once ObjectCreationAsStatement new Button(Buttons, e); break; case "othercube": case "darkcube": OtherCubes.Add(new OtherCube(this, e)); break; case "resizergrow": case "resizershrink": Resizers.Add(new Resizer(this, e)); break; case "miniblock": MiniBlocks.Add(new MiniBlock(e)); Warning.WriteLine(string.Format(Localization.DeprecatedElement, "MiniBlock")); break; default: Warning.WriteLine(string.Format(Localization.UnrecognizedChildElement, e.Name, "Level")); break; } } }