miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattleLogic.lua

116 lines
3.1 KiB
Lua

local GuideBattleLogic = {}
function GuideBattleLogic:Init(guideType)
if not guideType then
return
end
self.guideType = guideType
self.configList = ConfigManager.TryGetAllConfigsDataByKey(ConfigName.GuideBattleConfig, "GuideGroup", self.guideType)
end
function GuideBattleLogic:RoleTurnChange(curRound, role)
local curCamp = role.camp
local curPos = role.position
-- 没有就不引导了
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
return
end
-- 对话形式的引导
if _config.TriggerType == 1 then
BattleManager.SetGuidePause(true)
local storyId = _config.TriggerId
StoryManager.EventTrigger(storyId, function()
BattleManager.SetGuidePause(false)
end)
-- 引导形式的引导
elseif _config.TriggerType == 2 then
BattleManager.SetGuidePause(true)
local guideId = _config.TriggerId
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
function GuideBattleLogic:OnBattleStart(func)
-- 没有就不引导了
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 == -2 then -- 战前
_config = con
break
end
end
if not _config then
if func then
func()
end
return
end
-- 对话形式的引导
if _config.TriggerType == 1 then
BattleManager.SetGuidePause(true)
local storyId = _config.TriggerId
StoryManager.EventTrigger(storyId, function()
BattleManager.SetGuidePause(false)
if func then
func()
end
end)
end
end
function GuideBattleLogic:OnBattleEnd(func)
-- 没有就不引导了
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
end
-- 对话形式的引导
if _config.TriggerType == 1 then
BattleManager.SetGuidePause(true)
local storyId = _config.TriggerId
StoryManager.EventTrigger(storyId, function()
BattleManager.SetGuidePause(false)
if func then
func()
end
end)
end
end
return GuideBattleLogic