local UIAwakenActivity = UIViewClass() local hero_awaken_info_pb = require 'Proto.hero_awaken_info_pb' local IMG_TITLE_PATH = "UI_AwakenActivity/jxsl_msz_02.png" local IMG_CHALLENGE_PATH = "UI_AwakenActivity/jxsl_msz_01.png" local DEFAULT_PLAYER_NAME_IDS = Const_IDS.IDS_GVGFight_Rank_Info2 local BOSS_HERO_ID = 46 local BOSS_MODEL_ID = 10710 function UIAwakenActivity:OnOpened(context) self:RegistSystemEvent(EventID.UI_AwakenActivity_UpdateAwakenActivityInfo, self.Init) self:RegistSystemEvent(EventID.UI_AwakenActivity_AwakenChallengeRewardResp, self.RefreshReward) self:RegistSystemEvent(EventID.UI_HeroAwaken_GetPlayerInfo, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_AwakenActivity_OpenAwakenActivityPanelResp, self.RefreshPanel) UTL.Item.SetLocalizationImage(self.loc_Title, self.img_Title, IMG_TITLE_PATH) UIUtils.SetLabelText(self.txt_Title, Const_IDS["IDS_HeroAwaken_ActivityName"]) UTL.Item.SetLocalizationImage(self.loc_Challenge, self.img_Challenge, IMG_CHALLENGE_PATH) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_HeroAwaken_ActivityName"]) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.newBossModel) UTL.UIRender.Create3DSceneTrans(self.modelComponentDataHandle, CTL.HeroDetail.AWAKEN_SCENE_PATH, 2000, 0, 2000, 0, 165, 0, UTL.UIRender.LayerActiveType.HeroShow) UTL.UIRender.SetSceneTransPosition(self.modelComponentDataHandle, 2000, -55, 2000) UTL.UIRender.SetSceneTransRotation(self.modelComponentDataHandle, 0) UIUtils.SetActive(self.group_TipsPanel.gameObject, false) self:Init() end function UIAwakenActivity:Init() self.playerInfoMap = {} self.startChallengeNameMap = {} self.currIndex = -1 self.activityInfoList = MDL.AwakenActivity.GetAwakenActivityInfoList() if #self.activityInfoList == 0 then self:CloseView(true) elseif #self.activityInfoList == 1 then UIUtils.SetActive(self.group_Tab, false) self:SelectHero(1) else UIUtils.SetActive(self.group_Tab, true) local index = 0 local heroId = self.context and self.context.heroId self.LoopScroll_Tab:ClearCells() for i, v in ipairs(self.activityInfoList) do self.LoopScroll_Tab:AddData(v, 0) if v.heroId == heroId then index = i - 1 end end self.LoopScroll_Tab:SelectIndex(index) end end function UIAwakenActivity:SelectHero(index) if self.currIndex == index then return end self.currIndex = index local activityInfo = self.activityInfoList[index] if activityInfo.curStage == hero_awaken_info_pb.Showing then MDL.AwakenActivity.PullPlayerInfoFromServer(activityInfo.heroId) end self:RefreshPanel() end function UIAwakenActivity:RefreshPanel() self:DisplayModel() self:RefreshLeftInfo() self:RefreshRightBottom() end function UIAwakenActivity:RefreshReward() self:RefreshPanel() if #self.activityInfoList > 1 then self.LoopScroll_Tab:RefreshCells() end end function UIAwakenActivity:RefreshRemainTime() local activityInfo = self.activityInfoList[self.currIndex] local time = UTL.Time.FormatTimeForDayOrClock(activityInfo.fightEndTime - UTL.Time.GetServerTimestamp()) UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_LastTime"], time)) end function UIAwakenActivity:RefreshLeftInfo() self:StopRepeatFunc(self.RefreshRemainTime, 1) local activityInfo = self.activityInfoList[self.currIndex] local heroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(activityInfo.heroId).NameIDS]) UIUtils.SetLabel(self.txt_ZuociTrail, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_ActivityName2, heroName)) local firstInfo = MDL.AwakenActivity.GetRank1PlayerInfo(activityInfo.heroId) if firstInfo then UIUtils.SetActive(self.group_RankFirst, true) CTL.Character.SetPortraitAndFrame(self.UIHeroHead, firstInfo.portraitId, firstInfo.frameId) UIUtils.SetLabel(self.txt_Name, firstInfo.name) UIUtils.SetLabel(self.txt_DamageValue, firstInfo.param1) else UIUtils.SetActive(self.group_RankFirst, false) end if activityInfo.curStage == hero_awaken_info_pb.Fighting then self:RefreshRemainTime() self:StartRepeatFunc(self.RefreshRemainTime, 1) if string.isNilOrEmpty(activityInfo.startChallengeAcid) then UIUtils.SetLabel(self.txt_Description, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_ActivityTips3, heroName)) else local playerInfo = MDL.HeroAwaken.TryGetPlayerInfo(activityInfo.startChallengeAcid) UIUtils.SetLabel(self.txt_Description, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_ActivityTips1, playerInfo and playerInfo.name or UIUtils.GetLocalizedTxt(DEFAULT_PLAYER_NAME_IDS), heroName)) end elseif activityInfo.curStage == hero_awaken_info_pb.Showing then UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_DefeatedTime"], os.date(UTL.Time.FormatDateEnum.YMDHMS, activityInfo.fightEndTime))) if firstInfo then UIUtils.SetLabel(self.txt_Description, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_ActivityTips2, firstInfo.name, firstInfo.name)) else UIUtils.SetLabelText(self.txt_Description, Const_IDS.IDS_HeroAwaken_ActivityTips4) end end local rankRewardID = DataSheetManager.HeroAwakenRankReward:GetDataByHeroID_Rank(activityInfo.heroId, 1).RankRewardID local rewardData = DataSheetManager.HeroAwakenRankRewardRepeat:GetDataByID(rankRewardID).Item_Table self.scroll_Reward:ReloadAll(rewardData) end function UIAwakenActivity:RefreshRightBottom() local activityInfo = self.activityInfoList[self.currIndex] local heroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(activityInfo.heroId).NameIDS]) if activityInfo.curStage == hero_awaken_info_pb.Fighting then UIUtils.SetLabel(self.txt_Tips, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_AwakenCondition1, heroName)) self.group_Entry:SetState(0) self.btn_Challenge:SetRedPoint(CTL.AwakenActivity.CheckChallengeRed(activityInfo.heroId)) local weaponName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(activityInfo.heroId).MagicWeaponName]) local levelCondition = "%s+15" UIUtils.SetLabel(self.txt_AwakenPrecondition, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_EnterCondition, heroName, string.format(levelCondition, heroName), string.format(levelCondition, weaponName))) elseif activityInfo.curStage == hero_awaken_info_pb.Showing then self.group_Entry:SetState(activityInfo.hasChallengeReward and 2 or 1) -- 1:可领取,2:已领取 if not activityInfo.hasChallengeReward then self.group_Entry:SetState(1) self.btn_Receive:SetRedPoint(true) else if MDL.HeroAwaken.GetIsHeroAwaken(activityInfo.heroId) or CTL.HeroAwaken.IsEnableAwake(activityInfo.heroId) then self.group_Entry:SetState(3) else self.group_Entry:SetState(2) end end end end function UIAwakenActivity:DisplayModel() UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) local activityInfo = self.activityInfoList[self.currIndex] local playerShowInfo = MDL.AwakenActivity.GetPlayerShowInfo(activityInfo.heroId) if playerShowInfo then UIUtils.SetActive(self.txt_PlayerName, true) UIUtils.SetLabel(self.txt_PlayerName, playerShowInfo.name) UTL.UIRender.CreateOtherPlayerModel(self.modelComponentDataHandle, playerShowInfo, playerShowInfo.WeaponAppearanceID, 0, playerShowInfo.IsActiveMagicWeapon, true, -0.05) else UIUtils.SetActive(self.txt_PlayerName, false) local modelPath, equipTable, modelScale, lightPath, heroEffectPath, heroLightEffects = UTL.UIRender.LoadShowHero(BOSS_HERO_ID, true, nil, false) UTL.UIRender.CreatePlayerModel(self.modelComponentDataHandle, BOSS_HERO_ID, modelPath, lightPath, true, "", BOSS_HERO_ID) end UTL.UIRender.SetEntityPos(self.modelComponentDataHandle, -1.2, 0, -0.3) UTL.UIRender.RotateEntity(self.modelComponentDataHandle, 10) end function UIAwakenActivity:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_Tab then UTL.Item.SetHeroIconByHeroId(cellTable.img_HeroHead, data.heroId) cellTable.btn_Hero:SetRedPoint(CTL.AwakenActivity.CheckChallengeRed(data.heroId) or CTL.AwakenActivity.CheckRewardRed(data.heroId)) elseif scrollRect == self.scroll_Reward then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum, false) end end function UIAwakenActivity:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.LoopScroll_Tab then self:SelectHero(index + 1) elseif scrollRect == self.scroll_Reward then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end function UIAwakenActivity:OnButtonClicked(comp) if comp == self.btn_Challenge then local activityInfo = self.activityInfoList[self.currIndex] if not CTL.HeroAwaken.IsEnableAwake(activityInfo.heroId) then local heroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(activityInfo.heroId).NameIDS]) CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroAwaken_AwakenCondition1"], heroName) return end if activityInfo.curStage == hero_awaken_info_pb.Fighting then MDL.AwakenActivity.EnterLevelReq(activityInfo.heroId) end elseif comp == self.btn_Receive then local activityInfo = self.activityInfoList[self.currIndex] MDL.AwakenActivity.AwakenChallengeRewardReq(activityInfo.heroId) elseif comp == self.btn_Reward then local activityInfo = self.activityInfoList[self.currIndex] UIManager.OpenView(Const_UI_Lua.UIEnum.UIAwakenActivityRewardMain, {heroId = activityInfo.heroId}) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.AwakenActivity }) elseif comp == self.group_TipsPanel then UIUtils.SetActive(self.group_TipsPanel.gameObject, false) elseif comp == self.brn_AwakenPrecondition then UIUtils.SetActive(self.group_TipsPanel.gameObject, true) elseif comp == self.btn_Go then local activityInfo = self.activityInfoList[self.currIndex] MDL.HeroSelect.curSelectHeroID = activityInfo.heroId UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroShowPanel, { subViewName = MDL.HeroSelect.ToggleViewNameList.Awaken }) end end function UIAwakenActivity:OnClosed() CTL.AwakenActivity.RecordChallengeRed() MDL.AwakenActivity.ClearPlayerInfo() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end return UIAwakenActivity