コード例 #1
0
        private void CategoryAllSend(
            ItemBoxUI.ItemBoxDataPack sender,
            ItemBoxUI.ItemBoxDataPack receiver)
        {
            List <ItemNodeUI> itemNodeUiList = new List <ItemNodeUI>();

            foreach (ItemNodeUI itemVisible in sender.itemListUI.ItemVisibles)
            {
                StuffItem stuffItem = new StuffItem(itemVisible.Item);
                int       count     = stuffItem.Count;
                int       possible;
                if (!((IReadOnlyCollection <StuffItem>)receiver.itemList).CanAddItem(receiver.slotCounter.y, stuffItem, count, out possible))
                {
                    count = possible;
                }
                if (count > 0)
                {
                    if (receiver.itemList.AddItem(stuffItem, count))
                    {
                        receiver.ItemListAddNode(receiver.itemListUI.SearchNotUsedIndex, stuffItem);
                        receiver.ItemListNodeFilter(receiver.categoryUI.CategoryID, true);
                    }
                    itemVisible.Item.Count -= count;
                    if (itemVisible.Item.Count <= 0)
                    {
                        itemVisible.Item.Count = 0;
                        itemNodeUiList.Add(itemVisible);
                    }
                }
            }
            foreach (ItemNodeUI node in itemNodeUiList)
            {
                sender.itemList.Remove(node.Item);
                sender.itemListUI.RemoveItemNode(sender.itemListUI.SearchIndex(node));
            }
            this.SetFocusLevel(sender.itemListUI.FocusLevel);
            sender.itemListUI.ForceSetNonSelect();
            receiver.Refresh();
            sender.Refresh();
            this._itemSendPanel.Refresh();
        }
コード例 #2
0
        private void Send(
            ItemBoxUI.ItemBoxDataPack sender,
            ItemBoxUI.ItemBoxDataPack receiver,
            int count)
        {
            ItemNodeUI node       = sender.itemListUI.GetNode(this._selectedIndexOf);
            StuffItem  stuffItem1 = new StuffItem(node.Item);
            int        possible;

            if (!((IReadOnlyCollection <StuffItem>)receiver.itemList).CanAddItem(receiver.slotCounter.y, stuffItem1, count, out possible))
            {
                count = this.isSendAll ? possible : 0;
            }
            this.isSendAll = false;
            if (count <= 0)
            {
                return;
            }
            if (receiver.itemList.AddItem(stuffItem1, count))
            {
                receiver.ItemListAddNode(receiver.itemListUI.SearchNotUsedIndex, stuffItem1);
                receiver.ItemListNodeFilter(receiver.categoryUI.CategoryID, true);
            }
            node.Item.Count -= count;
            if (node.Item.Count <= 0)
            {
                count = Mathf.Abs(node.Item.Count);
                sender.itemList.Remove(node.Item);
                sender.itemListUI.RemoveItemNode(this._selectedIndexOf);
                List <StuffItem> stuffItemList = new List <StuffItem>();
                while (count > 0)
                {
                    StuffItem[] array = ((IEnumerable <StuffItem>)sender.itemList.FindItems(stuffItem1)).OrderBy <StuffItem, int>((Func <StuffItem, int>)(x => x.Count)).ToArray <StuffItem>();
                    if (!((IEnumerable <StuffItem>)array).Any <StuffItem>())
                    {
                        Debug.LogError((object)string.Format("RemoveCountOver:{0}", (object)Singleton <Resources> .Instance.GameInfo.GetItem(stuffItem1.CategoryID, stuffItem1.ID).Name));
                        break;
                    }
                    foreach (StuffItem stuffItem2 in array)
                    {
                        int count1 = stuffItem2.Count;
                        stuffItem2.Count -= count;
                        count            -= count1;
                        if (stuffItem2.Count <= 0)
                        {
                            stuffItemList.Add(stuffItem2);
                        }
                        if (count <= 0)
                        {
                            break;
                        }
                    }
                }
                foreach (StuffItem stuffItem2 in stuffItemList)
                {
                    sender.itemList.Remove(stuffItem2);
                    foreach (KeyValuePair <int, ItemNodeUI> keyValuePair in (IEnumerable <KeyValuePair <int, ItemNodeUI> >)sender.itemListUI.optionTable)
                    {
                        if (stuffItem2 == keyValuePair.Value.Item)
                        {
                            sender.itemListUI.RemoveItemNode(keyValuePair.Key);
                            break;
                        }
                    }
                }
                this.SetFocusLevel(sender.itemListUI.FocusLevel);
                sender.itemListUI.ForceSetNonSelect();
            }
            receiver.Refresh();
            sender.Refresh();
            this._itemSendPanel.Refresh();
        }