--- 国战晚间Boss主界面 local UICountryNightBossMain = UIViewClass() local CountryIconName = { [LuaConst.EHeroKingdomType.WEI] = "gb_msz_wei.png", [LuaConst.EHeroKingdomType.SHU] = "gb_msz_shu.png", [LuaConst.EHeroKingdomType.WU] = "gb_msz_wu.png", [LuaConst.EHeroKingdomType.QUN] = "gb_msz_qun.png", } function UICountryNightBossMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_CountryNightBoss_UpdateBossInfo, self.UpdateBossInfo) self:RegistSystemEvent(EventID.UI_CountryNightBoss_MainRankUpdate, self.UpdateRankInfo) self:RegistSystemEvent(EventID.UI_CountryNightBoss_LineUpInfoChanged, self.SetLineUpLimitBoss) MDL.CountryNightBoss.C2GCountryBossMainPanelChange(true) -- 初始化八卦图信息 self.bossMainInfo = {} -- k为position, v为data -- 当前选中信息 self.curSelectInfo = { position = 0, bossId = 0 } -- {bossID = 1, pos = 1} self.curToggleIndex = 0 -- 当前排行index self.toggle_Tab:SelectIndex(self.curToggleIndex) self:SetInfo() self:SetLineUpLimitBoss() self:RefreshEntryRedPoint() UTL.UIRender.AdaptiveImageSizeFit(self.bg_Bottom) end function UICountryNightBossMain:SetInfo() -- 界面信息 local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.CountryNightBoss) local date, time, extra = CTL.Activities.GetDetailsTimeDesc(activityData, true) UIUtils.SetLabel(self.txt_Time_Desc, date .. time) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[activityData.Activity]) -- 默认隐藏boss信息 UIUtils.SetActive(self.img_BossInfoBg.gameObject, false) for _, collection in ipairs(self.group_Boss) do collection.state_Boss:SetState(0) end end function UICountryNightBossMain:RefreshEntryRedPoint() if MDL.Activities.GetRedPointByID(LuaConst.ActivityType.CountryNightBoss) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.CountryNightBoss, 1, true, LuaConst.ActivityType.CountryNightBoss) end self.btn_Hint:SetRedPoint(CTL.CountryNightBoss.GetLineUpRedPoint()) end function UICountryNightBossMain:OnClosed() MDL.CountryNightBoss.C2GCountryBossMainPanelChange(false) end function UICountryNightBossMain:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UICountryNightBossMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then CTL.CountryNightBoss.ShowCountryNightBossNoteView() elseif comp == self.btn_Rank then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryNightBossRecord) elseif comp == self.btn_FightInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryNightBossReward) elseif comp == self.btn_PointReward then elseif comp == self.btn_Goto then if self.curSelectInfo.position == 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_CountryNightBoss_NeedToSelect"]) return end CTL.CountryNightBoss.GoToBossPos(self.curSelectInfo.position) elseif comp == self.btn_Hint then CTL.CountryNightBoss.SetLineUpRedPoint(false) self.btn_Hint:SetRedPoint(false) UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryNightBossSelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.CountryNightBoss, activityType = LuaConst.ActivityType.CountryNightBoss }, Const_UI_Lua.UIEnum.UIDemonGodSelectOfficer) elseif comp == self.btn_KingRightInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryKingRightPopUp) else for position, Collection in ipairs(self.group_Boss) do if comp == Collection.btn_BossBase then self:OnClickBossBaseBtn(position) elseif comp == Collection.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICountryNightBossSummary, { bossID = self.bossMainInfo[position].bossId }) end end end end --- 设置方位和boss信息按钮 function UICountryNightBossMain:OnClickBossBaseBtn(position) UIUtils.SetActive(self.img_BossInfoBg.gameObject, true) local bossInfo = self.bossMainInfo[position] local pointData = DataSheetManager.CountryNightBossPoint:GetDataByBossPoint(position) UIUtils.SetLabelText(self.txt_Direction, Const_IDS[pointData.PointName]) if bossInfo then -- 有Boss显示 self.state_Target:SetState(1) self.curSelectInfo.bossId = bossInfo.bossId self.curSelectInfo.position = position local bossData = DataSheetManager.CountryNightBoss:GetDataByID(bossInfo.bossId) local heroData = DataSheetManager.HeroNum:GetDataByID(bossData.HeroID) -- Boss艺术字描述 UIUtils.SetLabelText(self.txt_BossName, Const_IDS[bossData.WordBossName]) -- 额外伤害描述 local bossDesc = string.FormatByIdsId( Const_IDS["IDS_CountryNightBoss_ExtraDamage"], MDL.CountryNightBoss.DamageCountryFactor ) UIUtils.SetLabel(self.txt_BossInfo, bossDesc) -- 国别艺术字 CTL.Country.SetCountryImageByComp(self.img_RightBossCountryBg, self.img_RightBossCountry, bossData.BossNation) else -- 未生成 self.state_Target:SetState(0) self.curSelectInfo.bossId = 0 self.curSelectInfo.position = position end self:UpdateBossInfo() end function UICountryNightBossMain:UpdateBossInfo() -- 默认选中逻辑 local bossInfoList = MDL.CountryNightBoss.GetSortedBossInfoList() table.clear(self.bossMainInfo) for _, bossInfo in ipairs(bossInfoList) do self.bossMainInfo[bossInfo.position] = bossInfo end for position, collection in ipairs(self.group_Boss) do UIUtils.SetActive(collection.img_Select.gameObject, position == self.curSelectInfo.position) local bossInfo = self.bossMainInfo[position] if not bossInfo then -- 未刷新boss collection.state_Boss:SetState(0) else -- Boss图片 local bossData = DataSheetManager.CountryNightBoss:GetDataByID(bossInfo.bossId) CTL.Country.SetCountryImageByComp(collection.img_BossCountryBg, collection.img_BossCountry, bossData.BossNation) CTL.CountryNightBoss.SetHalfBossImg(collection.img_Boss, bossData.BossHalfCardImage) local isBossOver = MDL.CountryNightBoss.IsBossOver(bossInfo.bossId) local bossLeftTime = MDL.CountryNightBoss.GetBossLeftTimeByID(bossInfo.bossId) -- 剩余进度 UIUtils.SetLabel(collection.txt_Blood, CTL.CountryNightBoss.GetHpPercentValStr(bossInfo.bossHp, bossInfo.totalBossHp)) -- 倒计时 UIUtils.SetActive(collection.group_Time.gameObject, bossLeftTime > 0) UIUtils.SetAtlasImageFillAmount(collection.img_BossHp, CTL.CountryNightBoss.GetHpPercentVal(bossInfo.bossHp, bossInfo.totalBossHp)) -- Boss半身像 if isBossOver then collection.state_Boss:SetState(2) UIUtils.SetGray(collection.img_Boss, true) -- 设置boss伤害最高贡献国家标 if bossInfo.topCountryId == 0 then UIUtils.SetActive(collection.img_DefeatCountry, false) else UIUtils.SetActive(collection.img_DefeatCountry, true) CTL.Country.SetCountryFlagImg(collection.img_DefeatCountry, bossInfo.topCountryId) end else collection.state_Boss:SetState(1) UIUtils.SetGray(collection.img_Boss, false) -- 剩余时间 UIUtils.SetLabel(collection.txt_Time, CTL.CountryNightBoss.GetBossTimerStrBySeconds(bossLeftTime)) end end end end function UICountryNightBossMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_CountryRank then -- 国家榜 CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Country, data.countryId) UIUtils.SetLabel(cellTable.txt_Integral, data.score or "-") elseif scrollRect == self.loop_PlayerRank then -- 玩家榜 if string.isNilOrEmpty(data.acid) then CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Country, data.countryId) UIUtils.SetLabel(cellTable.txt_Player, "-") UIUtils.SetLabel(cellTable.txt_Damage, "-") else CTL.Country.SetCountryInRank(cellTable.img_Country, cellTable.txt_Country, data.countryId) local isSelf = data.acid == BattleDataGetter.GetAcID() -- 姓名 local nameStr = isSelf and UTL.Color.FormatGreenColor(data.playerName) or data.playerName -- 积分 local scoreStr = isSelf and UTL.Color.FormatGreenColor(UTL.String.GetCountStr(data.score)) or UTL.String.GetCountStr(data.score) UIUtils.SetLabel(cellTable.txt_Player, nameStr) UIUtils.SetActive(cellTable.txt_Server, false) UIUtils.SetLabel(cellTable.txt_Damage, scoreStr) end elseif self.loop_CASCountry == scrollRect then local countryData = DataSheetManager.HeroCountry:GetDataByID(data) UTL.Item.SetAtlasSprite(cellTable.img_Country, "UI_Formation", countryData.Uipath) UIUtils.SetLocalizationImage(cellTable.img_CountryName, CountryIconName[data]) end end function UICountryNightBossMain:OnValueChanged(comp, value) self.curToggleIndex = value if self.countryRankList and self.playerRankList then self:UpdateRankInfo(self.countryRankList, self.playerRankList) end end function UICountryNightBossMain:UpdateRankInfo(countryRankList, playerRankList) self.countryRankList = countryRankList self.playerRankList = playerRankList self.State_List:SetState(self.curToggleIndex) if self.curToggleIndex == 1 then -- 玩家榜 self.loop_PlayerRank:ReloadAll(playerRankList) else -- 国家榜 self.loop_CountryRank:ReloadAll(countryRankList) end end function UICountryNightBossMain:SetLineUpLimitBoss() self.loop_CASCountry:ReloadAll(MDL.CountryNightBoss.GetLineUpCountryLimits()) end return UICountryNightBossMain