local UIGoldenHeroStoryLevelSummary = UIViewClass() local DelayTiming = 0.5 function UIGoldenHeroStoryLevelSummary:OnCreated(context) self:SetComponentGroup() end function UIGoldenHeroStoryLevelSummary: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 UIUtils.SetActive(self.obj_Container.gameObject, false) local heroData = DataSheetManager.HeroNum:GetDataByID(BattleDataGetter.GetMainPlayerCharacterID()) self.autoExitLevelTime = DataSheetManager.ConstData:GetDataByID("AutoExitBarrier").IntValue self.delayTime = heroData.PoseTime / 1000 + DelayTiming self.rewardList = context.Reward self.isWin = context.Win self.passTime = context.Time self:StartRepeatFunc(self.RepeatFunc, 0) if self.isWin then CTL.Sound.PlayGameSound("MUSIC_Victory") else CTL.Sound.PlayGameSound("MUSIC_Fail") self:ShowSummary(self.isWin) end end function UIGoldenHeroStoryLevelSummary:RepeatFunc(deltaTime, timeSinceUpdate) UIUtils.SetLabel(self.txt_Tips, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_AutoExit), math.abs(math.ceil(self.autoExitLevelTime-timeSinceUpdate)))) if timeSinceUpdate > self.autoExitLevelTime then self:OnClickBackTownButton() elseif timeSinceUpdate > self.delayTime and not self.obj_Container.gameObject.activeInHierarchy then self:ShowSummary(self.isWin) end end function UIGoldenHeroStoryLevelSummary:SetComponentGroup() self.conditionText = {} self.complete = {} for i = 1, 3 do self.conditionText[i] = self["lab_Condition0"..i] self.complete[i] = self["sprite_Complete0"..i] end end function UIGoldenHeroStoryLevelSummary:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.Item.ID, data.Count) end function UIGoldenHeroStoryLevelSummary:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.RewardScroll then UTL.ItemTips.ShowCommonTipsById(data.Item.ID) end end function UIGoldenHeroStoryLevelSummary: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) UIUtils.SetActive(self.txt_Tips.gameObject, true) end function UIGoldenHeroStoryLevelSummary:HideLevelEvaluation() UIUtils.SetActive(self.group_Info, false) UIUtils.SetActive(self.group_Star, false) end function UIGoldenHeroStoryLevelSummary:FormatTime() local passSeconds = self.passTime if passSeconds > UTL.Time.TotalSecondsOneMinute then local 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) UIUtils.SetLabel(self.Txt_Common, time) else UIUtils.SetLabel(self.Txt_Common, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_TimeSecond), passSeconds)) end end function UIGoldenHeroStoryLevelSummary:ShowLevelEvaluation() self:FormatTime() local evaluationList = BattleDataGetter.GetLevelEvaluationList() local goldenHeroStoryLevelID = MDL.GoldenHeroStory.GetCurLevelSystemData().ID self.activityId = MDL.GoldenHeroStory.GetActivityIDByLevelID(goldenHeroStoryLevelID) local dataList = {} for _,v in DataSheetManager.GoldHeroActivityLevelGoal:GetEnumerator() do if v.BarrierID == goldenHeroStoryLevelID then dataList[v.OrderID] = v end end for i,v in ipairs(evaluationList) do UIUtils.SetLabel(self.conditionText[i], self:FormatEvaluationText(dataList[i], v.Completed, self.complete[i])) end end function UIGoldenHeroStoryLevelSummary:FormatEvaluationText(goldenHeroStoryLevelData, state, starImg) local curValue = 0 if goldenHeroStoryLevelData.CountType == 1 then curValue = MDL.GoldenHeroStory.GetLevelGoalDataByActivityID_LevelID_LevelGoalID(self.activityId, goldenHeroStoryLevelData.BarrierID, goldenHeroStoryLevelData.LeveGoalID).count if not curValue then curValue = 0 end UIUtils.SetActive(starImg, curValue == goldenHeroStoryLevelData.CountTotalNum) else local serverState = MDL.GoldenHeroStory.GetLevelGoalDataByActivityID_LevelID_LevelGoalID(self.activityId, goldenHeroStoryLevelData.BarrierID, goldenHeroStoryLevelData.LeveGoalID).state > 0 curValue = (serverState or state) and goldenHeroStoryLevelData.CountTotalNum or 0 UIUtils.SetActive(starImg, serverState or state) end return string.format(UIUtils.GetLocalizedTxt(Const_IDS[goldenHeroStoryLevelData.GoalDes]), goldenHeroStoryLevelData.CountTotalNum)..string.format("(%s/%s)", curValue, goldenHeroStoryLevelData.CountTotalNum) end -- 点击按钮回城 function UIGoldenHeroStoryLevelSummary:OnClickBackTownButton() MDL.Level.SendRoleLeaveFuben() self:StopRepeatFunc(self.RepeatFunc) end function UIGoldenHeroStoryLevelSummary:OnButtonClicked(obj) if obj == self.event_BackTown then self:OnClickBackTownButton() end end function UIGoldenHeroStoryLevelSummary:OnClosed() CTL.LevelSelect.RemoveSummaryTemplateEffect(self) end return UIGoldenHeroStoryLevelSummary