From 880c77888ab4dc21fb65e981c19303792cd323db Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 10 Nov 2021 11:03:18 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=81=87=E6=88=98=E6=96=97?= =?UTF-8?q?=E3=80=91=E5=8A=A0=E5=85=A5=E4=B8=BB=E8=A7=92=E6=8A=80=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Battle/BattleManager.lua | 54 +++++++++++++------ .../~Lua/Modules/Battle/View/BattleView.lua | 10 ++++ .../Modules/Battle/View/GuideBattleLogic.lua | 38 ++++++++++++- .../Modules/Battle/View/GuideBattlePanel.lua | 11 +++- 4 files changed, 94 insertions(+), 19 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua b/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua index b09c87037d..257a68cb7f 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua @@ -652,28 +652,48 @@ end -- 从monsterGroup中获取灵兽数据 function this.GetMonsterDataFromGroup(gId, camp) local list = {} + -- 灵兽 local Monsters = MonsterGroup[gId].Animal - if not Monsters then - return list - end - for i = 1, #Monsters do - local monster = Monsters[i] - local id = monster[1] - local star = monster[2] - local level = monster[3] + if Monsters then + for i = 1, #Monsters do + local monster = Monsters[i] + local id = monster[1] + local star = monster[2] + local level = monster[3] + local mUnit = { + unitId = id, + position = i, + star = star, + playerSex = 0, + forceScore = 0 + } + local pros = this.GetMonsterPros(id, level, star) + mUnit.property = pros + local mSkill = ConfigManager.GetConfigDataByDoubleKey(ConfigName.SpiritAnimalSkill, "SpiritAnimalMatch", id, "StarMatch", star) + mUnit.unitSkillIds = mSkill.Id + list[i] = this.PokemonUnitAdapter(mUnit, camp) + end + end + -- 主角 + local RoleSkills = MonsterGroup[gId].Role + if RoleSkills and #RoleSkills > 0 then local mUnit = { - unitId = id, - position = i, - star = star, + unitId = 20100, + position = 100, + star = 1, playerSex = 0, - forceScore = 0 + forceScore = 0, + property = {} } - local pros = this.GetMonsterPros(id, level, star) - mUnit.property = pros - local mSkill = ConfigManager.GetConfigDataByDoubleKey(ConfigName.SpiritAnimalSkill, "SpiritAnimalMatch", id, "StarMatch", star) - mUnit.unitSkillIds = mSkill.Id - list[i] = this.PokemonUnitAdapter(mUnit, camp) + for _, id in ipairs(RoleSkills) do + if not mUnit.unitSkillIds then + mUnit.unitSkillIds = id + else + mUnit.unitSkillIds = mUnit.unitSkillIds .. "#" .. id + end + end + list[#list+1] = this.PokemonUnitAdapter(mUnit, camp) end return list end diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleView.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleView.lua index b66c3a29e2..0f28665f10 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleView.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleView.lua @@ -413,6 +413,7 @@ function this.InitBattleEvent() BattleLogic.Event:AddEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange) BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange) BattleLogic.Event:AddEvent(BattleEventName.RoleTurnStart, this.RoleTurnChange) + BattleLogic.Event:AddEvent(BattleEventName.BattleStart, this.OnBattleStart) end -- 清除战斗数据 @@ -426,6 +427,7 @@ function this.ClearBattleEvent() BattleLogic.Event:RemoveEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange) BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange) BattleLogic.Event:RemoveEvent(BattleEventName.RoleTurnStart, this.RoleTurnChange) + BattleLogic.Event:RemoveEvent(BattleEventName.BattleStart, this.OnBattleStart) end --敌军出现的表现 @@ -489,6 +491,14 @@ function this.EnemyAppear(isStart) end end +-- 战斗开始回调 +function this.OnBattleStart() + -- 回调UI层 + if this.root.OnBattleStart then + this.root.OnBattleStart() + end +end + -- 角色轮转回调(不出手的位置不会回调) function this.RoleTurnChange(role) -- 回调UI层 diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattleLogic.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattleLogic.lua index 4db57426b8..1cd3c67939 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattleLogic.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattleLogic.lua @@ -1,6 +1,9 @@ local GuideBattleLogic = {} function GuideBattleLogic:Init(guideType) + if not guideType then + return + end self.guideType = guideType self.configList = ConfigManager.GetAllConfigsDataByKey(ConfigName.GuideBattleConfig, "GuideGroup", self.guideType) end @@ -43,6 +46,39 @@ function GuideBattleLogic:RoleTurnChange(curRound, role) 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 @@ -53,7 +89,7 @@ function GuideBattleLogic:OnBattleEnd(func) end local _config = nil for _, con in ipairs(self.configList) do - if con.Round == -1 then + if con.Round == -1 then -- 战后 _config = con break end diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattlePanel.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattlePanel.lua index 25a1689208..3112715be2 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattlePanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/GuideBattlePanel.lua @@ -86,7 +86,11 @@ function this:OnOpen(_fightData, _endFunc, guideType) endFunc = _endFunc fightType = BATTLE_TYPE.Test --判定战斗类型 - this.BG:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_zhandou_changjing_1005") + if guideType == 1 then + this.BG:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_zhandou_changjing_1005") + else + this.BG:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_zhandou_changjing_2") + end this.BtnGM:SetActive(true) this.ButtonLock:SetActive(false) @@ -159,6 +163,11 @@ function this.BattleEnd(result) end) end +function this.OnBattleStart(order) + --显示波次 + GuideBattleLogic:OnBattleStart() +end + function this.OnOrderChanged(order) --显示波次