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

184 lines
5.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)
self.PlayerSkillCount = {} -- 主角释放技能次数计数器
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:BattleRoundEnd(round)
-- 没有就不引导了
if not self.configList or #self.configList <= 0 then
return
end
local _config = nil
for _, con in ipairs(self.configList) do
if con.Round == -3 and con.Camp == round then -- 战中第n回合触发
_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)
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
--
function GuideBattleLogic:OnSkillCastEnd(skill)
-- 这里只判断主角技能
if skill.owner.position ~= 100 then
return
end
if not self.PlayerSkillCount[skill.owner.camp] then
self.PlayerSkillCount[skill.owner.camp] = 0
end
-- 释放技能次数+1
self.PlayerSkillCount[skill.owner.camp] = self.PlayerSkillCount[skill.owner.camp] + 1
-- 没有就不引导了
if not self.configList or #self.configList <= 0 then
return
end
local _config = nil
for _, con in ipairs(self.configList) do
-- 主角释放技能次数判断
if con.Round == -4 and con.Camp == skill.owner.camp and con.Turn == self.PlayerSkillCount[skill.owner.camp] 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)
if func then
func()
end
end)
end
end
return GuideBattleLogic