local UISuperGoldStoryPath = UIViewClass() local MOVE_DURATION = 0.5 --移动的时间 local ScreenWidth = UnityEngine.Screen.width local ScreenHeight = UnityEngine.Screen.height local function StringFormat(ids) return string.FormatByIdsId(Const_IDS.IDS_SuperGoldHeroActivity_Level_Hint_1, UIUtils.GetLocalizedTxt(Const_IDS[ids])) end function UISuperGoldStoryPath:TimerFunc() UIUtils.SetActive(self.group_Time, false) end function UISuperGoldStoryPath:SetCDTimer(timer, cdTime) if cdTime > 0 then timer:ResetAndBeginCustomTimer(false, cdTime, 0, nil) else timer:EndTimer() end end function UISuperGoldStoryPath:OnOpened(context) self.parentView = context.parentView self.activityId = context.parentView.activityId self.heroType = context.parentView.heroType self.activityType = MDL.OperationActivity.ActivityType.SuperGold self:RegistSystemEvent(EventID.UI_SuperGoldStory_RefreshInfo, self.RefreshSuperGoldStoryTaskAndLevel) -- 刷新界面 if context.parentView.storyLevelInfo then self.curLevelID = context.parentView.storyLevelInfo.levelCfg.LevelID end if context.parentView.storyTaskInfo then self.gotoTaskID = context.parentView.storyTaskInfo.taskCfg.TaskID end self:InitPathTimer() self:RefreshSuperGoldStoryTaskAndLevel() end function UISuperGoldStoryPath:OnButtonClicked(comp) self.gotoTaskID = 0 self.curLevelID = 0 for k,v in ipairs(self.group_Task) do if self:IsTaskUnlock(self.superGoldTaskInfoList[k].taskCfg.TaskID) then if self.superGoldTaskInfoList[k].taskState == MDL.GoldenHeroStory.Enum_TaskState.Lock then v.cell_Task.state_SelectTask:SetState(2) else v.cell_Task.state_SelectTask:SetState(0) end else v.cell_Task.state_SelectTask:SetState(2) end end for k,v in ipairs(self.group_Level) do v.cell_Level.state_SelectLevel:SetState(0) end for k,v in ipairs(self.group_Task) do if comp == v.cell_Task.btn_Task then if self:IsTaskUnlock(self.superGoldTaskInfoList[k].taskCfg.TaskID) then if self.superGoldTaskInfoList[k].taskState == MDL.GoldenHeroStory.Enum_TaskState.Lock then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_LockHint2) else v.cell_Task.state_SelectTask:SetState(1) self:SetSuperGoldStoryContentPosition(v.gameObject.transform) CTL.SuperGoldStory.ChangeSubUIPanel(self.activityId, self.heroType, 0, self.superGoldTaskInfoList[k]) if k == 1 then self.parentView:SetAbortActive(self:IsFirstTaskFinish()) else self.parentView:SetAbortActive(MDL.SuperGoldStory.GetDoingGroup(self.activityId) > 0) end return end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_LockHint2) end end end for k,v in ipairs(self.group_Level) do if comp == v.cell_Level.btn_Level then if self:IsLevelUnlock(self.levelInfoList[k].levelCfg.LevelID) then if self.levelInfoList[k].levelState == MDL.GoldenHeroStory.LevelState.Lock then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_LockHint1) else v.cell_Level.state_SelectLevel:SetState(1) self.curLevelID = DataSheetManager.SuperGoldStoryLevel:GetDataByLevelID(self.levelIDList[k]).ID self:SetSuperGoldStoryContentPosition(v.gameObject.transform) CTL.SuperGoldStory.ChangeSubUIPanel(self.activityId, self.heroType, 1, self.levelInfoList[k]) self.parentView:SetAbortActive(false) return end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_LockHint1) end end end for k,v in ipairs(self.group_Ending) do if comp == v.cell_Ending.btn_Ending then self.curEndingID = self.endingInfoList[k].EndingID self:SetSuperGoldStoryContentPosition(v.gameObject.transform) CTL.SuperGoldStory.ChangeSubUIPanel(self.activityId, self.heroType, 2, self.endingInfoList[k]) self.parentView:SetAbortActive(false) return end end end function UISuperGoldStoryPath:InitPathTimer() local isShowTimer, countDown = MDL.SuperGoldStory.IsShowNextLevelTimerByActivityID(self.activityId, self.heroType) UIUtils.SetActive(self.group_Time, not isShowTimer) if not isShowTimer then self:StartRepeatFunc(self.TimerFunc, countDown) self.cdTimer:SetDHMSStr(StringFormat("IDS_PreviewTime1"), StringFormat("IDS_PreviewTime2"), StringFormat("IDS_PreviewTime3"), StringFormat("IDS_PreviewTime4")) self:SetCDTimer(self.cdTimer, countDown) end end function UISuperGoldStoryPath:RefreshSuperGoldStoryTaskAndLevel() self:InitSuperGoldStoryGroupData() self:RefreshSuperGoldStoryTaskList() self:RefreshSuperGoldStoryLevelList() self:RefreshSuperGoldStoryEndingList() end function UISuperGoldStoryPath:InitSuperGoldStoryGroupData() local startTime = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId).startTime self.curDay = UTL.Time.GetTimestampDay(startTime) self.totalDays = DataSheetManager.SuperGoldEndingOpen[self.heroType]:GetDataCount() self.unLockTaskIDList = {} self.unLockLevelIDList = {} self.serverGroupIDList = MDL.SuperGoldStory.GetServerGroupInfoByActivityID(self.activityId) for _,groupID in ipairs(self.serverGroupIDList) do local groupCfg = DataSheetManager.SuperGoldGroup[self.heroType]:GetDataByGroupChildID(groupID) table.insert(self.unLockTaskIDList, groupCfg.TaskID) if groupCfg.LevelID > 0 then table.insert(self.unLockLevelIDList, groupCfg.LevelID) end end end function UISuperGoldStoryPath:RefreshSuperGoldStoryTaskList() self.taskIDList = MDL.SuperGoldStory.GetTaskIDListByGoldenHeroID(self.heroType) self.superGoldTaskInfoList = {} for k,v in ipairs(self.group_Task) do local taskCfg = DataSheetManager.SuperGoldStoryTask:GetDataByTaskID(self.taskIDList[k]) local taskState = MDL.SuperGoldStory.GetTaskStateByActivityID_HeroType_TaskFatherID(self.activityId, self.heroType, taskCfg.TaskID) local taskInfo = {taskCfg = taskCfg, taskState = taskState} self:RefreshSuperGoldStoryTaskInfo(v.cell_Task, taskInfo) table.insert(self.superGoldTaskInfoList, taskInfo) if self.gotoTaskID and self.gotoTaskID == taskCfg.TaskID then v.cell_Task.state_SelectTask:SetState(1) self:SetSuperGoldStoryContentPosition(v.gameObject.transform) if k == 1 then self.parentView:SetAbortActive(self:IsFirstTaskFinish()) end end if v.state_line then if taskState == MDL.GoldenHeroStory.Enum_TaskState.Lock then if MDL.SuperGoldStory.CheckShowTaskByGoldenHeroID(self.activityId, taskCfg.TaskID) then v.state_line:SetState(0) v.cell_Task.state_SelectTask:SetState(2) else v.state_line:SetState(1) end else v.state_line:SetState(0) end end end end function UISuperGoldStoryPath:RefreshSuperGoldStoryLevelList() self.levelIDList = MDL.SuperGoldStory.GetLevelIDListByGoldenHeroID(self.heroType) self.levelInfoList = {} for k,v in ipairs(self.group_Level) do v.cell_Level.state_SelectLevel:SetState(0) local levelCfg = DataSheetManager.SuperGoldStoryLevel:GetDataByLevelID(self.levelIDList[k]) local levelState = MDL.SuperGoldStory.GetGoldHeroLevelStateByActivityID_LevelID(self.activityId, levelCfg.LevelID) -- 关卡状态 if v.state_line then v.state_line:SetState(levelState == MDL.GoldenHeroStory.LevelState.Lock and 1 or 0) end local levelInfo = {levelCfg = levelCfg, levelState = levelState} self:RefreshSuperGoldStoryLevelInfo(v.cell_Level, levelInfo) table.insert(self.levelInfoList, levelInfo) if self.curLevelID and self.curLevelID == levelCfg.LevelID then v.cell_Level.state_SelectLevel:SetState(1) self:SetSuperGoldStoryContentPosition(v.gameObject.transform) CTL.SuperGoldStory.ChangeSubUIPanel(self.activityId, self.heroType, 1, self.levelInfoList[k]) end end end function UISuperGoldStoryPath:RefreshSuperGoldStoryEndingList() self.endingInfoList = {} for i, endingCfg in DataSheetManager.SuperGoldEndingRecord[self.heroType]:GetEnumerator() do local cell = self.group_Ending[i] if cell then UIUtils.SetLabelText(cell.cell_Ending.txt_Ending, Const_IDS[endingCfg.EndingName]) -- 结局名称 UIUtils.SetImageByAssetBundle(cell.cell_Ending.img_Ending, endingCfg.Pic_Big) -- 结局图片 table.insert(self.endingInfoList, endingCfg) if cell.state_line then cell.state_line:SetState(1) local openEndingIDList = MDL.SuperGoldStory.GetOpenEndingIDListByActivityID(self.activityId) if openEndingIDList then for k,v in ipairs(openEndingIDList) do if v == endingCfg.EndingID then cell.state_line:SetState(v == endingCfg.EndingID and 0 or 1) end end end end end end end function UISuperGoldStoryPath:RefreshSuperGoldStoryTaskInfo(cellTable, data) cellTable.state_SelectTask:SetState(self.gotoTaskID == data.taskCfg.TaskID and 1 or 0) local taskData = DataSheetManager.TaskFatherData:GetDataByID(data.taskCfg.TaskChainID) UIUtils.SetLabelText(cellTable.lab_Task, Const_IDS[taskData.Brief]) -- 任务名称 end function UISuperGoldStoryPath:RefreshSuperGoldStoryLevelInfo(cellTable, data) cellTable.state_SelectLevel:SetState(self.curLevelID == data.levelCfg.LevelID and 1 or 0) UIUtils.SetLabelText(cellTable.lab_Level, Const_IDS[data.levelCfg.BarrierName]) -- 关卡名称 UIUtils.SetImageByAssetBundle(cellTable.img_Level, data.levelCfg.BarrierPic) -- 关卡图片 end function UISuperGoldStoryPath:IsTaskUnlock(taskID) for k,v in ipairs(self.unLockTaskIDList) do if v == taskID then return true end end return false end function UISuperGoldStoryPath:IsLevelUnlock(levelID) for k,v in ipairs(self.unLockLevelIDList) do if v == levelID then return true end end return false end function UISuperGoldStoryPath:SetSuperGoldStoryContentPosition(targetTrans) local xPos = ScreenWidth * 0.5 - targetTrans.localPosition.x self:MoveToPos(self.tran_content, xPos, self.tran_content.localPosition.y, MOVE_DURATION, false) end function UISuperGoldStoryPath:IsFirstTaskFinish() if MDL.SuperGoldStory.GetDoingGroup(self.activityId) > 0 then local doneGroupIds = MDL.SuperGoldStory.GetDoneGroupIDs(self.activityId) if doneGroupIds then for k,v in ipairs(doneGroupIds) do if v == 1 then return true end end end end return false end return UISuperGoldStoryPath