local UIGoldenHeroMain = UIViewClass() local StringFormat = string.format function UIGoldenHeroMain:OnOpened(context) self.heroType = context.heroType self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.GoldenHero self.modeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType) self:SetButtonTextAndIcon() UIUtils.SetLocalizationImage(self.img_BossNew, "zr_msz_new.png") self.img_BossNew:SetNativeSize() UIUtils.SetLocalizationImage(self.img_New, "zr_msz_new.png") self.img_New:SetNativeSize() self:RegistSystemEvent(EventID.UI_DirectGift_GiftInfoUpdate, self.RefreshGiftNewImg) self:RegistSystemEvent(EventID.UI_DirectGift_NewGiftInfoChange, self.RefreshGiftNewImg) self:RegistSystemEvent(EventID.UI_OperationActivity_InfoChanged, self.RefreshTimeAndButton) self:RegistSystemEvent(EventID.UI_GoldenHero_ActivityEnd, self.RefreshTimeAndButton) self:RegistSystemEvent(EventID.UI_GoldenHero_RefreshCurrency, self.RefreshGoldenHeroStorySweepHint) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) local timeText = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroActivity_TimeHint2) self.txt_CountDown:SetDHMSStr(StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime1)), StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime2)), StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime3)), StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime4))) UIUtils.SetLabelText(self.lab_Time, Const_IDS.IDS_GoldHeroActivity_TimeHint1) self.isActive = MDL.GoldenHeroMain.IsActivityInFuncTime(self.activityId) self.levelType = MDL.GoldenHeroMain.GetLevelTypeByActivityId(self.activityId) --关卡系统是秘闻or轶事 CTL.GoldenHeroMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, title = "IDS_DrawCard_Title_QuickBuy"}) --红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].Story, self.RefreshGoldenHeroStoryRp) -- 秘闻入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].Anecdote, self.RefreshGoldenHeroStoryRp) -- 轶事入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].Boss, self.RefreshGoldenHeroBossRp) -- 协同入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].BossNewOne, self.RefreshGoldenHeroBossRp) -- 协同入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].Fame, self.RefreshGoldenHeroFameRp) -- 声明入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].DrawCardAvailable, self.RefreshGoldenHeroDrawCardRp) -- 限时抽卡入口红点 if self.levelType == MDL.GoldenHeroMain.LevelType.Story then self:RefreshGoldenHeroStoryRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Story)) -- 秘闻入口红点 else self:RefreshGoldenHeroStoryRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Anecdote)) -- 轶事入口红点 if self.modeData.TryLevelID and self.modeData.TryLevelID > 0 then UIUtils.SetActive(self.group_Try, true) self:RefreshHeroTryRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].HeroTryFirstPass)) end end self:RefreshGoldenHeroBossRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Boss)) -- 协同入口红点 self:RefreshGoldenHeroFameRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Fame)) -- 声明入口红点 self:RefreshGoldenHeroDrawCardRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].DrawCardAvailable)) -- 限时抽卡入口红点 self:RefreshTimeAndButton() self:RefreshGiftNewImg() if self.heroModel then self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.heroModel) end self:SetPortrait() CTL.GoldenHeroMain.SetIsOpenedActivity(self.activityId, true) UIManager.ActiveUIModle(false, "UIGoldenHeroMain") end function UIGoldenHeroMain:RefreshGiftNewImg() local isNew = CTL.DirectGift.IsActivityShowNew(self.activityId) UIUtils.SetActive(self.img_New, isNew) if not isNew then self.btn_Gift:SetRedPoint(MDL.RedPoint.GetNodeStateByLogicParams(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].DirectGiftFree)) end end function UIGoldenHeroMain:SetButtonTextAndIcon() --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[self.modeData.TownName]) if Localization.IsAllChinese() then UIUtils.SetLocalizationImage(self.img_Story, self.modeData.LevelIcon) --秘闻 UIUtils.SetLocalizationImage(self.img_Boss, self.modeData.BossIcon) --讨伐 UIUtils.SetLocalizationImage(self.img_Fame, self.modeData.TaskIcon) --声名鹊起 UIUtils.SetLocalizationImage(self.img_Shop, self.modeData.StoreIcon) --商店 else UIUtils.SetLabelText(self.lab_Story, Const_IDS[self.modeData.LevelName]) --秘闻 UIUtils.SetLabelText(self.lab_Boss, Const_IDS[self.modeData.BossName]) --讨伐 UIUtils.SetLabelText(self.lab_Fame, Const_IDS[self.modeData.TaskName]) --声名鹊起 UIUtils.SetLabelText(self.lab_Shop, Const_IDS[self.modeData.StoreName]) --商店 end end function UIGoldenHeroMain:OnClosed() UIManager.ActiveUIModle(true, "UIGoldenHeroMain") UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) if self.AnyPortraitObj then TK2API.DiscardInstance(self.AnyPortraitPath, self.AnyPortraitObj) self.AnyPortraitObj = nil end end function UIGoldenHeroMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGoldenHeroMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) return elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() return end local info = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) if not info or not CTL.OperationActivity.IsOperationActivityOpen(info) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_TimeHint3) return end if comp == self.btn_Shop or comp == self.btn_Shop_Loc then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroStore, {activityId = self.activityId}) elseif comp == self.btn_Fame or comp == self.btn_Fame_Loc then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroFame, {heroType = self.heroType, activityId = self.activityId}) elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GoldHeroMain, params = self.infoParams}) elseif comp == self.btn_Gift then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.OperationActivity.UIOACommonDirectGiftPanel, {activityType = self.activityType, activityId = self.activityId}) elseif comp == self.btn_Draw then CTL.GoldenHeroMain.OpenDrawCardMainPanel(self.activityId) elseif comp == self.btn_Try then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroTry, {heroType = self.heroType, activityId = self.activityId}) else if not self.isActive then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_TimeHint3) return end if comp == self.btn_Story or comp == self.btn_Story_Loc then if self.levelType == MDL.GoldenHeroMain.LevelType.Story then local taskID = 0 for k, v in ipairs(MDL.GoldenHeroStory.GetTaskIDListByGoldenHeroID(self.heroType)) do local goldHeroActivityTaskInfo = DataSheetManager.GoldHeroActivityTask:GetDataByTaskID(v) local taskState = MDL.GoldenHeroStory.GetTaskStateByActivityID_HeroType_TaskFatherID(self.activityId, self.heroType, goldHeroActivityTaskInfo.TaskID) if k == 1 then taskID = goldHeroActivityTaskInfo.TaskID end if taskState == MDL.GoldenHeroStory.Enum_TaskState.Doing then taskID = goldHeroActivityTaskInfo.TaskID end end UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroStory, {heroType = self.heroType, activityId = self.activityId, taskId = taskID}) elseif self.levelType == MDL.GoldenHeroMain.LevelType.Anecdote then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroAnecdote, {heroType = self.heroType, activityId = self.activityId}) end elseif comp == self.btn_Boss or comp == self.btn_Boss_Loc then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, {heroType = self.heroType, activityId = self.activityId}) end end end function UIGoldenHeroMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UIGoldenHeroMain:RefreshTimeAndButton() self:RefreshButtonState(self.isActive) UIUtils.SetActive(self.lab_Time, self.isActive) UIUtils.SetActive(self.txt_Time, self.isActive) local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) self.infoParams = {} if activityInfo then if self.isActive then local startTime = os.date(UTL.Time.FormatDateEnum.YMDHM, activityInfo.startTime) local endFuncTime = os.date(UTL.Time.FormatDateEnum.YMDHM, MDL.GoldenHeroMain.GetEndFuncTime(self.activityId)) self.txt_Time.text = " "..startTime .. " - " .. endFuncTime self.txt_CountDown:EndTimer() else local leftTimes = activityInfo.endTime - UTL.Time.GetServerTimestamp() self.txt_CountDown:ResetAndBeginCustomTimer(false, leftTimes, 0, nil) end --获取说明按钮中的参数 local startTime = os.date(UTL.Time.FormatDateEnum.YMDHM, activityInfo.startTime) local endFuncTime = os.date(UTL.Time.FormatDateEnum.YMDHM, MDL.GoldenHeroMain.GetEndFuncTime(self.activityId)) local endTime = os.date(UTL.Time.FormatDateEnum.YMDHM, activityInfo.endTime) self.infoParams[1] = startTime .. " - " .. endFuncTime self.infoParams[2] = endFuncTime .. " - " .. endTime self.infoParams[3] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.LevelName]) self.infoParams[4] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.BossName]) self.infoParams[5] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.TaskName]) self.infoParams[6] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.StoreName]) end end function UIGoldenHeroMain:RefreshButtonState(state) self:RefreshSingleButtonState(state, self.state_Story, self.btn_Story) self:RefreshSingleButtonState(state, self.state_Boss, self.btn_Boss) UIUtils.SetActive(self.group_StoryEffect, state or false) UIUtils.SetActive(self.group_BossEffect, state or false) self:RefreshSingleButtonState(state, self.state_Story, self.btn_Story_Loc) self:RefreshSingleButtonState(state, self.state_Boss, self.btn_Boss_Loc) UIUtils.SetActive(self.group_StoryEffect_Loc, state or false) UIUtils.SetActive(self.group_BossEffect_Loc, state or false) if self.heroType == MDL.GoldenHeroMain.HeroType.SSX then UIUtils.SetActive(self.group_GiftEffect, state or false) end end function UIGoldenHeroMain:RefreshSingleButtonState(active, uiState, comp) uiState:SetState(active and 0 or 1) UIUtils.SetComponentGray(comp, not active) end --region *********************** 红点 ******************************** function UIGoldenHeroMain:SetGroupSweepActive() local timeId = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).DailyRankEndTime if UTL.Time.IsServerInOpeningTime(1, timeId) then UIUtils.SetActive(self.group_Sweep, self.isActive) else UIUtils.SetActive(self.group_Sweep, false) end end ---@public 秘闻入口可扫荡显示 function UIGoldenHeroMain:RefreshGoldenHeroStorySweepHint() if self.levelType == MDL.GoldenHeroMain.LevelType.Story then if MDL.GoldenHeroStory.GetSweepRedPointByActivityID(self.activityId) then self:SetGroupSweepActive() self.btn_Story:SetRedPoint(false) self.btn_Story_Loc:SetRedPoint(false) else local active = MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Story) UIUtils.SetActive(self.group_Sweep, false) self.btn_Story:SetRedPoint(active and self.isActive) self.btn_Story_Loc:SetRedPoint(active and self.isActive) end elseif self.levelType == MDL.GoldenHeroMain.LevelType.Anecdote then if CTL.GoldenHeroAnecdote.IsActivityHasLevelCanSweep(self.activityId) then self:SetGroupSweepActive() self.btn_Story:SetRedPoint(false) self.btn_Story_Loc:SetRedPoint(false) else local active = MDL.RedPoint.GetNodeStateByMultiKey(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].Anecdote) UIUtils.SetActive(self.group_Sweep, false) self.btn_Story:SetRedPoint(active and self.isActive) self.btn_Story_Loc:SetRedPoint(active and self.isActive) end end end ---@public 秘闻入口红点 function UIGoldenHeroMain:RefreshGoldenHeroStoryRp(active) if self.levelType == MDL.GoldenHeroMain.LevelType.Story then if MDL.GoldenHeroStory.GetSweepRedPointByActivityID(self.activityId) then self:SetGroupSweepActive() self.btn_Story:SetRedPoint(false) self.btn_Story_Loc:SetRedPoint(false) else UIUtils.SetActive(self.group_Sweep, false) self.btn_Story:SetRedPoint(active and self.isActive) self.btn_Story_Loc:SetRedPoint(active and self.isActive) end elseif self.levelType == MDL.GoldenHeroMain.LevelType.Anecdote then if CTL.GoldenHeroAnecdote.IsActivityHasLevelCanSweep(self.activityId) then self:SetGroupSweepActive() self.btn_Story:SetRedPoint(false) self.btn_Story_Loc:SetRedPoint(false) else UIUtils.SetActive(self.group_Sweep, false) self.btn_Story:SetRedPoint(active and self.isActive) self.btn_Story_Loc:SetRedPoint(active and self.isActive) end end end ---@public 协同讨伐入口红点 function UIGoldenHeroMain:RefreshGoldenHeroBossRp(active) if CTL.GoldenHeroBoss.CheckIfHasNewBoss(self.activityId) then UIUtils.SetActive(self.img_BossNew, true and self.isActive) self.btn_Boss:SetRedPoint(false) self.btn_Boss_Loc:SetRedPoint(false) else UIUtils.SetActive(self.img_BossNew, false) self.btn_Boss:SetRedPoint(active and self.isActive) self.btn_Boss_Loc:SetRedPoint(active and self.isActive) end end ---@public 声名鹊起入口红点 function UIGoldenHeroMain:RefreshGoldenHeroFameRp(active) self.btn_Fame:SetRedPoint(active) self.btn_Fame_Loc:SetRedPoint(active) end ---@public 限时抽卡入口红点 function UIGoldenHeroMain:RefreshGoldenHeroDrawCardRp(active) self.btn_Draw:SetRedPoint(active) end ---@public 武将试用入口红点 function UIGoldenHeroMain:RefreshHeroTryRp(active) if self.btn_Try then if self.modeData.TryLevelID and self.modeData.TryLevelID > 0 then self.btn_Try:SetRedPoint(active) end end end --endregion *********************** 红点 ******************************** -- 动态立绘 function UIGoldenHeroMain:SetPortrait() local mainPrefabMode = self.modeData.MainPrefabMode local MainViewPrefabModeEnum = CTL.GoldenHeroMain.MainViewPrefabMode if mainPrefabMode == MainViewPrefabModeEnum.AnyPortrait then self.AnyPortraitPath = self.modeData.MainPrefabHero self.AnyPortraitObj = CTL.GoldenHeroMain.ShowAnyPortrait(self.modeData, self.group_2DDynamicBG.transform, self) elseif mainPrefabMode == MainViewPrefabModeEnum.OrthoGraphic then CTL.GoldenHeroMain.ShowModelWithOrthoGraphic(self.modelComponentDataHandle, self.modeData) elseif mainPrefabMode == MainViewPrefabModeEnum.RealBgScene then CTL.GoldenHeroMain.ShowReal3DModel(self.modelComponentDataHandle, self.modeData) end UIUtils.SetActive(self.bg_Bottom, mainPrefabMode ~= MainViewPrefabModeEnum.RealBgScene and mainPrefabMode ~= MainViewPrefabModeEnum.OrthoGraphic) end return UIGoldenHeroMain