2021-04-20 13:58:00 +08:00
|
|
|
local GuideBattleLogic = {}
|
2021-03-19 18:14:52 +08:00
|
|
|
|
|
|
|
function GuideBattleLogic:Init(guideType)
|
|
|
|
self.guideType = guideType
|
2021-11-10 09:48:42 +08:00
|
|
|
self.configList = ConfigManager.GetAllConfigsDataByKey(ConfigName.GuideBattleConfig, "GuideGroup", self.guideType)
|
2021-03-19 18:14:52 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function GuideBattleLogic:RoleTurnChange(curRound, role)
|
|
|
|
local curCamp = role.camp
|
|
|
|
local curPos = role.position
|
2021-11-10 09:48:42 +08:00
|
|
|
-- 没有就不引导了
|
|
|
|
if not self.configList or #self.configList <= 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local _config = nil
|
|
|
|
for _, con in ipairs(self.configList) do
|
|
|
|
if con.Round == curRound and con.Camp == curCamp and con.Turn == curPos then
|
|
|
|
_config = con
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not _config then
|
2021-03-19 18:14:52 +08:00
|
|
|
return
|
|
|
|
end
|
|
|
|
-- 对话形式的引导
|
2021-11-10 09:48:42 +08:00
|
|
|
if _config.TriggerType == 1 then
|
2021-03-19 18:14:52 +08:00
|
|
|
BattleManager.SetGuidePause(true)
|
2021-11-10 09:48:42 +08:00
|
|
|
local storyId = _config.TriggerId
|
2021-03-19 18:14:52 +08:00
|
|
|
StoryManager.EventTrigger(storyId, function()
|
|
|
|
BattleManager.SetGuidePause(false)
|
|
|
|
end)
|
|
|
|
-- 引导形式的引导
|
2021-11-10 09:48:42 +08:00
|
|
|
elseif _config.TriggerType == 2 then
|
2021-03-19 18:14:52 +08:00
|
|
|
BattleManager.SetGuidePause(true)
|
2021-11-10 09:48:42 +08:00
|
|
|
local guideId = _config.TriggerId
|
2021-03-19 18:14:52 +08:00
|
|
|
GuideManager.ShowGuide(guideId)
|
|
|
|
local function _onGuideDone()
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Guide.BattleGuideDone, _onGuideDone)
|
|
|
|
BattleManager.SetGuidePause(false)
|
|
|
|
end
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Guide.BattleGuideDone, _onGuideDone)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-13 15:10:40 +08:00
|
|
|
function GuideBattleLogic:OnBattleEnd(func)
|
2021-11-10 09:48:42 +08:00
|
|
|
-- 没有就不引导了
|
|
|
|
if not self.configList or #self.configList <= 0 then
|
|
|
|
if func then
|
|
|
|
func()
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local _config = nil
|
|
|
|
for _, con in ipairs(self.configList) do
|
|
|
|
if con.Round == -1 then
|
|
|
|
_config = con
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not _config then
|
|
|
|
if func then
|
|
|
|
func()
|
|
|
|
end
|
|
|
|
return
|
2021-04-13 15:10:40 +08:00
|
|
|
end
|
|
|
|
-- 对话形式的引导
|
2021-11-10 09:48:42 +08:00
|
|
|
if _config.TriggerType == 1 then
|
2021-04-13 15:10:40 +08:00
|
|
|
BattleManager.SetGuidePause(true)
|
2021-11-10 09:48:42 +08:00
|
|
|
local storyId = _config.TriggerId
|
2021-04-13 15:10:40 +08:00
|
|
|
StoryManager.EventTrigger(storyId, function()
|
|
|
|
BattleManager.SetGuidePause(false)
|
|
|
|
if func then
|
|
|
|
func()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end
|
2021-03-19 18:14:52 +08:00
|
|
|
|
|
|
|
return GuideBattleLogic
|