local UIDemonGodMain = UIViewClass() local EventSystem = require('Event/EventSystem') local function StringFormat(text) return string.FormatByIdsId(Const_IDS.IDS_HonorOrder_DaoJiShi, text) end function UIDemonGodMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.UpdateRankList) self:RegistSystemEvent(EventID.UI_DemonGod_RefreshMainUI, self.RefreshDemonGodMain) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.DemonGold_Reward, self.UpdateRewardRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.DemonGold_Chanllengy, self.UpdateChallengeRed) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.newBossModel) MDL.DemonGod.IsRefreshCurRankList = true MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.DemonGod, {isPreRank = false}, CTL.Rank.SortType.MyServer) -- 界面标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_ActivityName_DemonGod) self:RefreshDemonGodMain() self:UpdateRewardRed() self:UpdateChallengeRed() end function UIDemonGodMain:UpdateRewardRed() self.event_Reward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.DemonGold_Reward)) end function UIDemonGodMain:UpdateChallengeRed() self.event_Challenge:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.DemonGold_Chanllengy)) end function UIDemonGodMain: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.UITemplateTitlePanel.btn_Info then local data = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.DemonGod).Time_Table[1] local _,timeStr = UTL.Time.GetDateDescAndTimeById(data.StartTime, data.EndTime) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.DemonGod, params = {timeStr,UTL.Time.GetDiffLocalStrById(1)}}) elseif comp == self.btn_DamageInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.DemonGod_Damage}) elseif comp == self.event_Rank then MDL.DemonGod.IsRefreshCurRankList = true MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.DemonGod, {isPreRank = false}, CTL.Rank.SortType.MyServer) UIManager.OpenView(Const_UI_Lua.UIEnum.UIDemonGodRank) elseif comp == self.event_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDemonGodRewardMain) elseif comp == self.event_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.JiangXing}) elseif comp == self.event_Challenge then -- 选将界面 if self.timerCount > 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDemonGodSelectOfficer, {freeLineupFuncType = MDL.FreeLineUp.FuncType.DemonGod, activityType = LuaConst.ActivityType.DemonGod}) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_End) end end end function UIDemonGodMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIDemonGodMain:OnCellInit(scrollRect, index, cellTable, data) cellTable.state_rankCell:SetState(data.index - 1) UIUtils.SetLabel(cellTable.txt_Rank, data.index) UIUtils.SetLabel(cellTable.txt_PlayerName, data.name) UIUtils.SetLabel(cellTable.txt_Score, data.param1) end function UIDemonGodMain:RefreshDemonGodMain() local demonGodInfo = MDL.DemonGod.GetDemonGodInfo() local curKingdom = demonGodInfo.country --显示国别改用服务器的数据 UIUtils.SetLabel(self.txt_Limit, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_10, UTL.Color.GetColorfulText(LuaConst.KingomColor[curKingdom], MDL.DemonGod.KingomIDS[curKingdom]))) self.state_countries:SetState(curKingdom - 1) -- 国别 self:UpdateBossDetail(demonGodInfo.curBossId) local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.DemonGod) if UTL.Time.IsServerInOpeningTime(activityData.Time_Table[1].StartTime, activityData.Time_Table[1].EndTime) then self.event_Challenge:SetGray(false) self.timerCount = UTL.Time.GetServerIntervalTimeByTimeId(activityData.Time_Table[1].EndTime) self.cdTimer:SetDHMSStr(StringFormat(UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPrivilege_BuffShow)), StringFormat("{0}:{1}:{2}"), StringFormat("{0}:{1}"), StringFormat("{0}:{1}")) self.cdTimer:ResetAndBeginCustomTimer(false, self.timerCount, 0, nil) self:StartRepeatFunc(self.UpdateTimerFunc, self.timerCount, 1) else self:UpdateTimerFunc() end end function UIDemonGodMain:UpdateBossDetail(curBossId) local bossData = DataSheetManager.DemonGodBoss:GetDataByID(curBossId) local showData = bossData.HeroShow_Table --可能不止一个boss,目前就俩 -- 魔神名美术字 UTL.Item.SetLocalizationImage(self.loc_BossName, self.img_BossName, showData[1].BossName) UIUtils.SetLabelText(self.txt_BossName, Const_IDS[showData[1].WordBossName]) local hasFollower = #showData > 1 UIUtils.SetActive(self.group_RightHero, hasFollower) if hasFollower then UTL.Item.SetLocalizationImage(self.loc_BossName2, self.img_BossName2, showData[2].BossName) UIUtils.SetLabelText(self.txt_BossName2, Const_IDS[showData[2].WordBossName]) end -- 卸载之前的模型 UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) -- 加载场景,使用配置表里的国别场景,场景相机也改成武将养成的 local kingdomData = DataSheetManager.HeroCountry:GetDataByID(bossData.NationalLimit) UTL.UIRender.Create3DSceneTrans(self.modelComponentDataHandle, kingdomData.UiScene, 2000, 0, 2000, 0, 327, 0, UTL.UIRender.LayerActiveType.HeroShow) -- 主模型模型设置 UTL.UIRender.CreateNonPlayerModel(self.modelComponentDataHandle, showData[1].BossShow, showData[1].ModelScale, showData[1].ShowEquipmentID, bossData.ModelLight, showData[1].ModelOffset) if hasFollower then --随从模型设置 UTL.UIRender.CreateNonPlayerFollower(self.modelComponentDataHandle, showData[2].BossShow, showData[2].ModelScale, showData[2].ShowEquipmentID, showData[2].ModelOffset) end end function UIDemonGodMain:UpdateTimerFunc(deltaTime, timeSinceUpdate) self.timerCount = 0 self.cdTimer:EndTimer() UIUtils.SetLabel(self.txt_Time, UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS.IDS_ActivityItem_End))) self.event_Challenge:SetGray(true) end function UIDemonGodMain:UpdateRankList() if not MDL.DemonGod.IsRefreshCurRankList then return end self.DemonGodRankList = MDL.Rank.GetRankInfoDataByType(MDL.Rank.RankType.DemonGod) self.myRankInfo = MDL.Rank.GetMyRankInfo() local isHaveRank = false local myRankInfo = {} if #self.DemonGodRankList > 0 then -- 排行榜前三名 if #self.DemonGodRankList > 3 then self.loop_Rank:ClearCells() for i = 1, 3 do self.loop_Rank:AddData(self.DemonGodRankList[i], 0) end else self.loop_Rank:ReloadAll(self.DemonGodRankList) end end -- 个人信息 UIUtils.SetLabel(self.txt_Name, BattleDataGetter.GetPlayerName()) if self.myRankInfo.index > 0 and self.myRankInfo.index <= 3 then self.state_MyRankBG:SetState(self.myRankInfo.index - 1) else self.state_MyRankBG:SetState(3) end if self.myRankInfo.param1 > 0 then UIUtils.SetLabel(self.txt_Number, self.myRankInfo.index) else UIUtils.SetLabelText(self.txt_Number, Const_IDS.IDS_MultiplayerDungeon_None) -- 暂无排名 end UIUtils.SetLabel(self.txt_Score, self.myRankInfo.param1) end function UIDemonGodMain:OnClosed() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder) end return UIDemonGodMain