Example #1
0
        private void CreateItem(IList<string> tokens)
        {
            var item = new InventoryItem {Character = Character, ItemId = int.Parse(tokens[1]), StackSize = int.Parse(tokens[2])};

            InventoryItems.Add(item);

            //TODO: Check if inventory is full.

            var snapshot = new Snapshot();
            snapshot.SetType(SnapshotType.CREATEITEM);

            snapshot.WriteInt32(Character.GetHashCode()); //TODO: Change to generated id.
            snapshot.WriteByte(0); //Bag Id
            item.Serialize(snapshot);
            snapshot.WriteByte(1); //Item Count
            snapshot.WriteByte(item.Slot); //Item Slot
            snapshot.WriteInt16((short) item.StackSize); //Item Stack Size

            Send(snapshot);
        }
Example #2
0
 /// <summary>
 /// Create a new InventoryItem object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="itemId">Initial value of the ItemId property.</param>
 /// <param name="slot">Initial value of the Slot property.</param>
 /// <param name="characterId">Initial value of the CharacterId property.</param>
 public static InventoryItem CreateInventoryItem(global::System.Int32 id, global::System.Int32 itemId, global::System.Byte slot, global::System.Int32 characterId)
 {
     InventoryItem inventoryItem = new InventoryItem();
     inventoryItem.Id = id;
     inventoryItem.ItemId = itemId;
     inventoryItem.Slot = slot;
     inventoryItem.CharacterId = characterId;
     return inventoryItem;
 }