Example #1
0
 /// <summary>
 /// 存入
 /// </summary>
 public void store(TezComData item, int count)
 {
     m_Inventory.store(this.index, item, count);
 }
Example #2
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);
                    }
                }
            }
        }