local EventSystem = require('Event/EventSystem') local GoldenHeroStory_Controller = {} local private = {} local NotShowSkipTaskPopUp = "NotShowSkipTaskPopUp" --不展示跳过剧情任务弹窗 function GoldenHeroStory_Controller.OnStartup() EventSystem.Regist(EventID.Level_AddBoxReward, private.ShowStoryLevelBoxReward) private.storyViewBossButtonNode = nil end function GoldenHeroStory_Controller.OnShutdown() private.storyViewBossButtonNode = nil end function GoldenHeroStory_Controller.GetStoryViewBossButtonNode() return private.storyViewBossButtonNode end function GoldenHeroStory_Controller.SetStoryViewBossButtonNode(comp) private.storyViewBossButtonNode = comp end ---@public 打开章节开幕界面 function GoldenHeroStory_Controller.OpenGoldenHeroStoryStartPanel(chapterID) UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryChapter, {chapterID = chapterID}) end ---@public 打开结局界面 function GoldenHeroStory_Controller.OpenGoldHeroStoryEndingPanel(endingID) local endingInfo = DataSheetManager.GoldHeroEndingRecord:GetDataByEndingID(endingID) UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryAchieve, {endingID = endingID, endingInfo = endingInfo}) end ---@public 打开关卡成就界面 function GoldenHeroStory_Controller.OpenUIGoldenHeroStoryStarPanel(activityId, LevelCfg) UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryStar, {activityId = activityId, LevelCfg = LevelCfg}) end ---@private 战斗内宝箱奖励预览打开奖励界面 function private.ShowStoryLevelBoxReward(playerID, boxRewardID, addAmount) local itemList = DataSheetManager.BoxRewardData:GetDataByID(boxRewardID).Item_Table UIManager.OpenView(Const_UI_Lua.UIEnum.UIRewardGainPanel, {tipsIDS = "IDS_GoldHeroActivity_ActivityLevel_BoxHint1", itemList = itemList}) end ---@public 获取奖励物品信息并整理成表返回打开结算界面 function GoldenHeroStory_Controller.ShowBattleSummary(msg, activityId) local rewardList = {} for k,v in ipairs(msg.Resp.Rewards) do local itemData = DataSheetManager.ItemData:GetDataByID(v.ItemId) table.insert(rewardList, {Item = itemData, Count = v.ItemCount}) end CTL.HomeMain.CloseOpenView() UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryLevelSummary, {Reward = rewardList, Win = msg.isWin, Time = msg.passTime}) end ---@public 退出副本回来打开指定的秘闻关卡界面 function GoldenHeroStory_Controller.OpenStoryAndLevelView(activityId, levelId, levelIsFirst) if not MDL.GoldenHeroMain.IsActivityInFuncTime(activityId) then return end local heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(activityId) if levelIsFirst then local groupID, taskID for k,v in DataSheetManager.GoldHeroActivityGroup[heroType]:GetEnumerator() do if #v.LevelID > 0 then for i,levelID in ipairs(v.LevelID) do if levelID == levelId then if i < #v.LevelID then taskID = v.TaskID[i+1] elseif #v.NextGroupID > 0 then taskID = DataSheetManager.GoldHeroActivityGroup[heroType]:GetDataByGroupID(v.NextGroupID[1]).TaskID[1] end end end end end local taskCfg = DataSheetManager.GoldHeroActivityTask:GetDataByTaskID(taskID) local taskState = MDL.GoldenHeroStory.GetTaskStateByActivityID_HeroType_TaskFatherID(activityId, heroType, taskCfg.TaskID) if taskState == MDL.GoldenHeroStory.Enum_TaskState.Doing then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroStory, {heroType = heroType, activityId = activityId, taskId = taskID}) else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroStory, {heroType = heroType, activityId = activityId, levelId = levelId}) end else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroStory, {heroType = heroType, activityId = activityId, levelId = levelId}) end end ---@public 任务触发器触发,客户端主动接任务 function GoldenHeroStory_Controller.TaskTriggerReceive(taskLineID) local isFinishTask = MDL.Task.GetCompletedTaskByID(taskLineID) -- 需判断这个任务是否是做过的或正在做的 if not isFinishTask then MDL.Task.ClientAcceptTaskRequest(taskLineID) return end end ---@public 秘闻关卡的消耗体力道具是否足够 function GoldenHeroStory_Controller.IsEnergyEnough(activityId, levelId) local levelCfg = DataSheetManager.GoldHeroActivityLevel:GetDataByID(levelId) local hasNum = MDL.GoldenHeroStory.GetGoldHeroLevelCurrencyCountByActivityId(activityId) return hasNum >= levelCfg.EnergyNum end function GoldenHeroStory_Controller.ShowSkipTaskPopUp(activityId, heroType, DoTaskFunc) local tb = PersistentData.PlayerData:Get(NotShowSkipTaskPopUp) if not tb then tb = {} end local refinedHintTime = tb[heroType] or 0 local condition, content, excuteFunc if MDL.LaterEnter.IsCanQuickSkip(MDL.LaterEnter.LaterEnterQuickPassType.GoldHeroActivity) then condition = not UTL.Time.IsTimestampSameDay(refinedHintTime) content = Const_IDS.IDS_LaterEnter_Hint_13 excuteFunc = function() MDL.LaterEnter.LaterEnterQuickPassReq(MDL.LaterEnter.LaterEnterQuickPassType.GoldHeroActivity, {activityId}) end else condition = MDL.GoldenHeroStory.IsCanSkipLevel(activityId) and not UTL.Time.IsTimestampSameDay(refinedHintTime) and not MDL.GoldenHeroStory.IsUnclockAllEndingByActivityID(activityId) content = Const_IDS.IDS_GoldHeroActivityJump_1 excuteFunc = function() MDL.GoldenHeroStory.GoldHeroSkipAllStoryReq(activityId) end end if condition then UTL.MessageBox.ShowOKCancelToggleBox(nil, content, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarZoneAuction_27), excuteFunc, function(isOn) if isOn then tb[heroType] = UTL.Time.GetServerTimestamp() else tb[heroType] = nil end PersistentData.PlayerData:Set(NotShowSkipTaskPopUp, tb, true) end, DoTaskFunc) else DoTaskFunc() end end return GoldenHeroStory_Controller