local UIFreeLineupSelectOfficer = require("View/FreeLineUp/UIFreeLineupSelectOfficer") local UINationClimbTowerSelectOfficer = UIViewClass(UIFreeLineupSelectOfficer) local bgImagePath = ConstAssetPathConfig.bgImagePath -- OVERRIDE function UINationClimbTowerSelectOfficer:Init() self.UIState_NationClimbTower:SetState(1) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) -- GMS -- 标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS['IDS_NationClimbTower_SetHero']) self.curKingdom = MDL.NationClimbTower.GetTowerOpenInfo() -- 四国爬塔使用自己的国别数据 end --左侧前中后军按钮 -- OVERRIDE function UINationClimbTowerSelectOfficer:InitTeamSlotUnlock() for index, v in ipairs(self.group_Buttons) do local isUnlock = CTL.NationClimbTower.IsTeamSlotUnlock(self.curKingdom, index) v.btn_team:SetGray(not isUnlock, true) if self.selectTeamId == index then v.state_Button:SetState(1) else v.state_Button:SetState(0) end UIUtils.SetActive(v.img_Lock, not isUnlock) end end function UINationClimbTowerSelectOfficer:CheckIfFuncUnlock(funcId, isUnlock) if funcId and funcId == MDL.Unlock.FunctionType.ClimbTower then if not MDL.Unlock.IsUnlock(funcId) then CTL.NationClimbTower.CloseAllClimbView() end end end -- OVERRIDE function UINationClimbTowerSelectOfficer:SetLineUps() MDL.FreeLineUp.FreeLineUpSetRequest( MDL.FreeLineUp.FuncType.NationClimbTower, self.curKingdom, MDL.FreeLineUp.SetType.Official, self.allHeroList ) end function UINationClimbTowerSelectOfficer:OnClosed() -- 退出时覆盖预览的缓存 MDL.FreeLineUp.FreeLineUpGetInfoRequest(MDL.FreeLineUp.FuncType.NationClimbTower) end function UINationClimbTowerSelectOfficer:RefreshSelectOfficerView() self:RefreshTeamInfo() -- 刷新除选中外的另外2军战力 self:RefreshHeroList() self:InitTeamSlotUnlock() end function UINationClimbTowerSelectOfficer:RefreshRightPanelInfo() local index = self.selectTeamId -- 选中军的战力 UIUtils.SetLabelText(self.txt_TotalBR, Const_IDS[MDL.FreeLineUp.TeamIDS[self.selectTeamId]]) UIUtils.SetLabel(self.txt_BR, MDL.NationClimbTower.GetLineUpGSByTeamID(self.curKingdom, index)) -- 下一行战力显示 index = index + 1 > 3 and 1 or index + 1 UIUtils.SetLabelText(self.txt_Score01, Const_IDS[MDL.FreeLineUp.TeamIDS[index]]) UIUtils.SetLabel(self.txt_Num01, MDL.NationClimbTower.GetLineUpGSByTeamID(self.curKingdom, index)) -- 下一行战力显示 index = index + 1 > 3 and 1 or index + 1 UIUtils.SetLabelText(self.txt_Score02, Const_IDS[MDL.FreeLineUp.TeamIDS[index]]) UIUtils.SetLabel(self.txt_Num02, MDL.NationClimbTower.GetLineUpGSByTeamID(self.curKingdom, index)) -- 三军总战力 UIUtils.SetLabel(self.txt_TotalScore, string.FormatByIdsId(Const_IDS["IDS_NationClimbTower_AllHero"], MDL.NationClimbTower.GetLineUpGSTotal(self.curKingdom))) end function UINationClimbTowerSelectOfficer: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 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.ClimbTower}) elseif comp == self.btn_Save then CTL.NationClimbTower.SaveLineUp(self.allHeroList, self.curKingdom) elseif comp == self.btn_Formation then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFreeLineupDetailPanel, {id = MDL.FreeLineUp.FuncType.NationClimbTower, heroList = self.allHeroList, curKingdom = self.curKingdom}) else for index, v in ipairs(self.group_Buttons) do if comp == v.btn_team then -- 判断槽位是否解锁 local isUnlock, unlockText = CTL.NationClimbTower.IsTeamSlotUnlock(self.curKingdom, index) if not isUnlock then CTL.Tips.AddTipsMsg(unlockText) return end -- 更新选中 前中后军 self.selectTeamId = index self:RefreshTeamInfo() -- 刷新左侧槽位UI self:InitTeamSlotUnlock() end end end end -- OVERRIDE function UINationClimbTowerSelectOfficer:GetHeroHavePos(heroId) local lineUps = MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType) if lineUps then for k,teamInfo in ipairs(lineUps) do if teamInfo.lineNumber == self.curKingdom then for _, heroInfo in ipairs(teamInfo.heroInfos) do if heroInfo.heroId == heroId then return heroInfo.posNumber end end end end end return 0 end function UINationClimbTowerSelectOfficer:GetLineUpsInfoArr() for _, lineInfo in ipairs(MDL.FreeLineUp.GetLineUpInfoByFunctionType(self.freeLineupFuncType)) do if lineInfo.lineNumber == self.curKingdom then return lineInfo end end end -- OVERRIDE -- TODO 因不同玩法服务器发来的阵容信息默认规则不同,四国爬塔魏蜀吴群同时可以存储4套阵容lineNumber不同,后续优化MDL中的GetLineUpInfoByFunctionType方法,不在View中进行特判 function UINationClimbTowerSelectOfficer:RefreshTeamInfo() self:RefreshRightPanelInfo() local posTitle = Const_IDS.IDS_DemonGod_UI_30 local posNumber1, posNumber2 = 1, 2 if self.selectTeamId == 2 then posNumber1, posNumber2 = 3, 4 posTitle = Const_IDS.IDS_DemonGod_UI_31 elseif self.selectTeamId == 3 then posNumber1, posNumber2 = 5, 6 posTitle = Const_IDS.IDS_DemonGod_UI_32 end UIUtils.SetLabel(self.txt_TotalBR, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_45, UIUtils.GetLocalizedTxt(posTitle))) self.allHeroList = {-1, -1, -1, -1, -1, -1} local lineUps = self:GetLineUpsInfoArr() if lineUps then self.group_Sopt1.state_Select:SetState(0) self.group_Sopt2.state_Select:SetState(0) UIUtils.SetImageByAssetBundle(self.group_Sopt1.img_QualityHead, bgImagePath) UIUtils.SetImageByAssetBundle(self.group_Sopt2.img_QualityHead, bgImagePath) UIUtils.SetLabel(self.group_Sopt1.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, 0)) UIUtils.SetLabel(self.group_Sopt2.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, 0)) UIUtils.SetLabel(self.group_Sopt1.txt_Heritaged, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48, 0)) UIUtils.SetLabel(self.group_Sopt2.txt_Heritaged, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48,0)) UIUtils.SetLabel(self.txt_BR, 0) for _,heroInfo in ipairs(lineUps.heroInfos) do self.allHeroList[heroInfo.posNumber] = heroInfo.heroId end local allGs = 0 for _,heroInfo in ipairs(lineUps.heroInfos) do if posNumber1 == heroInfo.posNumber then self.group_Sopt1.state_Select:SetState(1) UTL.Item.SetHeroIconByHeroId(self.group_Sopt1.img_SelectedHero, heroInfo.heroId, heroInfo.heroAwaken) local quality = CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, MDL.HeroAwaken.GetIsHeroAwaken(heroInfo.heroId)) UTL.Color.SetQualityImageByType(self.group_Sopt1.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(self.group_Sopt1.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(self.group_Sopt1.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, heroInfo.heroBaseGs)) UIUtils.SetLabel(self.group_Sopt1.txt_Heritaged, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48, heroInfo.lineUpGs)) allGs = allGs + heroInfo.heroBaseGs + heroInfo.lineUpGs elseif posNumber2 == heroInfo.posNumber then self.group_Sopt2.state_Select:SetState(1) UTL.Item.SetHeroIconByHeroId(self.group_Sopt2.img_SelectedHero, heroInfo.heroId, heroInfo.heroAwaken) local quality = CTL.HeroAwaken.GetHeroQuality(heroInfo.heroId, MDL.HeroAwaken.GetIsHeroAwaken(heroInfo.heroId)) UTL.Color.SetQualityImageByType(self.group_Sopt2.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(self.group_Sopt2.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) UIUtils.SetLabel(self.group_Sopt2.txt_Basic, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_47, heroInfo.heroBaseGs)) UIUtils.SetLabel(self.group_Sopt2.txt_Heritaged, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_48, heroInfo.lineUpGs)) allGs = allGs + heroInfo.heroBaseGs + heroInfo.lineUpGs end end UIUtils.SetLabel(self.txt_BR, allGs) else self.group_Sopt1.state_Select:SetState(0) self.group_Sopt2.state_Select:SetState(0) UIUtils.SetImageByAssetBundle(self.group_Sopt1.img_QualityHead, bgImagePath) UIUtils.SetImageByAssetBundle(self.group_Sopt2.img_QualityHead, bgImagePath) end end return UINationClimbTowerSelectOfficer