Example #1
0
        public void Add(ClientThing Thing, bool Push = false)
        {
            if (Thing is ClientItem)
            {
                if (((ClientItem)Thing).Type.IsGround)
                {
                    Ground = (ClientItem)Thing;
                    return;
                }
            }

            if (Objects.Count >= 10)
                Objects.Remove(GetByIndex(9));

            int index = 0;
            for (index = 0; index < Objects.Count; ++index)
            {
                if (Push)
                {
                    if (Objects[index].Order >= Thing.Order)
                        break;
                }
                else if (Objects[index].Order > Thing.Order)
                    break;
            }
            Objects.Insert(index, Thing);
        }
Example #2
0
 public bool Remove(ClientThing Thing)
 {
     if (Thing == Ground)
     {
         Ground = null;
         return(true);
     }
     return(Objects.Remove(Thing));
 }
Example #3
0
 public void Replace(int index, ClientThing NewThing)
 {
     if (index == 0)
     {
         Ground = (ClientItem)NewThing;
     }
     else
     {
         Objects[index - 1] = NewThing;
     }
 }
Example #4
0
        private void OnContainerTransformItem(Packet props)
        {
            int             ContainerID = (int)props["ContainerID"];
            ClientContainer Container   = Containers[ContainerID];
            int             slot        = (int)props["Slot"];
            ClientItem      item        = (ClientItem)props["Item"];

            Container.Contents[slot] = item;

            // Dispatch an event
            if (UpdateContainer != null)
            {
                UpdateContainer(this, Container);
            }
        }
Example #5
0
        private void OnContainerAddItem(Packet props)
        {
            int             ContainerID = (int)props["ContainerID"];
            ClientContainer Container   = Containers[ContainerID];
            ClientItem      item        = (ClientItem)props["Item"];

            // Items are always added on index 0
            Container.Contents.Insert(0, item);

            // Dispatch an event
            if (UpdateContainer != null)
            {
                UpdateContainer(this, Container);
            }
        }
Example #6
0
        public void DrawInventoryItem(SpriteBatch Batch, ClientItem Item, Rectangle rect)
        {
            if (Item.Sprite == null)
            {
                return;
            }

            DrawSprite(Batch, UIContext.GameTime, null, Item.Sprite, Item.Subtype, 0, new Vector2(rect.X, rect.Y), Color.White);

            if (Item.Type.IsStackable)
            {
                String  count    = Item.Subtype.ToString();
                Vector2 textSize = UIContext.StandardFont.MeasureString(count);
                DrawBoldedText(Batch, count, new Vector2(rect.X + 32 - textSize.X - 1, rect.Y + 32 - textSize.Y + 1), false, Color.LightGray);
            }
        }
Example #7
0
        public void DrawTile(SpriteBatch Batch, GameTime Time, Vector2 Position, ClientTile Tile, TileAnimations Animations)
        {
            if (Tile == null)
            {
                return;
            }

            // Draw ground
            if (Tile.Ground != null)
            {
                DrawSprite(Batch, Time, Tile, Tile.Ground.Sprite, Tile.Ground.Subtype, -1, ref Position, Color.White);
            }

            foreach (ClientThing Thing in Tile.ObjectsByDrawOrder)
            {
                if (Thing is ClientCreature)
                {
                    DrawCreature(Batch, Time, (ClientCreature)Thing, Position, Color.White);
                }
                else
                {
                    ClientItem Item = (ClientItem)Thing;
                    DrawSprite(Batch, Time, Tile, Item.Sprite, Item.Subtype, -1, ref Position, Color.White);
                }
            }

            if (Animations != null)
            {
                foreach (GameEffect Effect in Animations.Effects)
                {
                    if (!Effect.Expired)
                    {
                        if (Effect is MagicEffect)
                        {
                            MagicEffect Magic = (MagicEffect)Effect;
                            DrawSprite(Batch, Time, Tile, Magic.Sprite, -1, Magic.Frame, Position, Color.White);
                        }
                        else if (Effect is DistanceEffect)
                        {
                            DistanceEffect Distance = (DistanceEffect)Effect;
                            DrawSprite(Batch, Time, Tile, Distance.Sprite, Distance.Frame, 0, Position + Distance.Offset, Color.White);
                        }
                    }
                }
            }
        }
Example #8
0
        public ItemButton(GameRenderer Renderer, ClientItem Item)
        {
            this.Item = Item;
            this.Renderer = Renderer;
            this.Padding = new Margin
            {
                Top = -1,
                Right = 1,
                Bottom = 1,
                Left = -1
            };

            Bounds.Width = 34;
            Bounds.Height = 34;

            NormalType = UIElementType.InventorySlot;
            HighlightType = UIElementType.InventorySlot;
        }
Example #9
0
        public ItemButton(GameRenderer Renderer, ClientItem Item)
        {
            this.Item     = Item;
            this.Renderer = Renderer;
            this.Padding  = new Margin
            {
                Top    = -1,
                Right  = 1,
                Bottom = 1,
                Left   = -1
            };

            Bounds.Width  = 34;
            Bounds.Height = 34;

            NormalType    = UIElementType.InventorySlot;
            HighlightType = UIElementType.InventorySlot;
        }
Example #10
0
 public void Replace(int index, ClientThing NewThing)
 {
     if (index == 0)
         Ground = (ClientItem)NewThing;
     else
         Objects[index - 1] = NewThing;
 }
Example #11
0
 public bool Remove(ClientThing Thing)
 {
     if (Thing == Ground)
     {
         Ground = null;
         return true;
     }
     return Objects.Remove(Thing);
 }
        public void DrawInventoryItem(SpriteBatch Batch, ClientItem Item, Rectangle rect)
        {
            if (Item.Sprite == null)
                return;

            DrawSprite(Batch, UIContext.GameTime, null, Item.Sprite, Item.Subtype, 0, new Vector2(rect.X, rect.Y), Color.White);

            if (Item.Type.IsStackable)
            {
                String count = Item.Subtype.ToString();
                Vector2 textSize = UIContext.StandardFont.MeasureString(count);
                DrawBoldedText(Batch, count, new Vector2(rect.X + 32 - textSize.X - 1, rect.Y + 32 - textSize.Y + 1), false, Color.LightGray);
            }
        }