local UIBattleSummaryPanel = UIViewClass() local DelayTiming = 0.5 local WinEffectTime = 0.5 local StarTimeGap = 0.2 local chapterGoalViewLevel = { 10201, 10203, 10205} --目前没有配置需求,暂时写死。以后要扩展的话就走配置 function UIBattleSummaryPanel:OnCreated(context) self:SetComponentGroup() end function UIBattleSummaryPanel:OnOpened(context) self.group_Fail = self.group_Fail.gameObject self.group_Win = self.group_Win.gameObject self.obj_Container = self.obj_Container self.showtime = 0 self.lastStarTime = 0 self.curLevelID = CTL.LevelSelect.GetCurrentLevelId() self.starList = {} local heroId = BattleDataGetter.GetMainPlayerCharacterID() local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) self.autoExitLevelTime = DataSheetManager.ConstData:GetDataByID("AutoExitBarrier").IntValue if heroData then self.delayTime = heroData.PoseTime / 1000 + DelayTiming else self.delayTime = 1 logging.error(LTAG.ERROR, "没有在HeroNum表里面找到武将ID:", heroId, "的数据,请检查!!!") end self.rewardList = context.Reward self.isWin = context.Win self.passTime = context.Time if self.curLevelID then self.barrierData = DataSheetManager.BarrierChosenData:GetDataByID(self.curLevelID) self:DealwithBtnShow() end self:StartRepeatFunc(self.OnUpdateFun, 0) if self.isWin then CTL.Sound.PlayGameSound("MUSIC_Victory") else CTL.Sound.PlayGameSound("MUSIC_Fail") end self:SetChapterGoalView() self:ShowSummary(self.isWin) self:ShowChapterGoal() end function UIBattleSummaryPanel:OnUpdateFun(deltaTime, timeSinceUpdate) if not self.needOpenGoalView then --没有奖励界面才有自动退出倒计时 if self.countdownNextLevel then UIUtils.SetLabel(self.txt_Tips, string.FormatByIdsId(Const_IDS.IDS_ClimbTower_AutoNextLevel, math.abs(math.ceil(self.autoExitLevelTime - timeSinceUpdate)))) else UIUtils.SetLabel(self.txt_Tips, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_AutoExit), math.abs(math.ceil(self.autoExitLevelTime - timeSinceUpdate)))) end end if timeSinceUpdate > self.autoExitLevelTime then if not self.needOpenGoalView then if self.barrierData and self.barrierData.DifficultyDegree == MDL.LevelSelect.Difficult.Elite or self.barrierData.DifficultyDegree == MDL.LevelSelect.Difficult.Hell then if self.countdownNextLevel then self:OnClickEnterNextLevel(false) else self:OnClickBackTownButton() --没有奖励界面显示,自动退出 end else self:OnClickBackTownButton() --没有奖励界面显示,自动退出 end end self:StopRepeatFunc(self.OnUpdateFun) elseif timeSinceUpdate > self.delayTime and not self.obj_Container.gameObject.activeInHierarchy then self:ShowSummary(self.isWin) elseif timeSinceUpdate > WinEffectTime and self.obj_Container.gameObject.activeInHierarchy then if timeSinceUpdate - self.lastStarTime >= StarTimeGap then self:PlayStarEffect() self.lastStarTime = timeSinceUpdate end end --if timeSinceUpdate > WinEffectTime + StarTimeGap and self.obj_Container.gameObject.activeInHierarchy then -- self:PlayStarEffect() --end end function UIBattleSummaryPanel:OnClickEnterNextLevel(isClick) local nextLevel = CTL.LevelSelect.GetNextLevelId(self.curLevelID) local unlockLevelId = MDL.LevelSelect.GetUnLockLevelIdMsg()[self.barrierData.DifficultyDegree] if nextLevel > 0 and unlockLevelId >= nextLevel then local nextBarrierData = DataSheetManager.BarrierChosenData:GetDataByID(nextLevel) local levelStar = MDL.LevelSelect.GetLevelStarNumById(nextLevel) if levelStar > 0 then --已解锁要判断体力 if nextBarrierData.Energy <= MDL.Player.GetEnergyValue() then MDL.LevelSelect.EnterFuben(LuaConst.LevelType.NORMAL, nextLevel, nil, nextBarrierData.MissonDataID[1]) else if isClick then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_108_WarnCode_EnergyIsNotEnough) end end else --未解锁不用判断 MDL.LevelSelect.EnterFuben(LuaConst.LevelType.NORMAL, nextLevel, nil, nextBarrierData.MissonDataID[1]) end end end function UIBattleSummaryPanel:PlayStarEffect() if #self.starList > 0 then self.starEffect[table.remove(self.starList)]:PlayUIEffect() CTL.Sound.PlayGameSound("UI_stars") end end function UIBattleSummaryPanel:SetComponentGroup() self.conditionText = {} --self.failedStar = {} --目前不用处理未达成的星星,一直显示就好 self.successStar = {} self.complete = {} self.incomplete = {} self.starEffect = {} for i = 1, 3 do self.conditionText[i] = self["lab_Condition0"..i] self.successStar[i] = self["group_Star0"..i].gameObject self.complete[i] = self["sprite_Complete0"..i] self.incomplete[i] = self["sprite_Incomplete0"..i] self.starEffect[i] = self["effect_Star0"..i] end end function UIBattleSummaryPanel:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.Item.ID, data.Count) end function UIBattleSummaryPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.RewardScroll then UTL.ItemTips.ShowCommonTipsById(data.Item.ID) end end function UIBattleSummaryPanel:ShowSummary(isWin) CameraController.Instance:SetDOF(true, 2) UIUtils.SetActive(self.obj_Container.gameObject, true) if self.rewardList then for i, item in ipairs(self.rewardList) do self.RewardScroll:AddData(item, 0) end end if isWin then self:ShowLevelEvaluation() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.BossChallenge) then self:HideLevelEvaluation() end end self.summaryTemplateEffectHandle1, self.summaryTemplateEffectHandle2 = CTL.LevelSelect.ShowCommonSummaryTemplate(self, isWin) CameraController.Instance:SetGray(not isWin) UIUtils.SetActive(self.group_Fail.gameObject, not isWin) UIUtils.SetActive(self.group_Win.gameObject, isWin) if self.Text_Local then --资源关继承了这个界面,所以这个预制新加的节点在资源关预制里不存在 UIUtils.SetLabelText(self.Text_Local, self.needOpenGoalView and Const_IDS.IDS_FightThroneNext or Const_IDS.IDS_ExitBarrier) end end -- 下一关按钮展示 function UIBattleSummaryPanel:DealwithBtnShow() self.countdownNextLevel = false if self.needOpenGoalView then UIUtils.SetActive(self.txt_Tips.gameObject, false) UIUtils.SetActive(self.event_NextLevel.gameObject, false) else if self.barrierData and (self.barrierData.DifficultyDegree == MDL.LevelSelect.Difficult.Elite or self.barrierData.DifficultyDegree == MDL.LevelSelect.Difficult.Hell) then if self.isWin then local nextLevel = CTL.LevelSelect.GetNextLevelId(self.curLevelID) if nextLevel > 0 then -- 还有后续关卡 local unlockLevelId = MDL.LevelSelect.GetUnLockLevelIdMsg()[self.barrierData.DifficultyDegree] UIUtils.SetActive(self.event_NextLevel.gameObject, true) UIUtils.SetLabelText(self.txt_NextLevel, Const_IDS.IDS_ClimbTower_StartNextLevel) if unlockLevelId >= nextLevel then self.event_NextLevel:SetGray(false, true) local levelStar = MDL.LevelSelect.GetLevelStarNumById(nextLevel) local nextBarrierData = DataSheetManager.BarrierChosenData:GetDataByID(nextLevel) if levelStar > 0 then if nextBarrierData.Energy <= MDL.Player.GetEnergyValue() then self.countdownNextLevel = true end else self.countdownNextLevel = true end UIUtils.SetActive(self.txt_Tips.gameObject, true) else self.event_NextLevel:SetGray(true, false) end else -- 没有后续关卡 直接隐藏按钮 UIUtils.SetActive(self.txt_Tips.gameObject, true) UIUtils.SetActive(self.event_NextLevel.gameObject, false) end else UIUtils.SetActive(self.txt_Tips.gameObject, false) UIUtils.SetActive(self.event_NextLevel.gameObject, true) self.event_NextLevel:SetGray(false, true) UIUtils.SetLabelText(self.txt_NextLevel, Const_IDS.IDS_ClimbTower_Restart) end else UIUtils.SetActive(self.txt_Tips.gameObject, true) UIUtils.SetActive(self.event_NextLevel.gameObject, false) end end end function UIBattleSummaryPanel:HideLevelEvaluation() UIUtils.SetActive(self.group_Info, false) UIUtils.SetActive(self.group_Star, false) end function UIBattleSummaryPanel:ShowLevelEvaluation() self:FormatTime() local evaluationList = BattleDataGetter.GetLevelEvaluationList() for i,v in ipairs(evaluationList) do UIUtils.SetLabel(self.conditionText[i], self:FormatEvaluationText(v.Data)) if v.Completed then UIUtils.SetActive(self.successStar[i], true) UIUtils.SetActive(self.complete[i], true) UIUtils.SetActive(self.incomplete[i], false) table.insert(self.starList, 1, i) else UIUtils.SetActive(self.successStar[i], false) UIUtils.SetActive(self.complete[i], false) UIUtils.SetActive(self.incomplete[i], true) end end end function UIBattleSummaryPanel:FormatTime() local passSeconds = self.passTime if passSeconds > UTL.Time.TotalSecondsOneMinute then local time if GameAppInfo.IsVietnamPackage() then time = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeMinute), math.floor(passSeconds / UTL.Time.TotalSecondsOneMinute)).." "..string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeSecond), passSeconds % UTL.Time.TotalSecondsOneMinute) else time = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeMinute), math.floor(passSeconds / UTL.Time.TotalSecondsOneMinute))..string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeSecond), passSeconds % UTL.Time.TotalSecondsOneMinute) end UIUtils.SetLabel(self.Txt_Common, string.Concat(UIUtils.GetLocalizedTxt(Const_IDS.IDS_PassTime), UTL.Color.FormatTextByColor("e8d588", time))) else local time1 = string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeSecond), passSeconds) UIUtils.SetLabel(self.Txt_Common, string.Concat(UIUtils.GetLocalizedTxt(Const_IDS.IDS_PassTime), UTL.Color.FormatTextByColor("e8d588", time1))) end end function UIBattleSummaryPanel:FormatEvaluationText(evaluateData) return string.format(UIUtils.GetLocalizedTxt(Const_IDS[evaluateData.EvaluationNextIDS]), evaluateData.Param1, evaluateData.Param2, evaluateData.Param3) end --章节目标显示,内容和UILevelSelectMainPanel:RefreshChapterAward function UIBattleSummaryPanel:ShowChapterGoal() UIUtils.SetActive(self.group_ChapterGoal, self.chapterGoalData ~= nil) if self.chapterGoalData then local chapterGoalId = self.chapterGoalData.chapterGoalId local data = DataSheetManager.ChapterGoalData:GetDataByChapterGoalID(chapterGoalId) UIUtils.SetImageByAssetBundle(self.img_Avatar01, data.DisplayHeroHeadPicture) local completeCount = MDL.LevelSelect.GetCompleteLevelCount(chapterGoalId) local amountCount = self.chapterGoalData.amountLevel local txtContent = completeCount < amountCount and string.format(UIUtils.GetLocalizedTxt(Const_IDS[data.LevelDisplayHintText]), amountCount - completeCount) or UIUtils.GetLocalizedTxt(Const_IDS[data.LevelDisplayGetHintText]) UIUtils.SetLabel(self.txt_ChapterGoal, txtContent) self.ProgressBarChapterGoal.fillAmount = completeCount / amountCount self.amountCount = amountCount self.completeCount = completeCount end end --点完退出还要看个章节奖励界面 function UIBattleSummaryPanel:SetChapterGoalView() self.needOpenGoalView = false --需要显示展示章节目标奖励 if not self.curLevelID then return --有些副本,比如资源关,是先清id再打开界面。这时候也不需要章节奖励 end if not MDL.LevelSelect.IsUnlockChapterGoalAward() then return --章节奖励机制未解锁 end local chapterId = MDL.LevelSelect.GetChapterIdByLevelId(self.curLevelID) self.chapterGoalData = MDL.LevelSelect.GetUnclaimedChapterGoalData(chapterId) if not self.chapterGoalData then return --已经领过奖励了又回来打了,不用弹 end local data = DataSheetManager.ChapterGoalData:GetDataByChapterGoalID(self.chapterGoalData.chapterGoalId) if not MDL.Unlock.IsComplete(data.Unlock_Table[1].UnlockCondition, data.Unlock_Table[1].UnlockConditionParam) then return end for _, v in ipairs(chapterGoalViewLevel) do if self.curLevelID == v then self.needOpenGoalView = true return end end end -- 点击按钮回城 function UIBattleSummaryPanel:OnClickBackTownButton() if self.needOpenGoalView then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIChapterGoalGet, { amountCount = self.amountCount, completeCount = self.completeCount }) else MDL.Level.SendRoleLeaveFuben() end self:StopRepeatFunc(self.OnUpdateFun) end function UIBattleSummaryPanel:OnBackButtonPressed() self:OnButtonClicked(self.event_BackTown) end function UIBattleSummaryPanel:OnButtonClicked(obj) if obj == self.event_BackTown then self:OnClickBackTownButton() elseif obj == self.event_NextLevel then self:OnClickEnterNextLevel(true) end end function UIBattleSummaryPanel:OnClosed() CTL.LevelSelect.RemoveSummaryTemplateEffect(self) end return UIBattleSummaryPanel