Beispiel #1
0
 public void TakeItem(ItemSlotData info, bool all = false)
 {
     if (!lootAgent || info == null || !info.item)
     {
         return;
     }
     WindowsManager.CloseWindow <ItemWindow>();
     if (!all)
     {
         if (info.amount == 1)
         {
             OnTake(info, 1);
         }
         else
         {
             AmountWindow.StartInput(delegate(long amount)
             {
                 OnTake(info, (int)amount);
             }, info.amount, "拾取数量", ZetanUtility.ScreenCenter, Vector2.zero);
         }
     }
     else
     {
         OnTake(info, info.amount);
     }
 }
 private void DebugGetter()
 {
     if (item)
     {
         AmountWindow.StartInput(a => { if (item)
                                        {
                                            BackpackManager.Instance.GetItem(item.Model_old, (int)a);
                                        }
                                 }, 999, position: icon.transform.position);
     }
 }
Beispiel #3
0
    private void TakeOut(ItemSlot copy, bool all = false)
    {
        if (!copy.IsEmpty)
        {
            if (all || copy.Data.amount < 2)
            {
                RemoveSlot(copy);
            }
            else
            {
                AmountWindow.StartInput((amount) =>
                {
                    if (copy.Data.amount < amount)
                    {
                        MessageManager.Instance.New("物品数量已改变,请重试");
                    }
                    else
                    {
                        copy.Data.amount -= (int)amount;
                        if (copy.Data.amount < 1)
                        {
                            RemoveSlot(copy);
                        }
                        else
                        {
                            copy.Refresh();
                        }
                    }
                }, copy.Data.amount, "取出数量");
            }
        }

        void RemoveSlot(ItemSlot copy)
        {
            copySlots.Remove(copy.Item.ID);
            caches.Put(copy);
            selectedItems.Remove(copy.Item);
            SourceContainer.MarkIf(s => selectedItems.Contains(s.Item));
            if (copySlots.Count < 1)
            {
                ZetanUtility.SetActive(tips, true);
            }
        }
    }
Beispiel #4
0
    public void StoreItem(ItemData item, bool all = false)
    {
        if (Handler == null || OtherWindow == null || !OtherWindow.Handler.Inventory || !item)
        {
            return;
        }
        WindowsManager.CloseWindow <ItemWindow>();
        int have = OtherWindow.Handler.GetAmount(item);

        if (have < 1)
        {
            return;
        }
        if (!all)
        {
            if (have == 1 && OnStore(item, 1) > 0)
            {
                MessageManager.Instance.New($"存入了1个 [{ItemUtility.GetColorName(item.Model_old)}]");
            }
            else
            {
                int maxGet = Handler.Inventory.PeekGet(item, have);
                AmountWindow.StartInput(delegate(long amount)
                {
                    int store = OnStore(item, (int)amount);
                    if (store > 0)
                    {
                        MessageManager.Instance.New($"存入了{store}个 [{ItemUtility.GetColorName(item.Model_old)}]");
                    }
                }, have > maxGet ? maxGet : have, "存入数量", ZetanUtility.ScreenCenter, Vector2.zero);
            }
        }
        else
        {
            int amountBef = Handler.GetAmount(item);
            int store     = OnStore(item, have);
            if (store > 0)
            {
                MessageManager.Instance.New($"存入了{store}个 [{ItemUtility.GetColorName(item.Model_old)}]");
            }
        }
    }
Beispiel #5
0
    /// <summary>
    /// 向玩家卖出道具
    /// </summary>
    /// <param name="goods">商品信息</param>
    public void SellItem(GoodsData goods)
    {
        if (MShop == null || goods == null || !goods.Info.IsValid)
        {
            return;
        }
        if (!MShop.Commodities.Contains(goods))
        {
            return;
        }
        long maxAmount = goods.Info.EmptyAble ? goods.LeftAmount : (goods.Info.SellPrice > 0 ? BackpackManager.Instance.Inventory.Money / goods.Info.SellPrice : 999);

        if (goods.LeftAmount == 1 && goods.Info.EmptyAble)
        {
            ConfirmWindow.StartConfirm(string.Format("确定购买1个 [{0}] 吗?", goods.Item.Name), delegate
            {
                if (OnSell(goods))
                {
                    MessageManager.Instance.New(string.Format("购买了1个 [{0}]", goods.Item.Name));
                }
            });
        }
        else if (goods.IsEmpty)
        {
            ConfirmWindow.StartConfirm("该商品暂时缺货");
        }
        else
        {
            AmountWindow.StartInput(delegate(long amount)
            {
                ConfirmWindow.StartConfirm(string.Format("确定购买{0}个 [{1}] 吗?", (int)amount, goods.Item.Name), delegate
                {
                    if (OnSell(goods, (int)amount))
                    {
                        MessageManager.Instance.New(string.Format("购买了{0}个 [{1}]", (int)amount, goods.Item.Name));
                    }
                });
            }, maxAmount, "购买数量", ZetanUtility.ScreenCenter, Vector2.zero);
        }
    }
Beispiel #6
0
    public void TakeOutItem(ItemData item, bool all = false)
    {
        if (Handler == null || item == null)
        {
            return;
        }
        WindowsManager.CloseWindow <ItemWindow>();
        int have = Handler.GetAmount(item);

        if (!all)
        {
            if (have == 1 && OnTakeOut(item, 1, 1) > 0)
            {
                MessageManager.Instance.New($"取出了1个 [{ItemUtility.GetColorName(item.Model_old)}");
            }
            else
            {
                AmountWindow.StartInput(delegate(long amount)
                {
                    int take = OnTakeOut(item, (int)amount, have);
                    if (take > 0)
                    {
                        MessageManager.Instance.New($"取出了{take}个 [{ItemUtility.GetColorName(item.Model_old)}]");
                    }
                }, have, "取出数量", ZetanUtility.ScreenCenter, Vector2.zero);
            }
        }
        else
        {
            int take = OnTakeOut(item, have, have);
            if (take > 0)
            {
                MessageManager.Instance.New($"取出了{have + take}个 [{ItemUtility.GetColorName(item.Model_old)}]");
            }
        }
    }