Exemple #1
0
        public static XElement GetElement(this XContainer container, XName name)
        {
            var r = container.ElementCaseInsensitive(name);

            if (r == null)
            {
                throw new FormatException();
            }
            return(r);
        }
Exemple #2
0
 public MappingLevels(XContainer container, string levelsDir = null)
 {
     this.levelsDir = levelsDir;
     foreach (var type in new[] { LevelType.Standard, LevelType.Bonus, LevelType.Extended })
     {
         var levels = container.ElementCaseInsensitive(type.ToString());
         var index  = 0;
         if (levels != null)
         {
             foreach (var level in levels.ElementsCaseInsensitive("level"))
             {
                 Add(new MappingLevel(type, ++index, level));
             }
         }
     }
 }
Exemple #3
0
        private static void AddHelper(Level level, OtherCubeMode mode, Point3D16 position, Point3D16 moveDirection,
                                      XContainer container)
        {
            if (mode == OtherCubeMode.AutoHide)
            {
                return;
            }
            var child = container.ElementCaseInsensitive("Button");

            if (child == null)
            {
                level.Buttons.Add(new Button(level.Buttons)
                {
                    Position = position,
                    Visible  = NullableBoolean.False,
                    Events   = new List <ushort> {
                        (ushort)level.Buttons.BlockEvents.Count
                    }
                });
            }
            else
            {
                var button = new Button(level.Buttons, child)
                {
                    Position = child.GetAttributeValueWithDefault("Position", position),
                    Visible  = child.GetAttributeValueWithDefault("Visible", NullableBoolean.False)
                };
                button.Events.Add((ushort)level.Buttons.BlockEvents.Count);
            }
            level.Buttons.BlockEvents.Add(new BlockEvent(level)
            {
                ID = new IDReference((short)level.MovingPlatforms.Count), Type = BlockEventType.AffectMovingPlatform
            });
            child = container.ElementCaseInsensitive("MovingPlatform");
            MovingPlatform platform;

            if (child == null)
            {
                platform = new MovingPlatform(level.MovingPlatforms)
                {
                    AutoStart = false, LoopStartIndex = 0
                }
            }
            ;
            else
            {
                platform = new MovingPlatform(level.MovingPlatforms, child)
                {
                    AutoStart      = child.GetAttributeValueWithDefault <bool>("AutoStart"),
                    LoopStartIndex = child.GetAttributeValueWithDefault <byte>("LoopStartIndex")
                };
            }
            if (platform.Waypoints.Count == 0)
            {
                platform.Waypoints.Add(new Waypoint {
                    Position = position
                });
                platform.Waypoints.Add(new Waypoint
                {
                    Position   = position + moveDirection,
                    TravelTime = (ushort)(mode == OtherCubeMode.Hole ? 1 : 32000)
                });
            }
            level.MovingPlatforms.Add(platform);
        }