local GuildEscort_Controller = {} local private = {} local EventSystem = require 'Event/EventSystem' local TownCartManager = require "Battle/Logic/MainLoop/SyncMoveManager/TownCartManager" local FrameContentSize = 42 local GuildEscortMainNoticeTime = "GuildEscortMainNoticeTime" function GuildEscort_Controller.OnStartup() EventSystem.Regist(EventID.GuildEscort_ContinueFindGuildEscortNPC, private.ContinueFindOnce) EventSystem.Regist(EventID.GuildEscort_MyCartBorn, GuildEscort_Controller.BeginFollowCart) EventSystem.Regist(EventID.SyncEscort_ShowKillTitleInfo, private.ShowKillTitleInfo) EventSystem.Regist(EventID.TimerWheelStartTimeOver, private.OnGuildEscortActivityStart) EventSystem.Regist(EventID.TimerWheelEndTimeOver, private.OnGuildEscortActivityEnd) EventSystem.Regist(EventID.GuildEscort_CartFollow, private.OnFollowStateChange) GuildEscort_Controller.EscortTeamAwardUp = DataSheetManager.ConstData:GetDataByID("EscortTeamAwardUp").IntValue private.FindingLevelItemID = DataSheetManager.ConstData:GetDataByID("EscortRobPosition").IntValue private.escortlevel = DataSheetManager.ConstData:GetDataByID("Escortlevel").IntValue private.FollowCartUniqId = "" private.KillInfo = { name_left = "", heroId_left = 0, name_right = "", heroId_right = 0, isKillerEnemy = false, } end -- Start 传送到场景相关 -- isEscort 是否是运镖 function GuildEscort_Controller.GotoGuildEscortScene(isEscort) if not MDL.Guild.IsHasGuild() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild"]) else if MDL.Team.IsFollowing() or GuildEscort_Controller.IsTransport() then -- 如果正在跟随、押运,则禁止寻路 CTL.Tips.AddTipsMsg(Const_IDS["IDS_Team_FollowCanNotDoThis"]) else NotSyncBattleSetter.StopAutoFightPathInTown() --停止现在的寻路(主要是为了清空其他寻路的缓存,比如TeamDungeon) if isEscort then -- 运镖状态直接前往运镖npc处 if CTL.WarZone.IsWarZoneOpen() then local warZoneActivityData = DataSheetManager.ZoneActivityData:GetDataByZoneID(LuaConst.ActivityType.GuildEscort) private.FindingNpcItemID = warZoneActivityData.ZoneNPCItemID else local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildEscort) private.FindingNpcItemID = activityData.NPCItemID end NotSyncBattleSetter.FindPathByNPCIDAndRide(private.FindingNpcItemID) else -- 劫镖状态前往对应的LevelItem点位 private.FindingMapId = 0 if CTL.WarZone.IsWarZoneOpen() then local warZoneActivityData = DataSheetManager.ZoneActivityData:GetDataByZoneID(LuaConst.ActivityType.GuildEscort) private.FindingMapId = warZoneActivityData.ZoneMapID else local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildEscort) private.FindingMapId = activityData.MapID end private.FindingLevelItem = LevelItemManager.GetLevelItem(private.FindingMapId, private.FindingLevelItemID) NotSyncBattleSetter.FindPathByLevelItem(private.FindingMapId, private.FindingLevelItem, GuildEscort_Controller.CutEscortFindPathCallBack, nil, true) end -- 准备寻路,关闭界面 UIManager.RecoverTopView() CTL.HomeMain.CloseOpenView() end end end function private.ContinueFindOnce() if private.FindingNpcItemID then NotSyncBattleSetter.FindPathByNPCIDAndRide(private.FindingNpcItemID) private.FindingNpcItemID = nil end if private.FindingLevelItem then NotSyncBattleSetter.FindPathByLevelItem(private.FindingMapId, private.FindingLevelItem, GuildEscort_Controller.CutEscortFindPathCallBack, nil, true) private.FindingLevelItem = nil end end function GuildEscort_Controller.OnStopFindPath() private.FindingNpcItemID = nil private.FindingLevelItem = nil end function GuildEscort_Controller.CutEscortFindPathCallBack() CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Escort_RobGuild)) end -- End 传送到场景相关 -- 打开主界面 function GuildEscort_Controller.OpenGuildEscortMainPanel() UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildEscortMainPanel) end -- 获取运镖活动人数 和 人数对应的奖励、速度加成 function GuildEscort_Controller.GetTeamBonus() local teamMemberNum = MDL.Team.GetTeamMemberNumbers() ~= 0 and MDL.Team.GetTeamMemberNumbers() or 1 local ratio = tonumber(GuildEscort_Controller.EscortTeamAwardUp) * (teamMemberNum - 1) return teamMemberNum, ratio end -- Start 镖车跟随相关 function GuildEscort_Controller.BeginFollowCart(uniqId) if uniqId and private.FollowCartUniqId ~= uniqId then private.FollowCartUniqId = uniqId TownCartManager.BeginFollowCart_MySelf(true) else TownCartManager.BeginFollowCart_MySelf(false) end end -- End 镖车跟随相关 -- 判断是否处于运镖状态(有运镖任务 and 任务是doing) function GuildEscort_Controller.IsTransport() local convoyTaskTb = MDL.Task.GetTaskList(MDL.Task.Enum_TaskType.Convoy) if convoyTaskTb ~= nil then for k, v in pairs(convoyTaskTb) do if v.State == MDL.Task.Enum_TaskState.Doing then return true end end end return false end -- 获取运镖称号配置(运镖时 替换 正常玩家佩戴的称号) function GuildEscort_Controller.GetGuildEscortTitle(quality) local guildEscortData = DataSheetManager.GuildEscortData:GetDataByID(quality) if guildEscortData ~= nil then return Const_IDS.IDS_Escort_BlueName, guildEscortData.Icon, FrameContentSize, UTL.Color.ModelNameColor.White, UTL.Color.ModelNameColor.White else logging.error(LTAG.ERROR, "没有找到品质为:", quality, " 的镖车数据,请检查配置表 或者 下发数据") return "", "", UTL.Color.ModelNameColor.White, UTL.Color.ModelNameColor.White end end -- 判断是否是队长 & 提示 function GuildEscort_Controller.JudgeTeamLeader(callBack) if CTL.Team.IsInTeam() and not CTL.Team.IsSelfLeader() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1757_InfoCode_Escort_NoTeamLeader"]) else callBack() end end -- 退出运镖判断 function GuildEscort_Controller.GuildEscortQuit(callBack) if CTL.GuildEscort.IsTransport() then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildEscortQuit) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildEscortQuit, {QuitCallBack = function() BattleDataGetter.StopFollowNPC(false) callBack() MDL.GuildEscort.NoticeC2GGiveUpEscortTask() end}) end else callBack() end end -- 设置活动红点 function GuildEscort_Controller.SetActivityRedPoint() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GuildEscort) and CTL.Activities.IsOpeningTime(LuaConst.ActivityType.GuildEscort) then local time = MDL.RedPoint.GetRedPointTimeByType(MDL.RedPoint.RedPointType.GuildEscort) if time and time > 0 and UTL.Time.IsTimestampSameDay(time) then EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildEscort, false) else -- 判断是否还有活动次数 local residueEscortNum = MDL.GuildEscort.GetEscortNumLimit() local residueCutEscortNum = MDL.GuildEscort.GetCutEscortNumLimit() if residueEscortNum > 0 or residueCutEscortNum > 0 then EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildEscort, true) else EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildEscort, false) end end else EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildEscort, false) end end function GuildEscort_Controller.OpenMainPanel() if MDL.Guild.IsHasGuild() then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildActivityEscort) end end -- 展示劫镖战斗奖励 function GuildEscort_Controller.ShowCutEscortReward() local rewardId = MDL.GuildEscort.GetEscortGetReward() if rewardId <= 0 then return end -- 此处不用判断道具数量,函数内部会进行判断 CTL.Bag.ShowGainItem(rewardId) MDL.GuildEscort.CancelEscortGetReward() end -- 战斗内击杀提示 function private.ShowKillTitleInfo(name_left, heroId_left, name_right, heroId_right, isKillerEnemy) -- 保证private.KillInfo的复用 private.KillInfo[name_left] = name_left private.KillInfo[heroId_left] = heroId_left private.KillInfo[name_right] = name_right private.KillInfo[heroId_right] = heroId_right private.KillInfo[isKillerEnemy] = isKillerEnemy if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIBattleKillTitle) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleKillTitle, killInfo) else EventSystem.Dispatch(EventID.UIBattle_KillTitle_StartShow, killInfo) end end -- 活动开始主界面提示 function private.OnGuildEscortActivityStart(timeId, activityId, timeIndex) if activityId == LuaConst.ActivityType.GuildEscort then if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Guild) and MDL.Guild.IsHasGuild() and not CTL.GuildEscort.IsTransport() then GuildEscort_Controller.SetActivityRedPoint() if CTL.Activities.IsInActivitySpecificLevel() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIActivitiesRemind, {LuaConst.ActivityType.GuildEscort}) else CTL.HomeMain.AddTownHomeDelayView(Const_UI_Lua.UIEnum.UIActivitiesRemind, {LuaConst.ActivityType.GuildEscort}) end end GuildEscort_Controller.ShowMainNotice(false) end end -- 活动结束处理 function private.OnGuildEscortActivityEnd() GuildEscort_Controller.ShowMainNotice(true) GuildEscort_Controller.SetActivityRedPoint() end -- 信息球显隐 function GuildEscort_Controller.ShowMainNotice(isShow) if isShow then local guildEscortMainNoticeTime = PersistentData.PlayerData:Get(GuildEscortMainNoticeTime, 0) if guildEscortMainNoticeTime == 0 then GuildEscort_Controller.ShowMainNotice(false) else local isOpen = CTL.Activities.IsOpeningTime(LuaConst.ActivityType.GuildEscort) if MDL.Guild.IsHasGuild() and UTL.Time.GetServerTimestamp() > guildEscortMainNoticeTime and not isOpen then CTL.HomeMain.AddMainNotice(CTL.HomeMain.NoticeType.GuildEscortReport) end end else CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.GuildEscortReport) -- 打开时移除主界面提示 local isOpen = CTL.Activities.IsOpeningTime(LuaConst.ActivityType.GuildEscort) if isOpen then PersistentData.PlayerData:Set(GuildEscortMainNoticeTime, UTL.Time.GetServerTimestamp() + CTL.Activities.GetTimeToClose(LuaConst.ActivityType.GuildEscort), true) else PersistentData.PlayerData:Set(GuildEscortMainNoticeTime, UTL.Time.GetServerTimestamp() + CTL.Activities.GetNextTimeToOpen(LuaConst.ActivityType.GuildEscort), true) end end end --设置国家标识 function GuildEscort_Controller.SetUICountryShow(parent, state, countryId, text) if countryId == nil or countryId == MDL.Country.CountryType.None then UIUtils.SetActive(parent, false) else UIUtils.SetActive(parent, true) state:SetState(countryId - 1) if text then UIUtils.SetLabelText(text, CTL.Country.GetCountryNameIDS(countryId)) end end end function private.OnFollowStateChange(playerEntity, isFollow, followSpd) playerEntity.ExpEntity:OnFollowStateChange(isFollow, followSpd) end return GuildEscort_Controller