Example #1
0
        public virtual bool CheckItem(HolderObject item)
        {
            int amount = 0;

            for (int i = 0; i < MaxSlots; i++)
            {
                if (Slots[i] != null && Slots[i].Item.GetType() == item.Item.GetType())
                {
                    amount += Slots[i].Amount;
                }
            }

            return(amount >= item.Amount);
        }
Example #2
0
        //public void AddToQuick(HolderObject item)
        //{
        //    AddItem(item, QuickSlots, WorldConsts.QuickSlotsAmount);
        //    _simpleEvents.Call(INVENTORY_ADD_QUICK_SLOT_ITEM, item);
        //}

        public override bool AddItem(HolderObject item)
        {
            if (AddItem(item, Slots, MaxSlots))
            {
                _simpleEvents.Call(INVENTORY_ADD_ITEM, item);
                return(true);
            }

            if (AddItem(item, QuickSlots, WorldConsts.QuickSlotsAmount))
            {
                _simpleEvents.Call(INVENTORY_ADD_QUICK_SLOT_ITEM, item);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public override bool CheckItem(HolderObject item)
        {
            int amount = 0;

            for (int i = 0; i < MaxSlots; i++)
            {
                if (Slots[i] != null && Slots[i].Item.GetType() == item.Item.GetType())
                {
                    amount += Slots[i].Amount;
                }
            }
            for (int i = 0; i < WorldConsts.QuickSlotsAmount; i++)
            {
                if (QuickSlots[i] != null && QuickSlots[i].Item.GetType() == item.Item.GetType())
                {
                    amount += QuickSlots[i].Amount;
                }
            }

            return(amount >= item.Amount);
        }
Example #4
0
        public override void RemoveItem(HolderObject item, int?changeAmount = null)
        {
            int amount = changeAmount ?? item.Amount;

            for (int i = 0; i < MaxSlots; i++)
            {
                if (Slots[i] != null && item != null && item.Item != null && Slots[i].Item.GetType() == item.Item.GetType() && amount > 0)
                {
                    amount = Slots[i].ChangeAmount(amount);
                    _simpleEvents.Call(INVENTORY_ADD_ITEM, item);
                }
            }
            for (int i = 0; i < WorldConsts.QuickSlotsAmount; i++)
            {
                if (QuickSlots[i] != null && item != null && item.Item != null && QuickSlots[i].Item.GetType() == item.Item.GetType() && amount > 0)
                {
                    amount = QuickSlots[i].ChangeAmount(amount);
                    _simpleEvents.Call(INVENTORY_ADD_QUICK_SLOT_ITEM, item);
                }
            }
        }
Example #5
0
 public void SetItem(UiSlot slot, HolderObject itemModel)
 {
     if (slot.SlotType == SlotType.Inventory)
     {
         Inventory.Slots[slot.SlotId] = itemModel;
     }
     else if (slot.SlotType == SlotType.Quick)
     {
         Inventory.QuickSlots[slot.SlotId] = itemModel;
     }
     else if (slot.SlotType == SlotType.EquipBoots ||
              slot.SlotType == SlotType.EquipCap ||
              slot.SlotType == SlotType.EquipPants ||
              slot.SlotType == SlotType.EquipShirt)
     {
         Inventory.EquipSlots[slot.SlotId] = itemModel;
     }
     else if (slot.SlotType == SlotType.Interactive)
     {
         if (_gameManager.DisplayManager.CurrentInteractPanel != null && _gameManager.DisplayManager.CurrentInteractPanel is InteractView)
         {
             var panel = _gameManager.DisplayManager.CurrentInteractPanel as InteractView;
             panel.SetItem(slot, itemModel);
         }
         if (slot.OnValueChanged != null)
         {
             slot.OnValueChanged(slot);
         }
     }
     else
     {
         if (slot.OnValueChanged != null)
         {
             slot.OnValueChanged(slot);
         }
     }
 }