Example #1
0
        public void SetData(GameObject root, CUIFormScript formScript)
        {
            ResRandomRewardStore dataByKey = GameDataMgr.randowmRewardDB.GetDataByKey(0xa029);

            for (int i = 0; i < 3; i++)
            {
                string                 name        = string.Format("Panel/QQVip/AwardGrid/QQ/ListElement{0}/ItemCell", i);
                GameObject             gameObject  = root.transform.FindChild(name).gameObject;
                ResDT_RandomRewardInfo info        = dataByKey.astRewardDetail[i];
                CUseable               itemUseable = CUseableManager.CreateUsableByRandowReward((RES_RANDOM_REWARD_TYPE)info.bItemType, (int)info.dwLowCnt, info.dwItemID);
                if (itemUseable != null)
                {
                    if (gameObject.GetComponent <CUIEventScript>() == null)
                    {
                        gameObject.AddComponent <CUIEventScript>();
                    }
                    CUICommonSystem.SetItemCell(formScript, gameObject, itemUseable, true, false);
                }
            }
            ResRandomRewardStore store2 = GameDataMgr.randowmRewardDB.GetDataByKey(0xa02a);

            for (int j = 0; j < 3; j++)
            {
                string                 str2     = string.Format("Panel/QQVip/AwardGrid/QQVip/ListElement{0}/ItemCell", j);
                GameObject             itemCell = root.transform.FindChild(str2).gameObject;
                ResDT_RandomRewardInfo info2    = store2.astRewardDetail[j];
                CUseable               useable2 = CUseableManager.CreateUsableByRandowReward((RES_RANDOM_REWARD_TYPE)info2.bItemType, (int)info2.dwLowCnt, info2.dwItemID);
                if (useable2 != null)
                {
                    if (itemCell.GetComponent <CUIEventScript>() == null)
                    {
                        itemCell.AddComponent <CUIEventScript>();
                    }
                    CUICommonSystem.SetItemCell(formScript, itemCell, useable2, true, false);
                }
            }
            this.m_BtnQQ = root.transform.FindChild("Panel/QQVip/AwardGrid/QQ/Button/").gameObject;
            Text      componentInChildren = root.transform.FindChild("Panel/QQVip/AwardGrid/QQVip/Button/").gameObject.GetComponentInChildren <Text>();
            CRoleInfo masterRoleInfo      = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

            if (masterRoleInfo != null)
            {
                if (masterRoleInfo.HasVip(0x10))
                {
                    if (this.m_BtnQQ.activeInHierarchy)
                    {
                        this.m_BtnQQ.GetComponentInChildren <Text>().text = "续费QQ会员";
                    }
                    componentInChildren.text = "续费超级会员";
                }
                else if (masterRoleInfo.HasVip(1))
                {
                    if (this.m_BtnQQ.activeInHierarchy)
                    {
                        this.m_BtnQQ.GetComponentInChildren <Text>().text = "续费QQ会员";
                    }
                    componentInChildren.text = "开通超级会员";
                }
                else if (!masterRoleInfo.HasVip(1))
                {
                    if (this.m_BtnQQ.activeInHierarchy)
                    {
                        this.m_BtnQQ.GetComponentInChildren <Text>().text = "开通QQ会员";
                    }
                    componentInChildren.text = "开通超级会员";
                }
            }
        }
        public BuyPickDialog(bool isGift, COM_ITEM_TYPE type, uint id, RES_SHOPBUY_COINTYPE coinType, float discount, uint maxCount, BuyPickDialog.OnConfirmBuyDelegate onConfirm, CMallFactoryShopController.ShopProduct callContext, BuyPickDialog.OnConfirmBuyCommonDelegate onConfirmCommon = null, CUIEvent uieventPars = null, bool bfromFactoyShop = false)
        {
            this.m_bShowBigIcon = (callContext != null && callContext.GetSpecialIconPath() != null);
            CUIFormScript cUIFormScript;

            if (this.m_bShowBigIcon)
            {
                cUIFormScript = Singleton <CUIManager> .GetInstance().OpenForm(BuyPickDialog.s_Gift_Big_Icon_Form_Path, false, true);
            }
            else
            {
                cUIFormScript = Singleton <CUIManager> .GetInstance().OpenForm(BuyPickDialog.s_Gift_Form_Path, false, true);
            }
            if (null != cUIFormScript)
            {
                this._root                 = cUIFormScript.gameObject;
                this._usb                  = CUseableManager.CreateUseable(type, id, 0);
                this._count                = 1u;
                this._bHeroSkinGift        = false;
                this._bDynamicCorrectPrice = false;
                this._heroSkinGiftCost     = 0u;
                this._maxCount             = maxCount;
                if (this._maxCount == 0u)
                {
                    this._maxCount = 999u;
                }
                this._onConfirm        = onConfirm;
                this._callContext      = callContext;
                this._onConfirmdCommon = onConfirmCommon;
                this._uieventPars      = uieventPars;
                this._coinType         = coinType;
                this._realDiscount     = discount;
                if (this._usb != null)
                {
                    this._countText = Utility.GetComponetInChild <Text>(this._root, "Panel/Count");
                    this._costText  = Utility.GetComponetInChild <Text>(this._root, "Panel/Cost");
                    this._descText  = Utility.GetComponetInChild <Text>(this._root, "Panel/lblDesc");
                    CItem cItem = new CItem(0uL, id, 0, 0);
                    uint  key   = (uint)cItem.m_itemData.EftParam[0];
                    ResRandomRewardStore dataByKey = GameDataMgr.randomRewardDB.GetDataByKey(key);
                    ListView <CUseable>  listView  = new ListView <CUseable>();
                    for (int i = 0; i < dataByKey.astRewardDetail.Length; i++)
                    {
                        if (dataByKey.astRewardDetail[i].bItemType != 0)
                        {
                            CUseable cUseable = CUseableManager.CreateUsableByRandowReward((RES_RANDOM_REWARD_TYPE)dataByKey.astRewardDetail[i].bItemType, (int)dataByKey.astRewardDetail[i].dwLowCnt, dataByKey.astRewardDetail[i].dwItemID);
                            if (cUseable != null)
                            {
                                listView.Add(cUseable);
                            }
                        }
                    }
                    if (this._descText != null)
                    {
                        this._descText.set_text(string.IsNullOrEmpty(cItem.m_mallDescription) ? cItem.m_description : cItem.m_mallDescription);
                    }
                    uint num  = 0u;
                    int  num2 = 0;
                    if (this._usb.m_type == COM_ITEM_TYPE.COM_OBJTYPE_ITEMPROP)
                    {
                        CItem cItem2 = (CItem)this._usb;
                        if (cItem2 != null && cItem2.m_itemData != null && cItem2.m_itemData.bType == 4)
                        {
                            this._bDynamicCorrectPrice = (cItem2.m_itemData.EftParam[3] > 0f);
                        }
                    }
                    CUIListScript componetInChild = Utility.GetComponetInChild <CUIListScript>(cUIFormScript.gameObject, "Panel/itemGroup");
                    componetInChild.SetElementAmount(listView.Count);
                    for (int j = 0; j < listView.Count; j++)
                    {
                        CUIListElementScript elemenet = componetInChild.GetElemenet(j);
                        this.UpdateElement(elemenet, listView[j], this.m_bShowBigIcon);
                        if (listView[j].m_type == COM_ITEM_TYPE.COM_OBJTYPE_HERO)
                        {
                            this._bHeroSkinGift = true;
                            CHeroItem cHeroItem      = listView[j] as CHeroItem;
                            CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                            if (masterRoleInfo != null && masterRoleInfo.IsOwnHero(cHeroItem.m_heroData.dwCfgID))
                            {
                                num += CHeroInfo.GetHeroCost(cHeroItem.m_heroData.dwCfgID, coinType);
                                num2++;
                            }
                        }
                        else if (listView[j].m_type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN)
                        {
                            this._bHeroSkinGift = true;
                            CHeroSkin cHeroSkin       = listView[j] as CHeroSkin;
                            CRoleInfo masterRoleInfo2 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                            if (masterRoleInfo2 != null && masterRoleInfo2.IsHaveHeroSkin(cHeroSkin.m_heroId, cHeroSkin.m_skinId, false))
                            {
                                num += CSkinInfo.GetHeroSkinCost(cHeroSkin.m_heroId, cHeroSkin.m_skinId, coinType);
                                num2++;
                            }
                        }
                    }
                    this._coinUsb = CUseableManager.CreateCoinUseable(coinType, 0);
                    if (this._coinUsb != null)
                    {
                        Utility.GetComponetInChild <Image>(this._root, "Panel/Cost/CoinType").SetSprite(CUIUtility.GetSpritePrefeb(this._coinUsb.GetIconPath(), false, false), false);
                    }
                    Text componetInChild2 = Utility.GetComponetInChild <Text>(this._root, "Panel/costDescText");
                    componetInChild2.set_text(string.Empty);
                    if (this._bHeroSkinGift && this._bDynamicCorrectPrice)
                    {
                        uint   buyPrice         = this._usb.GetBuyPrice(coinType);
                        Button componetInChild3 = Utility.GetComponetInChild <Button>(this._root, "Panel/Button_Sale");
                        if (num2 >= listView.Count)
                        {
                            CUICommonSystem.SetButtonEnableWithShader(componetInChild3, false, true);
                            componetInChild2.set_text(Singleton <CTextManager> .GetInstance().GetText("Gift_Can_Not_Buy_Tip"));
                            this._heroSkinGiftCost = 0u;
                        }
                        else
                        {
                            CUICommonSystem.SetButtonEnableWithShader(componetInChild3, true, true);
                            componetInChild2.set_text(Singleton <CTextManager> .GetInstance().GetText("Gift_Own_Hero_Skin_Tip"));
                            uint num3 = CMallFactoryShopController.ShopProduct.SConvertWithRealDiscount(buyPrice - num, this._realDiscount);
                            if (buyPrice >= num && num3 >= buyPrice / 10u)
                            {
                                this._heroSkinGiftCost = num3;
                            }
                            else
                            {
                                this._heroSkinGiftCost = buyPrice / 10u;
                            }
                        }
                        if (this._callContext != null)
                        {
                            this._callContext.m_bChangeGiftPrice = true;
                            this._callContext.m_newGiftPrice     = this._heroSkinGiftCost;
                        }
                    }
                }
                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_CloseForm, new CUIEventManager.OnUIEventHandler(this.OnCloseForm));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Add, new CUIEventManager.OnUIEventHandler(this.OnClickAdd));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Dec, new CUIEventManager.OnUIEventHandler(this.OnClickDec));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Max, new CUIEventManager.OnUIEventHandler(this.OnClickMax));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Confirm, new CUIEventManager.OnUIEventHandler(this.OnClickConfirm));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Cancel, new CUIEventManager.OnUIEventHandler(this.OnClickCancel));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_ConfirmFactoryShopBuy, new CUIEventManager.OnUIEventHandler(this.OnConfirmFactoryShopBuy));

                this.ValidateDynamic();
            }
        }
        private void OnClickExchange(CUIEvent uiEvent)
        {
            if (this._elementList == null)
            {
                return;
            }
            int commonUInt32Param = (int)uiEvent.m_eventParams.commonUInt32Param1;

            if (commonUInt32Param >= 0 && commonUInt32Param < this._elementList.Count)
            {
                uint     dwResItemID = this._elementList[commonUInt32Param].phase.Config.dwResItemID;
                CUseable cUseable    = CUseableManager.CreateUseable((COM_ITEM_TYPE)this._elementList[commonUInt32Param].phase.Config.wResItemType, this._elementList[commonUInt32Param].phase.Config.dwResItemID, (int)this._elementList[commonUInt32Param].phase.Config.wResItemCnt);
                if (cUseable == null)
                {
                    return;
                }
                bool flag = false;
                int  num  = 0;
                if (cUseable.m_type == COM_ITEM_TYPE.COM_OBJTYPE_HERO)
                {
                    CHeroItem cHeroItem = (CHeroItem)cUseable;
                    if (cHeroItem != null)
                    {
                        CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                        if (masterRoleInfo != null)
                        {
                            flag = masterRoleInfo.IsHaveHero(cHeroItem.m_baseID, true);
                        }
                    }
                }
                else if (cUseable.m_type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN)
                {
                    CHeroSkin cHeroSkin = (CHeroSkin)cUseable;
                    if (cHeroSkin != null)
                    {
                        CRoleInfo masterRoleInfo2 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                        if (masterRoleInfo2 != null)
                        {
                            flag = masterRoleInfo2.IsHaveHeroSkin(cHeroSkin.m_heroId, cHeroSkin.m_skinId, false);
                        }
                    }
                }
                else if (cUseable.m_type == COM_ITEM_TYPE.COM_OBJTYPE_ITEMPROP)
                {
                    CItem cItem = (CItem)cUseable;
                    if (cItem != null)
                    {
                        CRoleInfo masterRoleInfo3 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                        if (cItem.m_itemData != null && masterRoleInfo3 != null && cItem.m_itemData.bType == 4)
                        {
                            int num2 = (int)cItem.m_itemData.EftParam[0];
                            if (num2 > 0)
                            {
                                ResRandomRewardStore dataByKey = GameDataMgr.randomRewardDB.GetDataByKey((long)num2);
                                if (dataByKey != null)
                                {
                                    for (int i = 0; i < dataByKey.astRewardDetail.Length; i++)
                                    {
                                        if (dataByKey.astRewardDetail[i].bItemType == 0 || dataByKey.astRewardDetail[i].bItemType >= 18)
                                        {
                                            break;
                                        }
                                        if (dataByKey.astRewardDetail[i].bItemType == 4)
                                        {
                                            if (!masterRoleInfo3.IsHaveHero(dataByKey.astRewardDetail[i].dwItemID, true))
                                            {
                                                num = 0;
                                                break;
                                            }
                                            num = 1;
                                        }
                                        else if (dataByKey.astRewardDetail[i].bItemType == 11)
                                        {
                                            if (!masterRoleInfo3.IsHaveHeroSkin(dataByKey.astRewardDetail[i].dwItemID, true))
                                            {
                                                num = 0;
                                                break;
                                            }
                                            num = 1;
                                        }
                                        else if (dataByKey.astRewardDetail[i].bItemType > 0 && dataByKey.astRewardDetail[i].bItemType < 18)
                                        {
                                            num = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (flag)
                {
                    string strContent = string.Format(Singleton <CTextManager> .GetInstance().GetText("ExchangeWgt_Hero_Tips"), cUseable.m_name);
                    uiEvent.m_eventParams.taskId = 0u;
                    Singleton <CUIManager> .GetInstance().OpenMessageBoxWithCancel(strContent, enUIEventID.Activity_ExchangeHeroSkinConfirm, enUIEventID.None, uiEvent.m_eventParams, false);

                    return;
                }
                if (num == 1)
                {
                    string text = Singleton <CTextManager> .GetInstance().GetText("ExchangeWgt_Have_AllGift");

                    uiEvent.m_eventParams.taskId = 1u;
                    Singleton <CUIManager> .GetInstance().OpenMessageBoxWithCancel(text, enUIEventID.Activity_ExchangeHeroSkinConfirm, enUIEventID.None, uiEvent.m_eventParams, false);

                    return;
                }
                int maxExchangeCount = this._elementList[commonUInt32Param].phase.GetMaxExchangeCount();
                if (maxExchangeCount > 1)
                {
                    stUIEventParams par = default(stUIEventParams);
                    par.commonUInt16Param1 = (ushort)commonUInt32Param;
                    Singleton <CUIManager> .GetInstance().OpenExchangeCountSelectForm(cUseable, maxExchangeCount, enUIEventID.Activity_PtExchangeCountReady, par, this._elementList[commonUInt32Param].phase.Config.dwPointCnt, Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo().JiFen);
                }
                else
                {
                    string          text2 = (cUseable == null) ? string.Empty : cUseable.m_name;
                    stUIEventParams par2  = default(stUIEventParams);
                    par2.commonUInt16Param1 = (ushort)commonUInt32Param;
                    this._elementList[commonUInt32Param].phase.SetExchangeCountOnce(1);
                    Singleton <CUIManager> .GetInstance().OpenMessageBoxWithCancel(string.Format(Singleton <CTextManager> .GetInstance().GetText("confirmExchange"), maxExchangeCount, text2), enUIEventID.Activity_PtExchangeConfirm, enUIEventID.None, par2, false);
                }
            }
        }
Example #4
0
        public BuyPickDialog(bool isGift, COM_ITEM_TYPE type, uint id, RES_SHOPBUY_COINTYPE coinType, uint discount, uint maxCount, OnConfirmBuyDelegate onConfirm, CMallFactoryShopController.ShopProduct callContext, OnConfirmBuyCommonDelegate onConfirmCommon = null, CUIEvent uieventPars = null)
        {
            CUIFormScript formScript = Singleton <CUIManager> .GetInstance().OpenForm(s_Gift_Form_Path, false, true);

            if (null != formScript)
            {
                this._root     = formScript.gameObject;
                this._usb      = CUseableManager.CreateUseable(type, id, 0);
                this._count    = 1;
                this._maxCount = maxCount;
                if (this._maxCount == 0)
                {
                    this._maxCount = 0x3e7;
                }
                this._onConfirm        = onConfirm;
                this._callContext      = callContext;
                this._onConfirmdCommon = onConfirmCommon;
                this._uieventPars      = uieventPars;
                this._coinType         = coinType;
                this._discount         = discount;
                if (this._usb != null)
                {
                    this._countText = Utility.GetComponetInChild <Text>(this._root, "Panel/Count");
                    this._costText  = Utility.GetComponetInChild <Text>(this._root, "Panel/Cost");
                    this._descText  = Utility.GetComponetInChild <Text>(this._root, "Panel/lblDesc");
                    CItem item = new CItem(0L, id, 0, 0);
                    uint  key  = (uint)item.m_itemData.EftParam[0];
                    ResRandomRewardStore dataByKey = GameDataMgr.randowmRewardDB.GetDataByKey(key);
                    ListView <CUseable>  view      = new ListView <CUseable>();
                    for (int i = 0; i < dataByKey.astRewardDetail.Length; i++)
                    {
                        if (dataByKey.astRewardDetail[i].bItemType != 0)
                        {
                            CUseable useable = CUseableManager.CreateUsableByRandowReward((RES_RANDOM_REWARD_TYPE)dataByKey.astRewardDetail[i].bItemType, (int)dataByKey.astRewardDetail[i].dwLowCnt, dataByKey.astRewardDetail[i].dwItemID);
                            if (useable != null)
                            {
                                view.Add(useable);
                            }
                        }
                    }
                    if (this._descText != null)
                    {
                        this._descText.text = item.m_description;
                    }
                    for (int j = 0; j < 10; j++)
                    {
                        GameObject gameObject = this._root.transform.Find("Panel/itemGroup/itemCell" + j).gameObject;
                        if (j < view.Count)
                        {
                            gameObject.CustomSetActive(true);
                            CUICommonSystem.SetItemCell(formScript, gameObject, view[j], true, false);
                            Transform transform = gameObject.transform.Find("HaveItemFlag");
                            transform.gameObject.CustomSetActive(false);
                            if (view[j].m_type == COM_ITEM_TYPE.COM_OBJTYPE_HERO)
                            {
                                CHeroItem item2          = view[j] as CHeroItem;
                                CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                                if ((masterRoleInfo != null) && masterRoleInfo.IsOwnHero(item2.m_heroData.dwCfgID))
                                {
                                    transform.gameObject.CustomSetActive(true);
                                }
                            }
                            else if (view[j].m_type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN)
                            {
                                CHeroSkin skin  = view[j] as CHeroSkin;
                                CRoleInfo info2 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo();

                                if ((info2 != null) && info2.IsHaveHeroSkin(skin.m_heroId, skin.m_skinId, false))
                                {
                                    transform.gameObject.CustomSetActive(true);
                                }
                            }
                        }
                        else
                        {
                            gameObject.CustomSetActive(false);
                        }
                    }
                    this._coinUsb = CUseableManager.CreateCoinUseable(coinType, 0);
                    if (this._coinUsb != null)
                    {
                        Utility.GetComponetInChild <Image>(this._root, "Panel/Cost/CoinType").SetSprite(CUIUtility.GetSpritePrefeb(this._coinUsb.GetIconPath(), false, false));
                    }
                }
                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Add, new CUIEventManager.OnUIEventHandler(this.OnClickAdd));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Dec, new CUIEventManager.OnUIEventHandler(this.OnClickDec));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Max, new CUIEventManager.OnUIEventHandler(this.OnClickMax));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Confirm, new CUIEventManager.OnUIEventHandler(this.OnClickConfirm));

                Singleton <CUIEventManager> .GetInstance().AddUIEventListener(enUIEventID.BuyPick_Cancel, new CUIEventManager.OnUIEventHandler(this.OnClickCancel));

                this.ValidateDynamic();
            }
        }