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); }
public bool Remove(ClientThing Thing) { if (Thing == Ground) { Ground = null; return(true); } return(Objects.Remove(Thing)); }
public void Replace(int index, ClientThing NewThing) { if (index == 0) { Ground = (ClientItem)NewThing; } else { Objects[index - 1] = NewThing; } }
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); } }
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); } }
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); } }
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); } } } } }
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; }
public void Replace(int index, ClientThing NewThing) { if (index == 0) Ground = (ClientItem)NewThing; else Objects[index - 1] = NewThing; }
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); } }