public BuyPickDialog(bool isGift, COM_ITEM_TYPE type, uint id, RES_SHOPBUY_COINTYPE coinType, float 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._bHeroSkinGift = false; this._bDynamicCorrectPrice = false; this._heroSkinGiftCost = 0; 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._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 item = new CItem(0L, id, 0, 0); uint key = (uint)item.m_itemData.EftParam[0]; ResRandomRewardStore dataByKey = GameDataMgr.randomRewardDB.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; } uint num3 = 0; int num4 = 0; if (this._usb.m_type == COM_ITEM_TYPE.COM_OBJTYPE_ITEMPROP) { CItem item2 = (CItem)this._usb; if (((item2 != null) && (item2.m_itemData != null)) && (item2.m_itemData.bType == 4)) { this._bDynamicCorrectPrice = item2.m_itemData.EftParam[3] > 0f; } } 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) { this._bHeroSkinGift = true; CHeroItem item3 = view[j] as CHeroItem; CRoleInfo masterRoleInfo = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo(); if ((masterRoleInfo != null) && masterRoleInfo.IsOwnHero(item3.m_heroData.dwCfgID)) { num3 += CHeroInfo.GetHeroCost(item3.m_heroData.dwCfgID, coinType); num4++; transform.gameObject.CustomSetActive(true); } } else if (view[j].m_type == COM_ITEM_TYPE.COM_OBJTYPE_HEROSKIN) { this._bHeroSkinGift = true; CHeroSkin skin = view[j] as CHeroSkin; CRoleInfo info2 = Singleton <CRoleInfoManager> .GetInstance().GetMasterRoleInfo(); if ((info2 != null) && info2.IsHaveHeroSkin(skin.m_heroId, skin.m_skinId, false)) { num3 += CSkinInfo.GetHeroSkinCost(skin.m_heroId, skin.m_skinId, coinType); num4++; 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)); } Text componetInChild = Utility.GetComponetInChild <Text>(this._root, "Panel/costDescText"); componetInChild.text = string.Empty; if (this._bHeroSkinGift && this._bDynamicCorrectPrice) { uint buyPrice = this._usb.GetBuyPrice(coinType); Button btn = Utility.GetComponetInChild <Button>(this._root, "Panel/Button_Sale"); if (num4 >= view.Count) { CUICommonSystem.SetButtonEnableWithShader(btn, false, true); componetInChild.text = Singleton <CTextManager> .GetInstance().GetText("Gift_Can_Not_Buy_Tip"); this._heroSkinGiftCost = 0; } else { CUICommonSystem.SetButtonEnableWithShader(btn, true, true); componetInChild.text = Singleton <CTextManager> .GetInstance().GetText("Gift_Own_Hero_Skin_Tip"); uint num7 = CMallFactoryShopController.ShopProduct.SConvertWithRealDiscount(buyPrice - num3, this._realDiscount); if ((buyPrice >= num3) && (num7 >= (buyPrice / 10))) { this._heroSkinGiftCost = num7; } else { this._heroSkinGiftCost = buyPrice / 10; } } if (this._callContext != null) { this._callContext.m_bChangeGiftPrice = true; this._callContext.m_newGiftPrice = this._heroSkinGiftCost; } } } 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(); } }
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(); } }