local UIGoldenHeroBossPurchase = UIViewClass() local SingleTime = 1 local MultiTimes = 5 local HighStarNum = 5 function UIGoldenHeroBossPurchase:OnOpened(context) self.activityId = context.activityId self.heroType = context.heroType self.activityType = MDL.OperationActivity.ActivityType.GoldenHero self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_BuyCountRefresh, self.RefreshInfo) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshInfo) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_GoldHeroActivity_SynergyBoss_BossBuy_Title) self.modeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType) self.isLimit = self.modeData.BossBuyLimitNum ~= 0 CTL.GoldenHeroMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, energyType = MDL.GoldenHeroMain.EnergyType.Boss, title = "IDS_DrawCard_Title_QuickBuy"}) self:RefreshInfo() self:StartRepeatFunc(self.CloseAndHint, UTL.Time.GetServerIntervalTimeByTimeId(self.modeData.DailyRankEndTime), 1) end function UIGoldenHeroBossPurchase:CloseAndHint() CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_NewHint_2) self:CloseView() end function UIGoldenHeroBossPurchase:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGoldenHeroBossPurchase:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_One then self:OnClickBuy(SingleTime) elseif comp == self.btn_Five then self:OnClickBuy(MultiTimes) end end function UIGoldenHeroBossPurchase:OnClickBuy(times) if not self.isLimit or self.leftTime >= times then if UTL.Item.GetItemStockCount(self.modeData.BossBuyItem) >= (self.modeData.BossBuyItemNum * times) then MDL.GoldenHeroBoss.GoldHeroDailyBuyBossReq(self.activityId, times) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_BossBuy_Hint_4) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_BossBuy_Hint_3) end end function UIGoldenHeroBossPurchase:RefreshInfo() self.leftTime = math.max(0, self.modeData.BossBuyLimitNum - MDL.GoldenHeroBoss.GetBossBuyCount(self.activityId)) UIUtils.SetActive(self.txt_LeftTimes, self.isLimit) if self.isLimit then self.txt_LeftTimes.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_BossBuy_Hint_2) .. (self.leftTime == 0 and UTL.Color.FormatRedColor(self.leftTime) or self.leftTime) end self:SetButtonInfo(self.btn_One, self.group_One, SingleTime) self:SetButtonInfo(self.btn_Five, self.group_Five, MultiTimes) self:RefreshBossGroup() end function UIGoldenHeroBossPurchase:RefreshBossGroup() local bossList = {} for i, v in DataSheetManager.GoldHeroSynergyBossData[self.heroType]:GetEnumerator() do if v.BossStar == HighStarNum then table.insert(bossList, v) end end for i, v in ipairs(self.group_Boss) do local bossData = bossList[i] if bossData then UIUtils.SetActive(v.gameObject, true) UIUtils.SetLabelText(v.txt_BossName, Const_IDS[bossData.BossName]) UIUtils.SetImageByAssetBundle(v.img_Boss, bossData.Picture) else UIUtils.SetActive(v.gameObject, false) end end end function UIGoldenHeroBossPurchase:SetButtonInfo(btn, comp, times) btn:SetText(string.FormatByIdsKey("IDS_GoldHeroActivity_SynergyBoss_BossBuy_Button", (not self.isLimit or self.leftTime >= times) and times or UTL.Color.FormatRedColor(times))) UTL.Item.SetCurrencyImageIcon(comp.img_Icon, self.modeData.BossBuyItem) local costNum = self.modeData.BossBuyItemNum * times comp.txt_Num.text = UTL.Item.GetItemStockCount(self.modeData.BossBuyItem) >= costNum and costNum or UTL.Color.FormatRedColor(costNum) end return UIGoldenHeroBossPurchase