Пример #1
0
 public NormalID(IDReference reference)
 {
     if (reference.IsName)
     {
         Name = reference.Name;
     }
     else
     {
         Index = reference.Index;
     }
 }
Пример #2
0
        public OtherCube(Level parent, BinaryReader reader)
        {
            PositionTrigger = new Point3D16(reader);
            MovingBlockSync = new IDReference <MovingPlatform>(parent.MovingPlatforms, reader.ReadInt16());
            if (MovingBlockSync.Index == -2)
            {
                DarkCubeRadius          = new Point2D8(reader);
                DarkCubeMovingBlockSync = new IDReference <MovingPlatform>(parent.MovingPlatforms, reader.ReadInt16());
            }
            var count = reader.ReadUInt16();

            PositionCube = new Point3D16(reader);
            for (var i = 0; i < count; i++)
            {
                KeyEvents.Add(new KeyEvent(reader));
            }
        }
Пример #3
0
 public Button(Buttons parent, BinaryReader reader) : this(parent)
 {
     Visible         = (NullableBoolean)reader.ReadByte();
     DisableCount    = reader.ReadByte();
     Mode            = (ButtonMode)reader.ReadByte();
     ParentID        = reader.ReadInt16();
     SequenceInOrder = reader.ReadBoolean();
     reader.ReadByte();  // Siblings count is useless at this point
     if (IsMoving = reader.ReadBoolean())
     {
         MovingPlatformID = new IDReference <MovingPlatform>(parent.Parent.MovingPlatforms, reader.ReadInt16());
     }
     else
     {
         Position = new Point3D16(reader);
     }
     var count = reader.ReadUInt16();
     for (var i = 0; i < count; i++)
     {
         Events.Add(reader.ReadUInt16());
     }
     CheckChild();
 }
Пример #4
0
        public OtherCube(Level parent, XElement element)
        {
            element.GetAttributeValue(out PositionTrigger, "PositionTrigger");
            var id   = element.GetAttributeValue("MovingBlockSync");
            var sync = id == null ? new IDReference <MovingPlatform>(parent.MovingPlatforms, -1)
                                  : new IDReference <MovingPlatform>(parent.MovingPlatforms, id);

            element.GetAttributeValueWithDefault(out DarkCubeRadius, "Radius");
            element.GetAttributeValue(out PositionCube, "PositionCube");
            foreach (var e in element.Elements())
            {
                try
                {
                    KeyEvents.Add(new KeyEvent(e));
                }
                catch
                {
                    if (!e.Name.LocalName.Equals("MovingPlatform", StringComparison.InvariantCultureIgnoreCase) &&
                        !e.Name.LocalName.Equals("Button", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Warning.WriteLine(string.Format(Localization.UnrecognizedChildElement, e.Name, element.Name));
                    }
                }
            }
            if (element.Name == "OtherCube")
            {
                MovingBlockSync = sync;
                var mode          = element.GetAttributeValueWithDefault("Mode", OtherCubeMode.AutoHide);
                var moveDirection = element.GetAttributeValueWithDefault("MoveDirection", GetDefaultDirection(mode));
                if (mode == OtherCubeMode.Hole)
                {
                    PositionTrigger -= moveDirection;
                }
                AddHelper(parent, mode, PositionTrigger, moveDirection, element);
                if (DarkCubeRadius.Equals(default(Point2D8)))
                {
                    return;
                }
                var radius = DarkCubeRadius;
                DarkCubeRadius = default(Point2D8);
                for (var x = -radius.X; x <= radius.X; x++)
                {
                    for (var y = -radius.Y; y <= radius.Y; y++)
                    {
                        if (x != 0 || y != 0)
                        {
                            var position = PositionTrigger + new Point3D16((short)x, (short)y, 0);
                            parent.OtherCubes.Add(new OtherCube
                            {
                                PositionTrigger = position,
                                MovingBlockSync = MovingBlockSync,
                                PositionCube    = PositionCube,
                                KeyEvents       = KeyEvents
                            });
                            AddHelper(parent, mode, position, moveDirection, element);
                        }
                    }
                }
            }
            else
            {
                MovingBlockSync         = new IDReference <MovingPlatform>(parent.MovingPlatforms, -2);
                DarkCubeMovingBlockSync = sync;
            }
        }