Example #1
0
        public MapObject(DungeonObjectId id, Vector3 initialPosition, Vector2 size, bool onFloor)
        {
            _sprite = AttachChild(new MapSprite <DungeonObjectId>(
                                      id,
                                      DrawLayer.Underlay,
                                      SpriteKeyFlags.UseCylindrical,
                                      SpriteFlags.FlipVertical |
                                      (onFloor
                    ? SpriteFlags.Floor | SpriteFlags.MidAligned
                    : SpriteFlags.Billboard))
            {
                Size     = size,
                Position = initialPosition
            });
            _sprite.Selected += (sender, args) => args.RegisterHit(this);

            On <SlowClockEvent>(e =>
            {
                if (_sprite.FrameCount == 1)
                {
                    Exchange.Unsubscribe <SlowClockEvent>(this);
                }
                _sprite.Frame += e.Delta;
            });
        }
Example #2
0
        public LargeNpc(MapNpc npc)
        {
            On <SlowClockEvent>(e => { _sprite.Frame = e.FrameCount; });
            On <ShowMapMenuEvent>(OnRightClick);

            _npc              = npc ?? throw new ArgumentNullException(nameof(npc));
            _sprite           = AttachChild(new MapSprite <LargeNpcId>((LargeNpcId)_npc.ObjectNumber, DrawLayer.Underlay - 1, 0, SpriteFlags.BottomAligned));
            _sprite.Selected += (sender, e) => { e.RegisterHit(this); e.Handled = true; };
        }
Example #3
0
        public SmallNpc(MapNpc npc)
        {
            On <SlowClockEvent>(e => { _sprite.Frame = e.FrameCount; });
            On <ShowMapMenuEvent>(OnRightClick);

            _npc              = npc ?? throw new ArgumentNullException(nameof(npc));
            _sprite           = AttachChild(new MapSprite(npc.SpriteOrGroup, DrawLayer.Underlay - 1, 0, SpriteFlags.BottomAligned));
            _sprite.Selected += (sender, e) => e.RegisterHit(this);
        }
Example #4
0
 public MapObject(DungeonObjectId id, Vector3 initialPosition, Vector2 size, bool onFloor) : base(Handlers)
 {
     _initialPosition = initialPosition;
     _sprite          = new MapSprite <DungeonObjectId>(id, DrawLayer.Underlay, 0,
                                                        SpriteFlags.FlipVertical |
                                                        (onFloor
             ? SpriteFlags.Floor | SpriteFlags.MidAligned
             : SpriteFlags.Billboard));
     _sprite.Size = size;
     Children.Add(_sprite);
 }
Example #5
0
        public MapObject(SpriteId id, Vector3 initialPosition, Vector2 size, bool onFloor, bool backAndForth)
        {
            _sprite = AttachChild(new MapSprite(
                                      id,
                                      DrawLayer.Underlay,
                                      0,
                                      SpriteFlags.FlipVertical |
                                      (onFloor
                    ? SpriteFlags.Floor | SpriteFlags.MidAligned
                    : SpriteFlags.Billboard))
            {
                Size     = size,
                Position = initialPosition
            });
            _sprite.Selected += (_, args) => args.RegisterHit(this);

            On <SlowClockEvent>(e =>
            {
                if (_sprite.FrameCount == 1)
                {
                    Exchange.Unsubscribe <SlowClockEvent>(this);
                }

                _frame += e.Delta;
                if (backAndForth && _sprite.FrameCount > 2)
                {
                    int maxFrame  = _sprite.FrameCount - 1;
                    int frame     = _frame % (2 * maxFrame) - maxFrame;
                    _sprite.Frame = Math.Abs(frame);
                }
                else
                {
                    _sprite.Frame = _frame;
                }
            });
        }
Example #6
0
 public SmallNpc(SmallNpcId id, MapNpc.Waypoint[] waypoints) : base(Handlers)
 {
     _waypoints = waypoints;
     _sprite    = new MapSprite <SmallNpcId>(id, DrawLayer.Characters1, 0, SpriteFlags.BottomAligned);
     Children.Add(_sprite);
 }