예제 #1
0
 public static void clearSelect()
 {
     m_SelectedInventory = null;
     for (int i = 0; i < m_SelectedItemList.Count; i++)
     {
         m_SelectedItemList[i].picked = false;
     }
     m_SelectedItemList.Clear();
     eventState?.Invoke(State.EndAdd);
 }
예제 #2
0
        public void setInventory(TezInventory inventory)
        {
            if (m_Inventory != null && m_Inventory.tryGet(out var old_inventory))
            {
                old_inventory.onItemAdded   -= this.onItemAdded;
                old_inventory.onItemRemoved -= this.onItemRemoved;
                m_Inventory.close();
            }

            this.resetSlots();

            m_Inventory              = inventory;
            inventory.onItemAdded   += onItemAdded;
            inventory.onItemRemoved += onItemRemoved;
        }
예제 #3
0
 public override void close()
 {
     base.close();
     this.item   = null;
     m_Inventory = null;
 }
예제 #4
0
 public TezInventoryItemSlot(TezInventory inventory)
 {
     m_Inventory = inventory;
     this.picked = false;
 }
예제 #5
0
        public static void selectSlot(TezInventory inventory, TezInventoryItemSlot itemSlot)
        {
            if (itemSlot.picked)
            {
                return;
            }

            ///没有被选择的Inventory 或者是一样的 就是Pick功能
            if (m_SelectedInventory == null)
            {
                itemSlot.picked     = true;
                m_SelectedInventory = inventory;
                m_SelectedItemList.Add(itemSlot);
                eventState?.Invoke(State.BeginAdd);
            }
            else
            {
                if (m_SelectedInventory == inventory)
                {
                    itemSlot.picked = true;
                    m_SelectedItemList.Add(itemSlot);
                    eventState?.Invoke(State.ContinueAdd);
                }
                else
                {
                    ///只选择了一个
                    if (m_SelectedItemList.Count == 1)
                    {
                        ///如果选择的槽位有item了
                        ///就是交换功能
                        if (itemSlot.item != null)
                        {
                            var count = m_SelectedItemList[0].count;
                            var temp  = m_SelectedItemList[0].take();

                            m_SelectedItemList[0].item  = itemSlot.item;
                            m_SelectedItemList[0].count = itemSlot.count;

                            itemSlot.item  = temp;
                            itemSlot.count = count;

                            eventState?.Invoke(State.ItemSwitch);
                        }
                        ///否则就是存储功能
                        else
                        {
                            var count = m_SelectedItemList[0].count;
                            var item  = m_SelectedItemList[0].take();
                            itemSlot.store(item, count);

                            eventState?.Invoke(State.ContinueAdd);
                        }
                    }
                    ///大量释放就是存储功能
                    else
                    {
                        for (int i = 0; i < m_SelectedItemList.Count; i++)
                        {
                            var count = m_SelectedItemList[i].count;
                            var item  = m_SelectedItemList[i].take();
                            inventory.store(item, count);
                        }

                        eventState?.Invoke(State.ContinueAdd);
                    }
                }
            }
        }
 public virtual void setInventory(TezInventory inventory)
 {
     m_InventoryRef = inventory;
     m_FilterManager.setInventory(inventory);
 }