/// <summary> /// Transfer item from stack to this slot and set the item in this slot. Update the ui. /// </summary> public void SetItemFromStack(InventoryController.Stack stack, int nbItem) { _stack._item = stack._item; _stack._nbItem = nbItem; stack._nbItem -= nbItem; AddingItemEvent.Invoke(); UpdateSlot(); }
/// <summary> /// Transfer item from slot to stack. Update the slot in ui. /// </summary> /// <param name="stack">stack where the item are transfered</param> /// <param name="nbItem">nb item to transfer</param> public void TransferItemToStack(InventoryController.Stack stack, int nbItem) { stack._item = _stack._item; stack._nbItem = nbItem; _stack._nbItem -= nbItem; try{ RemovingItemEvent.Invoke(); } catch (System.NullReferenceException) { }; UpdateSlot(); }
/// <summary> /// Swap stack content with the stack from this slot. Update the ui. /// </summary> /// <param name="stack">stack to swap with</param> public void SwapStack(InventoryController.Stack stack) { Item item = _stack._item; int nbItem = _stack._nbItem; _stack._item = stack._item; _stack._nbItem = stack._nbItem; stack._item = item; stack._nbItem = nbItem; try{ AddingItemEvent.Invoke(); } catch (System.NullReferenceException) { }; UpdateSlot(); }
/// <summary> /// Transfer item from stack to this slot. Update the slot in ui. /// </summary> /// <param name="stack">stack from where the item are taken</param> /// <param name="nbItem">nb item to transfer</param> public void TransferItemFromStack(InventoryController.Stack stack, int nbItem) { if (_stack._nbItem + nbItem > InventoryController.MAX_ITEM_PER_STACK) { int rest = _stack._nbItem + nbItem - InventoryController.MAX_ITEM_PER_STACK; _stack._nbItem = InventoryController.MAX_ITEM_PER_STACK; stack._nbItem = rest; } else { _stack._nbItem += nbItem; stack._nbItem -= nbItem; } try { AddingItemEvent.Invoke(); } catch (System.NullReferenceException) { }; UpdateSlot(); }