Exemplo n.º 1
0
    void BuyItemSuc(BaseHttpRequest request, BaseResponse response)
    {
        BuyItemResponse resp = response as BuyItemResponse;

        if (resp.data == null)
        {
            return;
        }

        int propid = 0;

        ItemOfReward[] rewards = null;
        HttpRequest    req     = request as HttpRequest;

        if (_type == ShopItemType.Active)
        {
            BuyActiveShopItemParam param = req.ParamMem as BuyActiveShopItemParam;
            propid = param.propid;
        }
        else
        {
            PurchaseParam param = req.ParamMem as PurchaseParam;
            propid = param.propid;
        }

        if (resp.data.Result != null)
        {
            if (resp.data.Result.coin > 0)
            {
                string strText = Core.Data.stringManager.getString(5214);
                strText = string.Format(strText, resp.data.Result.coin, Core.Data.stringManager.getString(5037));
                SQYAlertViewMove.CreateAlertViewMove(strText);
                DBUIController.mDBUIInstance.RefreshUserInfo();
            }
            else if (resp.data.Result.stone > 0)
            {
                string strText = Core.Data.stringManager.getString(5214);
                strText = string.Format(strText, resp.data.Result.stone, Core.Data.stringManager.getString(5070));
                SQYAlertViewMove.CreateAlertViewMove(strText);
                DBUIController.mDBUIInstance.RefreshUserInfo();
            }
            else if (resp.data.Result.eny > 0)
            {
                string strText = Core.Data.stringManager.getString(5214);
                strText = string.Format(strText, resp.data.Result.eny, Core.Data.stringManager.getString(5038));
                SQYAlertViewMove.CreateAlertViewMove(strText);
                DBUIController.mDBUIInstance.RefreshUserInfo();
            }
            else if (resp.data.Result.pwr > 0)
            {
                string strText = Core.Data.stringManager.getString(5214);
                strText = string.Format(strText, resp.data.Result.pwr, Core.Data.stringManager.getString(5039));
                SQYAlertViewMove.CreateAlertViewMove(strText);
                DBUIController.mDBUIInstance.RefreshUserInfo();
            }

            if (resp.data.Result.p != null)
            {
                rewards = resp.data.Result.p;
                ShowRewards(propid, rewards);
            }
        }
        else
        {
            if (UIDragonMallMgr.GetInstance().CheckOpenWindowList.Contains(propid))
            {
                SQYAlertViewMove.CreateAlertViewMove(string.Format(Core.Data.stringManager.getString(5214), Core.Data.itemManager.getItemData(propid).name, ""));
            }
            else
            {
                GetRewardSucUI.OpenUI(resp.data.p, Core.Data.stringManager.getString(5097));
            }

            DBUIController.mDBUIInstance.RefreshUserInfo();
        }


        SQYMainController.mInstance.UpdateBagTip();
    }
Exemplo n.º 2
0
    void BuyNormal_OnClick()
    {
        if (!CheckVipBuy())
        {
            return;
        }

        int mNeedMoney = 0;
        int mMoneyType = 0;

        if (_type == ShopItemType.Active)
        {
            mMoneyType = ActiveItemdata.mType;
            if (ActiveItemdata.disPrice == 0)
            {
                mNeedMoney = ActiveItemdata.price;
            }
            else
            {
                mNeedMoney = ActiveItemdata.disPrice;
            }
        }
        else
        {
            if (mdata.discount.Length != 0)
            {
                mMoneyType = mdata.discount[0];
                mNeedMoney = mdata.discount[1];
            }
            else
            {
                if (mdata.price.Length != 0)
                {
                    mMoneyType = mdata.price[0];
                    mNeedMoney = mdata.price[1];
                }
            }
        }


        if (mMoneyType == 0)
        {
            if (Core.Data.playerManager.Coin < mNeedMoney)
            {
                JCRestoreEnergyMsg.OpenUI(ItemManager.COIN_PACKAGE, ItemManager.COIN_BOX, 2);
                return;
            }
        }
        else if (mMoneyType == 1)
        {
            if (Core.Data.playerManager.Stone < mNeedMoney)
            {
                SQYAlertViewMove.CreateAlertViewMove(Core.Data.stringManager.getString(35006));
                return;
            }

            // talkingdata add by wxl
            if (_type == ShopItemType.Active)
            {
                TDataOnBuyItem(ActiveItemdata.pid, 1, mNeedMoney);
            }
            else
            {
                TDataOnBuyItem(mdata.ID, 1, mNeedMoney);
            }
        }
        else
        {
            if (mMoneyType != 2 && mMoneyType != 3)
            {
                int      _battlesoul = 0;
                ItemData data        = null;
                _battlesoul = Core.Data.itemManager.GetBagItemCount(mMoneyType);
                data        = Core.Data.itemManager.getItemData(mMoneyType);

                if (_battlesoul < mNeedMoney)
                {
                    if (data != null)
                    {
                        SQYAlertViewMove.CreateAlertViewMove(string.Format(Core.Data.stringManager.getString(25174), data.name));
                    }
                    return;
                }
            }
            else
            {
                SQYAlertViewMove.CreateAlertViewMove(Core.Data.stringManager.getString(7999));

                return;
            }
        }

        HttpTask task = new HttpTask(ThreadType.MainThread, TaskResponse.Default_Response);

        if (_type != ShopItemType.Active)
        {
            PurchaseParam param = new PurchaseParam();
            param.gid    = Core.Data.playerManager.PlayerID;
            param.propid = mdata.ID;
            if (this.mdata.max == 0)
            {
                param.nm = 1;
            }
            else
            {
                param.nm = BuyNumber.NumIndex;
            }
            task.AppendCommonParam(RequestType.BUY_ITEM, param);
        }
        else
        {
            BuyActiveShopItemParam param = new BuyActiveShopItemParam();
            param.gid    = int.Parse(Core.Data.playerManager.PlayerID);
            param.propid = ActiveItemdata.pid;
            param.nm     = 1;
            task.AppendCommonParam(RequestType.ACTIVESHOPBUYITEM, param);
        }
        if (Core.Data.guideManger.isGuiding)
        {
            task.afterCompleted += SecretShopMgr.GetInstance().testHttpResp_UI;
        }
        else
        {
            task.afterCompleted += SecretShopMgr.GetInstance()._UIDragonMallCell.testHttpResp_UI;
        }
        task.DispatchToRealHandler();
        ComLoading.Open();
        Back_OnClick();
    }