Beispiel #1
0
 public bool BuyItem(SunItem item)
 {
     if (item.ItemSellMoney >= Inventory.Money)
     {
         return(false);
     }
     if (!Inventory.AddItemToInv(item, out var slotInfo))
     {
         return(false);
     }
     Inventory.Money -= item.ItemSellMoney;
     return(true);
 }
Beispiel #2
0
        private bool isItemInInventory(SunItem item, out ItemSlotInfo itemSlot)
        {
            itemSlot = null;
            foreach (var slot in invSlotsInfo)
            {
                if (slot != null && (uint)BitConverter.ToUInt16(slot.itemInfo.code, 0) == item.itemId)
                {
                    itemSlot = slot;
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
        public bool AddItemToInv(SunItem item, out ItemSlotInfo slotInfo, int count = 1)
        {
            slotInfo = null;
            if (isItemInInventory(item, out var slot))
            {
                slot.itemInfo.itemCount++;
                slotInfo = slot;
                return(true);
            }
            var slotNum = FindFreeInvSlot();

            if (slotNum == -1)
            {
                return(false);
            }
            invSlotsInfo[slotNum] = new ItemSlotInfo((byte)slotNum, item, (byte)count);
            slotInfo = invSlotsInfo[slotNum];
            inventoryItemCount++;
            return(true);
        }
Beispiel #4
0
 public ItemInfo(SunItem item, byte itemCount)
 {
     this.code      = BitConverter.GetBytes((ushort)item.itemId);
     this.itemCount = itemCount;
     this.serial    = BitConverter.GetBytes(0); //TODO figure this out
 }
Beispiel #5
0
 public ItemSlotInfo(byte position, SunItem item, byte itemCount = 1)
 {
     this.position       = position;
     this.itemInfo       = new ItemInfo(item, itemCount);
     this.itemOptionInfo = new ItemOptionInfo(item);
 }