--[[ 金将返场抽卡界面,日服专属 ]] local UIGoldHeroReprint = UIViewClass() local GiveItemId = DataSheetManager.ConstData:GetDataByID("LimitDrawCardGiveItemId").IntValue local HeroHalfCardImagePath = ConstAssetPathConfig.HeroPicPath function UIGoldHeroReprint:OnOpened(context) self.activityType = MDL.OperationActivity.ActivityType.GoldHeroReprint self.activityTypeInfo = MDL.GoldHeroReprint.GetGoldHeroReprintActivityInfo() self.activityId = self.activityTypeInfo.activityId self.currency_Info:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICurrencyPanel), {viewClassPath = self.__viewClassPath, currencyTypeIds = CTL.Currency.GetCurrentTypeIds(self.__viewClassPath), param = {activityType = self.activityType, activityId = self.activityId}}) local goldHeroReprintBackGround = MDL.OperationActivity.ActivityBaseData[self.activityType]:GetDataByActivityID(self.activityId) self.drawCardPoolId = goldHeroReprintBackGround.DrawCardPoolID local goldHeroReprintShowHero = MDL.OperationActivity.GoldHeroReprintShowHero:GetDataByActivityID_OrderID(self.activityId, 1) self.upHeroID = goldHeroReprintShowHero.HeroShowID self.toggle_Skip.isOn = CTL.ActivityGacha.IsSkipAnim(self.activityType) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RegistSystemEvent(EventID.UI_OperationActivity_InfoChanged, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_GachaLimit_Refresh, self.RefreshPanel) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_JP_GoldHeroReprint_Title"]) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self:InitGoldHeroReprintView() -- 打开界面时停止自动寻路 防止抽卡TimeLine和剧情重叠 NotSyncBattleSetter.StopAutoFightPathInTown() --停止现在的寻路 CTL.ActivityGacha.TryReOpenDrawCardResult() end function UIGoldHeroReprint:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIGoldHeroReprint:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Exchange then -- 兑换商城 UIManager.OpenView(Const_UI_Lua.UIEnum.OperationActivity.UIOACommonStoreBase, {activityType = self.activityType, activityId = self.activityId}, "DrawCard/TimeLimit/UIGoldHeroReprintStore") elseif comp == self.btn_Info or comp == self.btn_ProbabilityInfo then -- 卡池详情 UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaSummary, {drawCardType = CTL.DrawCard.DrawCardType.Limit, activityId = self.activityId, activityType = self.activityType, drawCardPoolId = self.drawCardPoolId}) elseif comp == self.btn_HeroInfo then -- 打开武将界面 MDL.HeroSelect.curSelectHeroID = self.upHeroID UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroShowPanel) elseif comp == self.btn_Gift then -- 特惠礼包 UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldHeroReprintRecharge, {activityType = self.activityType, activityId = self.activityId}) elseif comp == self.btn_Gacha1 then self:DrawCardProcess(1) elseif comp == self.btn_Gacha10 then self:DrawCardProcess(10) elseif comp == self.obj_Profession.btn_Profession then UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroFilterView, {canJump = false, heroId = self.upHeroID, isCountry = false, heroFilterPos = self.obj_HeroFilterPos}) end end function UIGoldHeroReprint:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGoldHeroReprint:InitGoldHeroReprintView() self:ShowHeroList() self:ShowUpHeroInfo() self.isActive = MDL.GoldHeroReprint.IsActivityInFuncTime() UIUtils.SetActive(self.txt_Time, self.isActive) if self.activityTypeInfo then if self.isActive then local startTime = os.date(UTL.Time.FormatDateEnum.YMDHM, self.activityTypeInfo.startTime) local endFuncTime = os.date(UTL.Time.FormatDateEnum.YMDHM, self.activityTypeInfo.endTime) self.txt_Time.text = " "..startTime .. "-" .. endFuncTime end end self:RefreshPanel() end -- 设置返场武将立绘 function UIGoldHeroReprint:ShowHeroList() local heroCount = MDL.OperationActivity.GoldHeroReprintShowHero:GetDataLengthByActivityID(self.activityId) local isTwoHero = heroCount == 2 -- 本期是否只有两个武将 self.state_Pos:SetState(isTwoHero and 1 or 2) -- 1号位武将立绘,默认1号是UP local heroData = DataSheetManager.HeroNum:GetDataByID(MDL.OperationActivity.GoldHeroReprintShowHero:GetDataByActivityID_OrderID(self.activityId, 1).HeroShowID) UIUtils.SetSpritePivotPos(self.img_FirstIMG, string.format(HeroHalfCardImagePath, heroData.JPHalfCardImage), 1.2) -- 2号位武将立绘 local heroData = DataSheetManager.HeroNum:GetDataByID(MDL.OperationActivity.GoldHeroReprintShowHero:GetDataByActivityID_OrderID(self.activityId, 2).HeroShowID) UIUtils.SetSpritePivotPos(self.img_SecondIMG, string.format(HeroHalfCardImagePath, heroData.JPHalfCardImage), 1.15) if not isTwoHero then -- 3号位武将立绘 local heroData = DataSheetManager.HeroNum:GetDataByID(MDL.OperationActivity.GoldHeroReprintShowHero:GetDataByActivityID_OrderID(self.activityId, 3).HeroShowID) UIUtils.SetSpritePivotPos(self.img_ThirdIMG, string.format(HeroHalfCardImagePath, heroData.JPHalfCardImage), 1.1) end end -- 设置Up武将信息 function UIGoldHeroReprint:ShowUpHeroInfo() local heroData = DataSheetManager.HeroNum:GetDataByID(self.upHeroID) local appearanceWearID = MDL.HeroSelect.GetAppearanceIDByHeroID(self.upHeroID) local appearanceData = nil if appearanceWearID > 0 then appearanceData = DataSheetManager.HeroAppearance:GetDataByID(appearanceWearID) end UIUtils.SetLocalizationImage(self.img_Name, "UI_HeroName/"..heroData.HeadImage..".png") UIUtils.SetLocalizationImage(self.img_Country, "country_"..heroData.Kingdom..".png") CTL.HeroSelect.SetHeroProfession(self.upHeroID, self.obj_Profession, true) -- 武将职业 CTL.HeroSelect.ShowCV(self.txt_CV, self.upHeroID) -- 武将配音 UIUtils.SetLabel(self.txt_Intelligence, (appearanceWearID > 0 and appearanceData.Intelligence > 0) and appearanceData.Intelligence or heroData.HeroIntelligence) --设置英雄资质 end function UIGoldHeroReprint:DrawCardProcess(drawCount) local itemId, countInBag = CTL.ActivityGacha.GetConsumeItemInfos(self.drawCardPoolId) if countInBag >= drawCount then --购买 MDL.ActivityGacha.RequestActivityDrawCard(self.activityId, self.activityType, drawCount) else if self.itemStoreID > 0 then --弹出购买道具框 local store = MDL.OperationActivity.StoreGoodsData:GetDataByID(self.itemStoreID) local currencyID = store.MoneyID local currencyCount = store.BuyPrice UIManager.OpenView(Const_UI_Lua.UIEnum.UIItemBuyPanel, {ItemId = itemId, ItemStoreId = self.itemStoreID, CurrencyId = currencyID, CurrencyCount = currencyCount}) else UIManager.OpenView(Const_UI_Lua.UIEnum.OperationActivity.UIGetActivityItemPanel, {itemId = itemId, activityId = self.activityId, activityType = self.activityType}) end end end function UIGoldHeroReprint:RefreshDrawCardConsumeItem() local itemId, countInBag = CTL.ActivityGacha.GetConsumeItemInfos(self.drawCardPoolId) UTL.Item.SetCurrencyImageIcon(self.img_Icon_One, itemId) UIUtils.SetLabel(self.txt_One, CTL.ActivityGacha.GetGachaCostNumShow(itemId, 1)) UTL.Item.SetCurrencyImageIcon(self.img_Icon_Ten, itemId) UIUtils.SetLabel(self.txt_Ten, CTL.ActivityGacha.GetGachaCostNumShow(itemId, 10)) self.btn_Gacha1:SetRedPoint(countInBag > 0) self.btn_Gacha10:SetRedPoint(countInBag >= 10) end function UIGoldHeroReprint:RefreshPanel() self.btn_Gift:SetRedPoint(MDL.GoldHeroReprint.CheckDirectGiftRedPoint()) -- 购买英雄帖增加招募次数 local drawData = DataSheetManager.DrawCardData:GetDataByID(self.drawCardPoolId) self.itemStoreID = drawData.ItemStoreID local consumeId = drawData.Item local consumeData = DataSheetManager.ItemData:GetDataByID(consumeId) local consumeName = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[consumeData.Name]), consumeData.Color) local giveItemData = DataSheetManager.ItemData:GetDataByID(GiveItemId) local giveItemName = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[giveItemData.Name]), giveItemData.Color) self.lab_GiveHint.text = string.FormatByIdsId(Const_IDS["IDS_LimitDrawCard_GiveHint"], consumeName, giveItemName) -- 招募X武将后,金将产出率是X local info = MDL.ActivityGacha.GetActivityDrawInfo(self.activityId) local drawCount = info.drawCount local stageDrawNum local probability for i, v in DataSheetManager.GoldHeroProbabilityShow:GetEnumerator() do if drawCount < v.RewardNum then probability = v.ProbabilityShow stageDrawNum = v.RewardNum break end end self.txt_ProbabilityTip.text = string.FormatByIdsKey("IDS_Japan_GoldHero_Tips2", drawCount, stageDrawNum, probability) -- 本期UP金将是XX UIUtils.SetLabel(self.lab_UPTips, string.FormatByIdsId(Const_IDS.IDS_JP_GoldHeroReprint_Tips, UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(self.upHeroID).NameIDS]))) self:RefreshDrawCardConsumeItem() end function UIGoldHeroReprint:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseSubViews() self:CloseView(true) end end end function UIGoldHeroReprint:CloseSubViews() UIManager.CloseView(Const_UI_Lua.UIEnum.UIGachaSummary) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGachaGetLimit) end function UIGoldHeroReprint:OnValueChanged(comp, value) if comp == self.toggle_Skip then CTL.ActivityGacha.SetSkipAnim(self.activityType, value) end end return UIGoldHeroReprint