Ejemplo n.º 1
0
        void Render(RenderEvent e)
        {
            var window = Resolve <IWindowManager>();

            if (window.Size.X < 1 || window.Size.Y < 1)
            {
                return;
            }

            var position = new Vector3(window.PixelToNorm(_position), 0.0f);
            var size     = new Vector2(window.GuiScale, -window.GuiScale) * _size / window.Size;

            e.Add(new Sprite <CoreSpriteId>(_cursorId,
                                            0,
                                            position,
                                            (int)DrawLayer.MaxLayer,
                                            SpriteFlags.NoTransform | SpriteFlags.NoDepthTest,
                                            size));

            if (_cursorId == CoreSpriteId.CursorSmall) // Inventory screen, check what's being held.
            {
                var assets = Resolve <IAssetManager>();
                var state  = Resolve <IGameState>();
                var held   = Resolve <IInventoryScreenState>().ItemInHand;

                if (held is GoldInHand)
                {
                    var spriteId = CoreSpriteId.UiGold;
                    var texture  = assets.LoadTexture(spriteId);
                    texture.GetSubImageDetails(0, out var itemSize, out _, out _, out _);
                    e.Add(BuildItemInHandSprite(spriteId, itemSize, position));
                }
                else if (held is RationsInHand)
                {
                    var spriteId = CoreSpriteId.UiFood;
                    var texture  = assets.LoadTexture(spriteId);
                    texture.GetSubImageDetails(0, out var itemSize, out _, out _, out _);
                    e.Add(BuildItemInHandSprite(spriteId, itemSize, position));
                }
                else if (held is ItemSlot itemInHand)
                {
                    var          item     = assets.LoadItem(itemInHand.Id);
                    ItemSpriteId spriteId = item.Icon + state.TickCount % item.IconAnim;
                    var          texture  = assets.LoadTexture(spriteId);
                    texture.GetSubImageDetails((int)spriteId, out var itemSize, out _, out _, out _);
                    e.Add(new Sprite <ItemSpriteId>(spriteId,
                                                    (int)spriteId,
                                                    position + new Vector3(window.UiToNormRelative(new Vector2(6, 0)), 0),
                                                    (int)DrawLayer.MaxLayer,
                                                    SpriteFlags.NoTransform | SpriteFlags.NoDepthTest,
                                                    window.UiToNormRelative(itemSize)));
                    // TODO: Quantity text
                }
            }
        }
Ejemplo n.º 2
0
 void Render(RenderEvent e)
 {
     if (_renderUnderlay)
     {
         e.Add(_underlay);
     }
     if (_renderOverlay)
     {
         e.Add(_overlay);
     }
 }
Ejemplo n.º 3
0
 void Render(RenderEvent renderEvent)
 {
     lock (_syncRoot)
         foreach (var sprite in _sprites)
         {
             renderEvent.Add(sprite.Value);
         }
 }
Ejemplo n.º 4
0
 void Render(RenderEvent e)
 {
     e.Add(_tilemap); /*
                       * // Split map rendering into one render call per distance group for debugging
                       * int offset = 0;
                       * foreach (var distance in _tilesByDistance.OrderByDescending(x => x.Key))
                       * {
                       * e.Add(new TileMapWindow(_tilemap, offset, distance.Value.Count));
                       * offset += distance.Value.Count;
                       * }
                       * //*/
 }
Ejemplo n.º 5
0
        void Render(RenderEvent e)
        {
            var sprite = new Sprite <T>(
                _id,
                _frame,
                _position,
                (int)DrawLayer.Interface,
                SpriteFlags.NoTransform | SpriteFlags.LeftAligned,
                _size);

            e.Add(sprite);
        }
Ejemplo n.º 6
0
        /*
         * void Select(WorldCoordinateSelectEvent e)
         * {
         *  float denominator = Vector3.Dot(Normal, e.Direction);
         *  if (Math.Abs(denominator) < 0.00001f)
         *      return;
         *
         *  var pixelPosition = _position * _tileSize;
         *  float t = Vector3.Dot(new Vector3(pixelPosition, 0.0f) - e.Origin, Normal) / denominator;
         *  if (t < 0)
         *      return;
         *
         *  var intersectionPoint = e.Origin + t * e.Direction;
         *  int x = (int)(intersectionPoint.X - pixelPosition.X);
         *  int y = (int)(intersectionPoint.Y - pixelPosition.Y);
         *
         *  if (x < 0 || x >= _size.X ||
         *      y < 0 || y >= _size.Y)
         *      return;
         *
         *  e.RegisterHit(t, $"NPC {_id}", this);
         * }//*/

        void Render(RenderEvent e)
        {
            var sprite = new Sprite <DungeonObjectId>(
                _id,
                _frame / TicksPerFrame,
                _position,
                (int)DrawLayer.Underlay,
                SpriteFlags.FlipVertical | (_onFloor ? (SpriteFlags.Floor | SpriteFlags.MidAligned) : SpriteFlags.Billboard),
                _size);

            e.Add(sprite);
        }
Ejemplo n.º 7
0
        protected virtual void Render(RenderEvent e)
        {
            var map             = Resolve <IMapManager>().Current;
            var pixelPosition   = Position * new Vector2(map.TileSize.X, map.TileSize.Y);
            var positionLayered = new Vector3(pixelPosition, DrawLayer.Characters1.ToZCoordinate(Position.Y));

            var npcSprite = new Sprite <TSpriteId>(
                Id,
                Frame,
                positionLayered,
                (int)DrawLayer.Characters1,
                SpriteFlags.BottomAligned);

            e.Add(npcSprite);
        }
Ejemplo n.º 8
0
 void Render(RenderEvent renderEvent)
 {
     renderEvent.Add(_tilemap);
 }