local UINationClimbTowerMainPanel = UIViewClass() function UINationClimbTowerMainPanel:OnOpened(context) self:RegistTriggerEvent(self.img_Back, UIEventTriggerType.Drag) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.ClimbTowerEntry_Challenge, self.RefreshRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.ClimbTowerEntry_Progress, self.RefreshRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.ClimbTowerEntry_LineUp, self.RefreshLineUpRed) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.SetShowGs) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) -- GMS self:RegistSystemEvent(EventID.UI_CloseAndRecoverView, self.OnCloseAndRecoverView) self:RegistSystemEvent(EventID.UI_FubenQuickPass, self.OnClimbTowerQuickPass) self.towerType = context.towerType MDL.NationClimbTower.SetCurSelectTower() --记录当前进入的塔类型,进行跨天判断使用 UIUtils.SetActive(self.ani_TitleInfo, false) self.TableShowSystem:SetIsClimbTower(true) self.TableShowSystem:EnterTableShow() self:UpdateNationUI() self:UpdateNationClimbTowerInfo() self:RefreshRed() UIManager.ActiveUIModle(false, "UINationClimbTowerMainPanel") end function UINationClimbTowerMainPanel:OnClimbTowerQuickPass(mapType) if mapType == LuaConst.LevelType.NationClimbTower then self:UpdateNationUI() self:UpdateNationClimbTowerInfo() self:RefreshRed() end end function UINationClimbTowerMainPanel:OnClosed() UIManager.ActiveUIModle(true, "UINationClimbTowerMainPanel") end function UINationClimbTowerMainPanel:CheckIfFuncUnlock(funcId, isUnlock) if funcId and funcId == MDL.Unlock.FunctionType.ClimbTower and not MDL.Unlock.IsUnlock(funcId) then CTL.NationClimbTower.CloseAllClimbView() end end function UINationClimbTowerMainPanel:UpdateNationClimbTowerInfo() local chapterConfig = MDL.NationClimbTower.GetTowerConfigData(self.towerType) local nextLevelConfig = MDL.NationClimbTower.GetNextLevelConfig() if not nextLevelConfig then nextLevelConfig = MDL.NationClimbTower.GetPassedMaxLevelConfig(self.towerType) end self.nextLevelConfig = nextLevelConfig self.TableShowSystem:LoadChapterInfo(chapterConfig.BGUI) self.TableShowSystem:SwitchTable(false) self.TableShowSystem:LoadClimbTowerInfo(chapterConfig.ID, nextLevelConfig.Number % (chapterConfig.LevelNum - 1)) self:RefreshUI() end function UINationClimbTowerMainPanel:UpdateNationUI() UIUtils.SetActive(self.group_LeftClimbTower, false) UIUtils.SetActive(self.group_LeftBtn, false) UIUtils.SetActive(self.group_NationBtn, true) UIUtils.SetActive(self.group_InfoClimbTower, false) UIUtils.SetActive(self.btn_Shop, not GameAppInfo.IsVietnamPackage()) end function UINationClimbTowerMainPanel:RefreshRed() -- 挑战按钮红点 self.btn_ChallengeClimbTower:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ClimbTowerEntry_Challenge)) self.btn_Progress:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ClimbTowerEntry_Progress)) self:RefreshLineUpRed() end function UINationClimbTowerMainPanel:RefreshLineUpRed() self.btn_Array:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ClimbTowerEntry_LineUp)) end function UINationClimbTowerMainPanel:RefreshUI() self:SetShowGs() local openType, openLv = MDL.NationClimbTower.GetTowerOpenInfo() local chapterConfig = MDL.NationClimbTower.GetTowerConfigData(openType) UIUtils.SetLabelText(self.txt_ClimbTowerLevel, Const_IDS[chapterConfig.ClimbTower]) UIUtils.SetLabel(self.txt_Level, string.FormatByIdsId(Const_IDS["IDS_NationClimbTower_HistoryLevel"], self.nextLevelConfig.Number)) if not CTL.NationClimbTower.IsDuringOpenTime() then self.btn_ChallengeClimbTower:SetGray(true, true) elseif CTL.NationClimbTower.IsCrossDay() or CTL.NationClimbTower.IsMaxLevelByDay() then self.btn_ChallengeClimbTower:SetGray(true,true) UIUtils.SetActive(self.group_InfoClimbTower, true) UIUtils.SetActive(self.group_Reward,true) UIUtils.SetActive(self.group_Right,true) local dayCount = CTL.NationClimbTower.IsCrossDay() and 2 or 3 local timeValue = UTL.Time.GetServerIntervalTimeToRefresh(1) + UTL.Time.TotalSecondsOneDay * dayCount -- 挑战完的时刻 -> 第二天5点 + 3天 self.group_InfoClimbTower:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS["IDS_NationClimbTower_LevelMaxTime"]),1,2) self.group_InfoClimbTower:ResetAndBeginTimer(false,timeValue,0) elseif CTL.NationClimbTower.IsPassedAllLevelByTowerType() then self.btn_ChallengeClimbTower:SetGray(true,true) UIUtils.SetActive(self.group_InfoClimbTower,false) UIUtils.SetActive(self.group_Reward,false) UIUtils.SetActive(self.group_Right,false) else self.btn_ChallengeClimbTower:SetGray(false,true) UIUtils.SetActive(self.group_InfoClimbTower, false) UIUtils.SetActive(self.group_Reward,true) UIUtils.SetActive(self.group_Right,true) end UIUtils.SetActive(self.btn_through, MDL.NationClimbTower.IsHasNoNeedFightClimberLevel()) if self.nextLevelConfig then local levelRewardTable = DataSheetManager.NationClimbTowerRewardRepeat:GetDataByAttrRepeatID(self.nextLevelConfig.LevelRewardRepeatID).Item_Table for i, v in ipairs(self.group_Item) do UIUtils.SetActive(self.group_Item[i].gameObject,false) end local index=0 for k, v in pairs(levelRewardTable) do index=index+1 local reward = self.group_Item[index] if index <=3 then UTL.Item.SetItemCell(reward, v.ItemID, v.ItemNum) UIUtils.SetActive(reward.gameObject,true) reward.ItemID=v.ItemID end end --首次通关奖励显示 for i, v in ipairs(self.group_ItemFirst) do UIUtils.SetActive(self.group_ItemFirst[i].gameObject,false) end local needShowFirstPastLevelId= self.nextLevelConfig.NewRewardPre local needShowLevelData= DataSheetManager.NationClimbTowerLevel:GetDataByID(needShowFirstPastLevelId) local levelFormatStr = string.FormatByIdsId(Const_IDS["IDS_NationClimbTower_HistoryLevel"], needShowLevelData.Number) UIUtils.SetLabel(self.txt_Notice, string.FormatByIdsId(Const_IDS["IDS_NationClimbTower_NextReward"], levelFormatStr)) local needShowRewardTable = DataSheetManager.NationClimbTowerRewardRepeat:GetDataByAttrRepeatID(needShowLevelData.LevelRewardRepeatID).Item_Table local firstRewardIndex=0 for i, v in ipairs(needShowRewardTable) do firstRewardIndex=firstRewardIndex+1 local reward = self.group_ItemFirst[firstRewardIndex] if firstRewardIndex <=3 then UTL.Item.SetItemCell(reward, v.ItemID, v.ItemNum) UIUtils.SetActive(reward.gameObject,true) reward.ItemID=v.ItemID end end end end --战力显示 function UINationClimbTowerMainPanel:SetShowGs() local myGS = MDL.NationClimbTower.GetLineUpGSTotal(self.towerType) if self.nextLevelConfig then local currentGS = CTL.LevelSelect.GetSubjugateFreeLineGsText(self.nextLevelConfig.SubjugateDataPVE, myGS) --显示当前战力 if myGS == 0 then UIUtils.SetLabelText(self.txt_Now, Const_IDS["IDS_NationClimbTower_NoHero"]) else local currentGSShow = string.FormatByIdsKey("IDS_NewClimbTower_CombatPower", currentGS) UIUtils.SetLabel(self.txt_Now, currentGSShow) end --显示 推荐战力 UIUtils.SetLabel(self.txt_Limit, string.FormatByIdsKey("IDS_NewClimbTower_RecommendCombatPower", tostring(self.nextLevelConfig.Battle))) UIUtils.SetActive(self.btn_through, MDL.NationClimbTower.IsHasNoNeedFightClimberLevel()) end end function UINationClimbTowerMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UINationClimbTowerMainPanel: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 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.ClimbTower}) -- 玩法说明 elseif comp == self.btn_ChallengeClimbTower then CTL.NationClimbTower.OnEnterChallengeLevel() -- 挑战 elseif comp == self.btn_through then local targetMaxTowerLevelCfg = MDL.NationClimbTower.GetTargetMaxTowerLevelCfg() local content = string.FormatByIdsKey("IDS_PlayEasier_Tips1", self.txt_ClimbTowerLevel.text .. string.FormatByIdsId(Const_IDS["IDS_NationClimbTower_HistoryLevel"], targetMaxTowerLevelCfg.Number)) UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_PlayEasier_Button, content, function() MDL.LevelSelect.FubenQuickPassReq(LuaConst.LevelType.NationClimbTower, MDL.NationClimbTower.GetNextLevelConfig().ID, targetMaxTowerLevelCfg.ID) end) elseif comp == self.btn_Progress then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UINationClimbTowerProgress) -- 历程 elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.WuDao}) -- 跳转武道商店 elseif comp == self.btn_RewardInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIClimbTowerReward, {nationTowerID = self.towerType}) elseif comp == self.btn_Array then -- 布阵界面 UIManager.OpenView(Const_UI_Lua.UIEnum.UINationClimbTowerSelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.NationClimbTower, activityType = LuaConst.ActivityType.ClimbTower }, "DemonGod/UIDemonGodSelectOfficer" ) else --首通道具提示 for i, v in ipairs(self.group_ItemFirst) do if comp == self.group_ItemFirst[i].event_Click then UTL.ItemTips.ShowCommonTipsById(self.group_ItemFirst[i].ItemID) return end end --下一关道具提示 for i, v in ipairs(self.group_Item) do if comp == self.group_Item[i].event_Click then UTL.ItemTips.ShowCommonTipsById(self.group_Item[i].ItemID) return end end end end function UINationClimbTowerMainPanel:OnDrag(comp, eventData) self.TableShowSystem:DraggingByManual(eventData.delta.x) end return UINationClimbTowerMainPanel