Пример #1
0
    protected override void OnRequest(request_shop_op request, object userdata)
    {
        if (userdata is ShopBuyItemAction)
        {
            ShopBuyItemAction param = userdata as ShopBuyItemAction;
            request.op_type = param.OpType;
            request.shopid  = param.ResId;
        }

        if (userdata is ShopRefreshAction)
        {
            ShopRefreshAction param = userdata as ShopRefreshAction;
            request.op_type = param.OpType;
        }

        if (userdata is ShopFreeRefreshAction)
        {
            ShopFreeRefreshAction param = userdata as ShopFreeRefreshAction;
            request.op_type = param.OpType;
        }
    }
Пример #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);
    }