Beispiel #1
0
    void BuyMallItem(int resId, int subId)
    {
        MallTableItem item = Module.MallTable[resId] as MallTableItem;

        if (item == null)
        {
            return;
        }

        PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();

        //有钱没;
        MallItemInfo info = item.mallItems[subId];
        ProceedsType pt   = (ProceedsType)item.processType;

        if (pdm.GetProceeds(pt) < info.processNow)
        {
            //PromptUIManager.Instance.AddNewPrompt(ShopModule.GetBuyMoneyNotEnougthStr(pt));
            PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, ShopModule.GetBuyMoneyNotEnougthStr(pt)));
            return;
        }

        //次数够了没;
        switch (mModule.GetLimitTypeByID(resId))
        {
        case MallLimitType.ERROR:
            GameDebug.LogError("数据错误");
            return;

        case MallLimitType.NONE:
            break;

        case MallLimitType.DAY:
        case MallLimitType.FOREVER:
            if (mModule.GetPlayerBuyTimes(resId) >= item.limitTimes)
            {
                //PromptUIManager.Instance.AddNewPrompt(StringHelper.GetString("buy_no_time"));
                PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, StringHelper.GetString("buy_no_time")));
                return;
            }
            break;
        }

        MallBuyItemAction param = new MallBuyItemAction();

        param.ResId  = resId;
        param.SubIdx = subId;

        Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_MALL_BUY, param);
    }
Beispiel #2
0
    void BuyMallItem(int resId)
    {
        ShopTableItem item = DataManager.ShopTable[resId] as ShopTableItem;

        if (item == null)
        {
            return;
        }

        PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (pdm == null || pdm.GetShopIsBuyDone(resId))
        {
            return;
        }

        if (!mAllItemsLists.ContainsKey(resId))
        {
            return;
        }

        ShopItemUI itemUi = mAllItemsLists[resId];

        if (itemUi == null)
        {
            return;
        }

        // 已经买了吗;
        if (itemUi.IsScretItemBuyDone)
        {
            //PromptUIManager.Instance.AddNewPrompt(StringHelper.GetString("buy_done"));
            PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, StringHelper.GetString("buy_done")));
            return;
        }

        /// 钱够了吗;
        ProceedsType pt   = ProceedsType.Invalid;
        int          cost = 0;

        if (!itemUi.GetProcTypeAndCost(ref pt, ref cost))
        {
            return;
        }

        if (pdm.GetProceeds(pt) < cost)
        {
            //PromptUIManager.Instance.AddNewPrompt(ShopModule.GetBuyMoneyNotEnougthStr(pt));
            PopTipManager.Instance.AddNewTip(StringHelper.StringWithColor(FontColor.Red, ShopModule.GetBuyMoneyNotEnougthStr(pt)));
            return;
        }

        // 成功逻辑;
        ShopBuyItemAction param = new ShopBuyItemAction();

        param.OpType = (int)ShopOpType.BuyItem;
        param.ResId  = resId;

        Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_SHOP, param);

        //MallBuyItemAction param = new MallBuyItemAction();
        //param.ResId = resId;
        //param.SubIdx = subId;

        ////有钱没;
        //MallItemInfo info = item.mallItems[subId];
        //if (pdm.GetProceeds((ProceedsType)item.processType) < info.processNow)
        //{
        //    PromptUIManager.Instance.AddNewPrompt("钱不够");
        //    return;
        //}

        ////次数够了没;
        //switch (mModule.GetLimitTypeByID(resId))
        //{
        //    case MallLimitType.ERROR:
        //        GameDebug.LogError("数据错误");
        //        return;
        //    case MallLimitType.NONE:
        //        break;
        //    case MallLimitType.DAY:
        //    case MallLimitType.FOREVER:
        //        if (mModule.GetPlayerBuyTimes(resId) >= item.limitTimes)
        //        {
        //            PromptUIManager.Instance.AddNewPrompt("购买次数够了");
        //            return;
        //        }
        //        break;
        //}

        //Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_MALL_BUY, param);
    }