private static Point3D16 GetDefaultDirection(OtherCubeMode mode) { switch (mode) { case OtherCubeMode.MoveAway: return(new Point3D16(0, -1, 0)); case OtherCubeMode.Hole: return(new Point3D16(0, 0, 1)); default: return(default(Point3D16)); } }
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); }