예제 #1
0
        public void ReDraw(ISkillArgs args, ItemInventory inventory, bool includeBack)
        {
            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.InventoyUI;
            // 0 重绘,1 添加,2 删除, 3 更新
            sp.Ks.Add(0);
            sp.Bs.Add(true);

            sp.Ks.Add(inventory.posList.Count);

            foreach (ItemPosition ip in inventory.posList)
            {
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey());

                sp.Ins.Add(info.cat);
                sp.Ins.Add(info.id);
                sp.Ins.Add(ip.GetCount());

                sp.Ss.Add(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY());
            }

            FreeData fd = (FreeData)args.GetUnit("current");

            sp.Ks.Add((int)BagCapacityUtil.GetCapacity(fd));
            sp.Ks.Add((int)Math.Ceiling(BagCapacityUtil.GetWeight(fd)));

            SendMessageAction.sender.SendMessage(args, sp, 1, "current");

            ChickenFuncUtil.UpdateBagCapacity(args, (int)Math.Ceiling(BagCapacityUtil.GetWeight(fd)), BagCapacityUtil.GetCapacity(fd));
        }
예제 #2
0
        public static void AddClip(int count, int clipType, FreeData fd, IEventArgs args)
        {
            if (BagCapacityUtil.CanAddToBag(args, fd, (int)ECategory.GameItem, clipType, count))
            {
                int            leftCount = count;
                ItemPosition[] ips       = fd.freeInventory.GetInventoryManager().GetDefaultInventory().GetItems();
                foreach (ItemPosition ip in ips)
                {
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                    if (ip.GetParameters().HasPara("ClipType") && (int)ip.GetParameters().Get("ClipType").GetValue() == clipType)
                    {
                        int added = Math.Min(leftCount, info.stack - ip.count);
                        leftCount -= added;

                        ip.SetCount(ip.GetCount() + added);
                        ip.GetInventory().GetInventoryUI().UpdateItem((FreeRuleEventArgs)args, ip.GetInventory(), ip);
                    }
                }

                if (leftCount > 0)
                {
                    FreeItem item = FreeItemManager.GetItem((FreeRuleEventArgs)args, FreeItemConfig.GetItemKey((int)ECategory.GameItem, clipType), leftCount);
                    if (item != null)
                    {
                        fd.freeInventory.GetInventoryManager().GetDefaultInventory().AddItem((ISkillArgs)args, item, true);
                    }
                }
            }
            else
            {
                FreeItem item = FreeItemManager.GetItem((FreeRuleEventArgs)args, FreeItemConfig.GetItemKey((int)ECategory.GameItem, clipType), count);
                if (item != null)
                {
                    fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagGround).AddItem((ISkillArgs)args, item, true);
                }
            }
        }