1169 lines
40 KiB
Lua
1169 lines
40 KiB
Lua
require("Base/BasePanel")
|
||
require("Modules.Battle.Config.PokemonEffectConfig")
|
||
local FEAConfig = require("Modules/Battle/Config/FightEffectAudioConfig")
|
||
-- local RoleShowView = require("Modules/Battle/View/BattleRoleShowView")
|
||
local BattleView = {}
|
||
local this = BattleView
|
||
|
||
--敌军站位分布
|
||
--敌军站位根节点Y坐标
|
||
local posY = 380
|
||
local posOffset = 0
|
||
|
||
local tbRole = {}
|
||
local tbRoleDispose = {}
|
||
|
||
local tbMonster = {}
|
||
local tbMonsterDispose = {}
|
||
|
||
local tbWeapon = {}
|
||
local tbWeaponDispose = {}
|
||
|
||
|
||
local playerHP = 0
|
||
local playerMaxHP = 0
|
||
local enemyHP = 0
|
||
local enemyMaxHP = 0
|
||
local playerTmpHp
|
||
local enemyTmpHp
|
||
|
||
local delayRecycleList = {}
|
||
|
||
local LastDebugTime -- 点击调试键的时间间隔需要大于0.1秒
|
||
|
||
local scene = {
|
||
"r_zhandou_changjing016",
|
||
"r_zhandou_changjing016",
|
||
"r_zhandou_changjing016",
|
||
}
|
||
|
||
local loadAsset = function(path)
|
||
local go = poolManager:LoadAsset(path, PoolManager.AssetType.GameObject)
|
||
local layer = tonumber(go.name) or 0
|
||
local battleSorting = BattleManager.GetBattleSorting()
|
||
Util.AddParticleSortLayer(go, battleSorting - layer)
|
||
go.name = tostring(battleSorting)
|
||
--- 播放音效
|
||
local audioData = FEAConfig.GetAudioData(path)
|
||
if audioData then
|
||
SoundManager.PlaySound(audioData.name)
|
||
end
|
||
return go
|
||
end
|
||
|
||
--所有需要延迟回收的资源走该接口,当回调执行前界面已被销毁时,不会报错
|
||
local addDelayRecycleRes = function(path, go, recycleTime, delayFunc, delayTime)
|
||
if not delayRecycleList[path] then
|
||
delayRecycleList[path] = {}
|
||
end
|
||
table.insert(delayRecycleList[path], go)
|
||
|
||
if delayTime and delayTime < recycleTime then
|
||
Timer.New(delayFunc, delayTime):Start()
|
||
Timer.New(function ()
|
||
if not delayRecycleList[path] then return end
|
||
go:SetActive(false)
|
||
for i=1, #delayRecycleList[path] do
|
||
if delayRecycleList[path][i] == go then
|
||
poolManager:UnLoadAsset(path, go, PoolManager.AssetType.GameObject)
|
||
table.remove(delayRecycleList[path], i)
|
||
break
|
||
end
|
||
end
|
||
end, recycleTime):Start()
|
||
else
|
||
Timer.New(function ()
|
||
if not delayRecycleList[path] then return end
|
||
go:SetActive(false)
|
||
for i=1, #delayRecycleList[path] do
|
||
if delayRecycleList[path][i] == go then
|
||
poolManager:UnLoadAsset(path, go, PoolManager.AssetType.GameObject)
|
||
table.remove(delayRecycleList[path], i)
|
||
break
|
||
end
|
||
end
|
||
if delayFunc then
|
||
delayFunc()
|
||
end
|
||
end, recycleTime):Start()
|
||
end
|
||
end
|
||
|
||
function this:GetABossRage(i)
|
||
local rage = this.bossRageRoot.transform:Find("rage_"..i)
|
||
if not rage then
|
||
rage = newObjToParent(this.bossRage, this.bossRageRoot)
|
||
rage.transform.localScale = Vector3.one * 1.5
|
||
rage:SetActive(false)
|
||
rage.name = "rage_"..i
|
||
end
|
||
return rage
|
||
end
|
||
|
||
function this:InitComponent(root, go)
|
||
this.spLoader = SpriteLoader.New()
|
||
BattleManager.SetSpLoader(this.spLoader)
|
||
-- body
|
||
this.root = root
|
||
this.gameObject = go.gameObject
|
||
this.transform = go.transform
|
||
|
||
this.BG = Util.GetGameObject(self.gameObject, "BG")
|
||
-- this.LastBG = Util.GetGameObject(self.gameObject, "LastBG")
|
||
|
||
this.BuffItem = Util.GetGameObject(this.gameObject, "BuffIcon")
|
||
this.RoleItem = Util.GetGameObject(this.gameObject, "Role")
|
||
this.EnemyItem = Util.GetGameObject(this.gameObject, "Enemy")
|
||
this.EnemyItem2 = Util.GetGameObject(this.gameObject, "Enemy2")
|
||
this.Monster = Util.GetGameObject(this.gameObject, "Monster")
|
||
|
||
this.UpRoot = Util.GetGameObject(this.gameObject, "UpRoot")
|
||
this.DownRoot = Util.GetGameObject(this.gameObject, "DownRoot")
|
||
|
||
this.DiffMonster = Util.GetGameObject(this.DownRoot, "teamSkill")
|
||
this.DiffMonsterFlag = false
|
||
this.DiffMonsterSlider = Util.GetGameObject(this.DiffMonster, "slider"):GetComponent("Image")
|
||
this.DiffMonsterIcon = Util.GetGameObject(this.DiffMonster, "icon"):GetComponent("Image")
|
||
|
||
this.EnemyDiffMonster = Util.GetGameObject(this.UpRoot, "teamSkill")
|
||
this.EnemyDiffMonsterFlag = false
|
||
this.EnemyDiffMonsterSlider = Util.GetGameObject(this.EnemyDiffMonster, "slider"):GetComponent("Image")
|
||
this.EnemyDiffMonsterIcon = Util.GetGameObject(this.EnemyDiffMonster, "icon"):GetComponent("Image")
|
||
|
||
this.bossRoot = Util.GetGameObject(this.UpRoot, "boss")
|
||
this.bossBuffRoot = Util.GetGameObject(this.bossRoot, "buff")
|
||
this.bossRageRoot = Util.GetGameObject(this.bossRoot, "rage")
|
||
this.bossRage = Util.GetGameObject(this.bossRoot, "rage/Image")
|
||
this.bossRageList = {}
|
||
for i = 1, 10 do
|
||
this.bossRageList[i] = this:GetABossRage(i)
|
||
end
|
||
|
||
Util.GetGameObject(this.UpRoot, "EnemyHP"):SetActive(false)
|
||
Util.GetGameObject(this.DownRoot, "PlayerHP"):SetActive(false)
|
||
this.EnemyHP = Util.GetGameObject(this.UpRoot, "EnemyHP/hp"):GetComponent("Image")
|
||
this.EnemyHPTxt = Util.GetGameObject(this.UpRoot, "EnemyHP/Text"):GetComponent("Text")
|
||
this.PlayerHP = Util.GetGameObject(this.DownRoot, "PlayerHP/hp"):GetComponent("Image")
|
||
this.PlayerHPTxt = Util.GetGameObject(this.DownRoot, "PlayerHP/Text"):GetComponent("Text")
|
||
|
||
this.PlayerPanel = Util.GetGameObject(self.gameObject, "RolePanel")
|
||
this.EnemyPanel = Util.GetGameObject(self.gameObject, "EnemyPanel")
|
||
|
||
this.FirstEffect = Util.GetGameObject(this.gameObject, "Start")
|
||
this.ThirdEffect = Util.GetGameObject(this.gameObject, "Third")
|
||
this.skillEffectRoot = Util.GetGameObject(this.gameObject, "skillEffectRoot")
|
||
|
||
this.Cache = Util.GetGameObject(this.gameObject, "cache")
|
||
--人物角色costing
|
||
this.enemySkillCast = Util.GetGameObject(this.transform, "EnemySkillCast")
|
||
this.enemySkillCastRoot = Util.GetGameObject(this.transform, "EnemySkillCast/TongYong_Casting_Shang/DongHua/RENWU")
|
||
|
||
this.mySkillCast = Util.GetGameObject(this.transform, "mySkillCast")
|
||
this.mySkillCastRoot = Util.GetGameObject(this.transform, "mySkillCast/TongYong_Casting_Xia/DongHua/RENWU")
|
||
--灵兽casting
|
||
this.lingshouCastUp = Util.GetGameObject(this.transform, "LingshouCastUp")
|
||
this.lingshouCastUpRoot = Util.GetGameObject(this.transform, "LingshouCastUp/EFFECT_Casting_LingShou_Shang/DongHua/RENWU")
|
||
|
||
this.lingshouCastDown = Util.GetGameObject(this.transform, "LingshouCastDown")
|
||
this.lingshouCastDownRoot = Util.GetGameObject(this.transform, "LingshouCastDown/EFFECT_Casting_LingShou_Xia/DongHua/RENWU")
|
||
this.lingshouUpEffect=Util.GetGameObject(this.transform, "LingshouCastUp/EFFECT_Casting_LingShou_Shang/DongHua/RENWU/fx_kapianfanmian")
|
||
this.lingshouDownEffect=Util.GetGameObject(this.transform, "LingshouCastDown/EFFECT_Casting_LingShou_Xia/DongHua/RENWU/fx_kapianfanmian")
|
||
this.lingshouUpEffect:SetActive(false)
|
||
this.lingshouDownEffect:SetActive(false)
|
||
this.enemyMonster=Util.GetGameObject(this.transform, "enemyMonster")
|
||
this.playerMonster=Util.GetGameObject(this.transform, "playerMonster")
|
||
-- this.ElementalResonanceView = SubUIManager.Open(SubUIConfig.ElementalResonanceView, self.gameObject.transform)
|
||
-- this.ElementalResonanceView2 = SubUIManager.Open(SubUIConfig.ElementalResonanceView, self.gameObject.transform)
|
||
-- this.ElementalResonanceView.elementalResonanceBtn:SetActive(false)
|
||
-- this.ElementalResonanceView2.elementalResonanceBtn:SetActive(false)
|
||
|
||
this.player = Util.GetGameObject(this.DownRoot, "player")
|
||
this.enemy = Util.GetGameObject(this.UpRoot, "enemy")
|
||
this.player:SetActive(false)
|
||
this.enemy:SetActive(false)
|
||
|
||
|
||
this.mySkillCast:SetActive(false)
|
||
this.enemySkillCast:SetActive(false)
|
||
this.lingshouCastUp:SetActive(false)
|
||
this.lingshouCastDown:SetActive(false)
|
||
|
||
this.MonsterList = {}
|
||
for i = 1, 6 do
|
||
this.MonsterList[i] = Util.GetGameObject(this.gameObject, "playerMonster/list/"..i)
|
||
this.MonsterList[6 + i] = Util.GetGameObject(this.gameObject, "enemyMonster/list/"..i)
|
||
end
|
||
this.MonsterList[100] = Util.GetGameObject(this.gameObject, "playerMonster/list/100")
|
||
this.MonsterList[101] = Util.GetGameObject(this.gameObject, "enemyMonster/list/101")
|
||
this.fightIdText = Util.GetGameObject(this.gameObject, "fightId"):GetComponent("Text")
|
||
end
|
||
function this:BindEvent()
|
||
|
||
end
|
||
|
||
-- 正常接口
|
||
function this:OnOpen(data, _fightType, isBoss)
|
||
-- this.ElementalResonanceView:OnOpen({sortOrder = BattleManager.GetBattleSorting()})
|
||
-- this.ElementalResonanceView2:OnOpen({sortOrder = BattleManager.GetBattleSorting()})
|
||
this:Init()
|
||
this:SetData(data.fightData, data.fightSeed, data.fightType, data.maxRound, data.fightId, isBoss)
|
||
this.fightType = _fightType
|
||
end
|
||
|
||
function this:OnSortingOrderChange(battleSorting)
|
||
-- 层级
|
||
this.FirstEffect:GetComponent("Canvas").sortingOrder = battleSorting + 30
|
||
this.skillEffectRoot:GetComponent("Canvas").sortingOrder = battleSorting + 40
|
||
|
||
local skillSorting = battleSorting + 90
|
||
this.mySkillCast:GetComponent("Canvas").sortingOrder = skillSorting
|
||
this.enemySkillCast:GetComponent("Canvas").sortingOrder = skillSorting
|
||
|
||
this.enemyMonster:GetComponent("Canvas").sortingOrder = battleSorting+200
|
||
this.playerMonster:GetComponent("Canvas").sortingOrder = battleSorting+200
|
||
this.lingshouCastUp:GetComponent("Canvas").sortingOrder = skillSorting
|
||
this.lingshouCastDown:GetComponent("Canvas").sortingOrder = skillSorting
|
||
if not self.oSortingOrder then
|
||
self.oSortingOrder = skillSorting
|
||
Util.AddParticleSortLayer(self.mySkillCast, skillSorting)
|
||
Util.AddParticleSortLayer(self.enemySkillCast, skillSorting)
|
||
Util.AddParticleSortLayer(self.lingshouCastUp,skillSorting)
|
||
Util.AddParticleSortLayer(self.lingshouCastDown,skillSorting)
|
||
else
|
||
Util.AddParticleSortLayer(self.mySkillCast, skillSorting - self.oSortingOrder)
|
||
Util.AddParticleSortLayer(self.enemySkillCast, skillSorting - self.oSortingOrder)
|
||
Util.AddParticleSortLayer(self.lingshouCastUp,skillSorting- self.oSortingOrder)
|
||
Util.AddParticleSortLayer(self.lingshouCastDown,skillSorting- self.oSortingOrder)
|
||
end
|
||
|
||
for _, v in pairs(tbRole) do
|
||
v:OnSortingOrderChange(battleSorting)
|
||
end
|
||
for _, v in pairs(tbRoleDispose) do
|
||
v:OnSortingOrderChange(battleSorting)
|
||
end
|
||
for _, v in pairs(tbMonster) do
|
||
v:OnSortingOrderChange(battleSorting)
|
||
end
|
||
for _, v in pairs(tbMonsterDispose) do
|
||
v:OnSortingOrderChange(battleSorting)
|
||
end
|
||
for _, v in pairs(tbWeapon) do
|
||
v:OnSortingOrderChange(battleSorting)
|
||
end
|
||
for _, v in pairs(tbWeaponDispose) do
|
||
v:OnSortingOrderChange(battleSorting)
|
||
end
|
||
end
|
||
|
||
|
||
|
||
-- 初始化界面
|
||
function this:Init()
|
||
-- 初始化战斗对象池
|
||
BattlePool.Init(this.Cache)
|
||
BattlePool.Register(BATTLE_POOL_TYPE.MY_ROLE, this.RoleItem)
|
||
BattlePool.Register(BATTLE_POOL_TYPE.ENEMY_ROLE, this.EnemyItem)
|
||
BattlePool.Register(BATTLE_POOL_TYPE.ENEMY_ROLE_2, this.EnemyItem2)
|
||
BattlePool.Register(BATTLE_POOL_TYPE.BUFF_VIEW, this.BuffItem)
|
||
BattlePool.Register(BATTLE_POOL_TYPE.Monster, this.Monster)
|
||
|
||
-- 层级
|
||
local battleSorting = BattleManager.GetBattleSorting()
|
||
this.FirstEffect:GetComponent("Canvas").sortingOrder = battleSorting + 30
|
||
this.skillEffectRoot:GetComponent("Canvas").sortingOrder = battleSorting + 40
|
||
this.mySkillCast:GetComponent("Canvas").sortingOrder = battleSorting + 300
|
||
this.enemySkillCast:GetComponent("Canvas").sortingOrder = battleSorting + 300
|
||
this.lingshouCastUp:GetComponent("Canvas").sortingOrder = battleSorting+300
|
||
this.lingshouCastDown:GetComponent("Canvas").sortingOrder = battleSorting+300
|
||
|
||
-- 异妖显示
|
||
this.DiffMonster:SetActive(false)
|
||
this.DiffMonsterFlag = false
|
||
this.EnemyDiffMonster:SetActive(false)
|
||
this.EnemyDiffMonsterFlag = false
|
||
|
||
UIManager.camera.clearFlags = CameraClearFlags.Skybox
|
||
--注册战斗事件
|
||
this.InitBattleEvent()
|
||
|
||
|
||
for i=1, 6 do
|
||
local shadow = Util.GetGameObject(this.EnemyPanel, "live_"..i.."/shadow")
|
||
shadow:SetActive(false)
|
||
|
||
this.MonsterList[i]:SetActive(false)
|
||
this.MonsterList[6 + i]:SetActive(false)
|
||
end
|
||
end
|
||
|
||
-- 设置数据数据
|
||
function this:SetData(_fightData, _seed, _battleType, _maxRound, _fightId, _isBoss)
|
||
-- body
|
||
this.fightData = _fightData
|
||
this.seed = _seed
|
||
this.battleType = _battleType or 0
|
||
this.maxRound = _maxRound
|
||
this.fightId = _fightId
|
||
this.isBoss = _isBoss
|
||
this.bossRoot:SetActive(_isBoss)
|
||
--
|
||
if not this.seed then
|
||
this.seed = math.random(0, 2147483647)
|
||
LogBlue("随机生成了 随机种子 == ".. this.seed)
|
||
end
|
||
|
||
if IsOpenBattleDebug then
|
||
LogWarn(BattleManager.PrintBattleTable(_fightData))
|
||
LogWarn(this.seed)
|
||
LastDebugTime = Time.realtimeSinceStartup
|
||
end
|
||
|
||
-- 设置角色展示界面数据
|
||
-- RoleShowView.SetData(_fightData)
|
||
|
||
-- 加入战斗记录
|
||
local record = {
|
||
fightData = this.fightData,
|
||
fightSeed = this.seed,
|
||
fightType = this.battleType,
|
||
maxRound = this.maxRound,
|
||
fightId = this.fightId
|
||
}
|
||
this.recordId = BattleRecordManager.SetBattleRecord(record)
|
||
BattleRecordManager.SetBattleBothNameStr(this.nameStr, this.recordId)
|
||
|
||
this.fightIdText.text = this.fightId or ""
|
||
end
|
||
|
||
|
||
|
||
-- 设置攻击双方的名称
|
||
function this:SetNameStr(_nameStr)
|
||
this.nameStr = _nameStr
|
||
end
|
||
|
||
-- 开始战斗
|
||
function this:StartBattle()
|
||
--
|
||
this.InitBattleData()
|
||
-- 初始化战斗数据
|
||
FixedUpdateBeat:Add(this.OnUpdate, self)
|
||
-- 不再预加载资源
|
||
this.BattleOrderChange(1)
|
||
end
|
||
|
||
-- 暂停战斗
|
||
function this:PauseBattle()
|
||
BattleManager.PauseBattle()
|
||
end
|
||
-- 继续战斗
|
||
function this:ResumeBattle()
|
||
BattleManager.ResumeBattle()
|
||
end
|
||
|
||
--
|
||
function this:StopBattle()
|
||
BattleManager.StopBattle()
|
||
end
|
||
|
||
-- 结束战斗
|
||
function this.EndBattle(result)
|
||
--前端
|
||
local hpList={}
|
||
table.insert(hpList,Language[10227])
|
||
for i = 1, 6 do
|
||
local role=RoleManager.GetRole(0,i)
|
||
if role then
|
||
table.insert(hpList,role:GetRoleData(RoleDataName.Hp))
|
||
end
|
||
end
|
||
table.insert(hpList,Language[10228])
|
||
for i = 1, 6 do
|
||
local role=RoleManager.GetRole(1,i)
|
||
if role then
|
||
table.insert(hpList,role:GetRoleData(RoleDataName.Hp))
|
||
end
|
||
end
|
||
table.insert(hpList,Language[10229])
|
||
table.insert(hpList,result)
|
||
LogWarn(BattleManager.PrintBattleTable(hpList))
|
||
-- 清空数据
|
||
this.Clear()
|
||
-- 判断结果
|
||
result = result or BattleRecordManager.GetBattleRecordResult(this.recordId)
|
||
|
||
-- 战斗结束
|
||
this.root.BattleEnd(result)
|
||
end
|
||
|
||
--
|
||
function this.Clear()
|
||
--战斗统计前将roleView收集到该容器中,tbRole清理掉
|
||
for _, v in pairs(tbRole) do
|
||
table.insert(tbRoleDispose, v)
|
||
end
|
||
tbRole = {}
|
||
|
||
for _, v in pairs(tbMonster) do
|
||
table.insert(tbMonsterDispose, v)
|
||
end
|
||
tbMonster = {}
|
||
|
||
for _, v in pairs(tbWeapon) do
|
||
table.insert(tbWeaponDispose, v)
|
||
end
|
||
tbWeapon = {}
|
||
end
|
||
|
||
-- 初始化战斗数据
|
||
function this.InitBattleData()
|
||
Random.SetSeed(this.seed)
|
||
--BattleLogic.IsOpenBattleRecord = true
|
||
BattleLogic.Init(this.fightData, {uid = PlayerManager.uid, fightId = this.fightId}, this.maxRound)
|
||
BattleLogic.Type = this.battleType
|
||
LogError("battle type=="..BattleLogic.Type)
|
||
this.InitBattleEvent()
|
||
|
||
-- this.EnemyPanel:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, posY)
|
||
end
|
||
|
||
-- 设置主角头像显示
|
||
local sexIcon = {
|
||
[0] = "live2d_npc_boy_t1",
|
||
[1] = "live2d_npc_girl_t1",
|
||
}
|
||
function this.SetHeadShow()
|
||
local enemy = MonsterManager.GetMonster(1, 100) -- 敌方主角
|
||
if enemy then
|
||
this.enemy:SetActive(true)
|
||
if enemy.sex then
|
||
this.enemy:GetComponent("Image").sprite = this.spLoader:LoadSprite(sexIcon[enemy.sex])
|
||
end
|
||
else
|
||
this.enemy:SetActive(false)
|
||
end
|
||
local player = MonsterManager.GetMonster(0, 100) -- 我方主角
|
||
if player then
|
||
this.player:SetActive(true)
|
||
if player.sex then
|
||
this.player:GetComponent("Image").sprite = this.spLoader:LoadSprite(sexIcon[player.sex])
|
||
end
|
||
|
||
else
|
||
this.player:SetActive(false)
|
||
end
|
||
|
||
end
|
||
-- 注册战斗事件
|
||
function this.InitBattleEvent()
|
||
|
||
BattleLogic.Event:AddEvent(BattleEventName.AddRole, this.OnAddRole)
|
||
BattleLogic.Event:AddEvent(BattleEventName.AddMonster, this.OnAddMonster)
|
||
BattleLogic.Event:AddEvent(BattleEventName.AddWeapon, this.OnAddWeapon)
|
||
BattleLogic.Event:AddEvent(BattleEventName.RemoveRole, this.OnRemoveRole)
|
||
BattleLogic.Event:AddEvent(BattleEventName.RemoveMonster, this.OnRemoveMonster)
|
||
BattleLogic.Event:AddEvent(BattleEventName.BattleEnd, this.EndBattle)
|
||
BattleLogic.Event:AddEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange)
|
||
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange)
|
||
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundEnd, this.BattleRoundEnd)
|
||
BattleLogic.Event:AddEvent(BattleEventName.RoleTurnStart, this.RoleTurnChange)
|
||
BattleLogic.Event:AddEvent(BattleEventName.BattleStart, this.OnBattleStart)
|
||
BattleLogic.Event:AddEvent(BattleEventName.SkillCastEnd, this.OnSkillCastEnd)
|
||
|
||
end
|
||
-- 清除战斗数据
|
||
function this.ClearBattleEvent()
|
||
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.AddRole, this.OnAddRole)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.AddMonster, this.OnAddMonster)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.RemoveRole, this.OnRemoveRole)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.RemoveMonster, this.OnRemoveMonster)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.BattleEnd, this.EndBattle)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundEnd, this.BattleRoundEnd)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.RoleTurnStart, this.RoleTurnChange)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.BattleStart, this.OnBattleStart)
|
||
BattleLogic.Event:RemoveEvent(BattleEventName.SkillCastEnd, this.OnSkillCastEnd)
|
||
end
|
||
|
||
--敌军出现的表现
|
||
function this.EnemyAppear(isStart)
|
||
SoundManager.PlaySound(SoundConfig.Sound_BattleStart_03)
|
||
local go = this.FirstEffect
|
||
go:SetActive(true)
|
||
--TODO:动态计算敌军站位
|
||
for i=1, 6 do
|
||
local index = i
|
||
local enemyLivePos = Util.GetTransform(this.EnemyPanel, "live_"..i)
|
||
local enemyPos = Util.GetTransform(this.EnemyPanel, tostring(i))
|
||
-- local scale = i > 3 and 0.5 or 0.6
|
||
local scale = 0.6
|
||
-- enemyLivePos:DOScale(Vector3.one * scale * 1.1, 0.5):SetEase(Ease.OutExpo)
|
||
enemyLivePos:DOScale(Vector3.one * scale*1.1 , 0.5):SetEase(Ease.OutExpo)
|
||
enemyPos:DOScale(Vector3.one * 1.1, 0.5):SetEase(Ease.OutExpo):OnComplete(function ()
|
||
enemyLivePos:DOScale(Vector3.one * scale, 0.2):SetEase(Ease.InExpo)
|
||
enemyPos:DOScale(Vector3.one, 0.2):SetEase(Ease.InExpo):OnComplete(function ()
|
||
if index == 6 then
|
||
--显示血条
|
||
for r, v in pairs(tbRole) do
|
||
if r.camp == 0 then
|
||
playerTmpHp = playerTmpHp + r:GetRoleData(RoleDataName.Hp)
|
||
else
|
||
enemyTmpHp = enemyTmpHp + r:GetRoleData(RoleDataName.Hp)
|
||
end
|
||
end
|
||
Timer.New(function ()
|
||
go:SetActive(false)
|
||
playerHP = 0
|
||
this.PlayerHPTxt.text = Language[10230]..math.floor(playerHP / playerMaxHP * 100).."%"
|
||
|
||
enemyHP = 0
|
||
this.EnemyHPTxt.text = Language[10231]..math.floor(enemyHP / enemyMaxHP * 100).."%"
|
||
|
||
if isStart then
|
||
Timer.New(function ()
|
||
if BattleLogic.CurOrder == 1 then
|
||
BattleManager.StartBattle()
|
||
else
|
||
BattleManager.ResumeBattle()
|
||
end
|
||
end, 0.1):Start()
|
||
end
|
||
|
||
if BattleLogic.CurOrder == 1 then
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.Guide.GuideBattleStart)
|
||
end
|
||
end, 0.5):Start()
|
||
end
|
||
end)
|
||
end):SetDelay(0.2):OnStart(function ()
|
||
if enemyLivePos.childCount > 0 and RoleManager.GetRole(1, i) then
|
||
local go2 = BattleManager.LoadAsset("fx_Effect_enemy_birth")
|
||
go2.transform:SetParent(this.EnemyPanel.transform)
|
||
go2.transform.localScale = Vector3.one*0.5
|
||
go2.transform.position = enemyPos.position + Vector3.New(0, 120, 0)*0.00375
|
||
go2:SetActive(true)
|
||
addDelayRecycleRes("fx_Effect_enemy_birth", go2, 2)
|
||
end
|
||
end)
|
||
end
|
||
end
|
||
|
||
-- 战斗开始回调
|
||
function this.OnBattleStart()
|
||
-- 回调UI层
|
||
if this.root.OnBattleStart then
|
||
this.root.OnBattleStart()
|
||
end
|
||
end
|
||
-- 技能释放完成
|
||
function this.OnSkillCastEnd(skill)
|
||
-- 回调UI层
|
||
if this.root.OnSkillCastEnd then
|
||
this.root.OnSkillCastEnd(skill)
|
||
end
|
||
end
|
||
|
||
-- 角色轮转回调(不出手的位置不会回调)
|
||
function this.RoleTurnChange(role)
|
||
-- 回调UI层
|
||
if this.root.RoleTurnChange then
|
||
this.root.RoleTurnChange(role)
|
||
end
|
||
end
|
||
|
||
-- 回合结束
|
||
function this.BattleRoundEnd(Round)
|
||
-- 回调UI层
|
||
if this.root.BattleRoundEnd then
|
||
this.root.BattleRoundEnd(Round)
|
||
end
|
||
end
|
||
|
||
-- 回合变化
|
||
function this.BattleRoundChange(Round)
|
||
-- 回调UI层
|
||
this.root.OnRoundChanged(Round)
|
||
|
||
-- 异妖CD
|
||
if this.DiffMonsterFlag then
|
||
local slider = BattleLogic.GetTeamSkillCastSlider(0)
|
||
this.DiffMonsterSlider.fillAmount = slider
|
||
end
|
||
if this.EnemyDiffMonsterFlag then
|
||
local slider = BattleLogic.GetTeamSkillCastSlider(1)
|
||
this.EnemyDiffMonsterSlider.fillAmount = slider
|
||
end
|
||
end
|
||
-- 战斗波次变化
|
||
function this.BattleOrderChange(order)
|
||
-- 回调UI层
|
||
if this.root.OnOrderChanged then
|
||
this.root.OnOrderChanged(order)
|
||
end
|
||
|
||
-- this.ElementalResonanceView.elementalResonanceBtn:SetActive(true)
|
||
-- this.ElementalResonanceView2.elementalResonanceBtn:SetActive(true)
|
||
|
||
local curFormation = FormationManager.GetFormationByID(FormationManager.currentFormationIndex)
|
||
-- this.ElementalResonanceView:GetElementalType(curFormation.teamHeroInfos,1)
|
||
-- this.ElementalResonanceView:SetPosition(2)
|
||
if this.fightData.enemyData[order] then
|
||
-- this.ElementalResonanceView2:GetElementalType(this.fightData.enemyData[order], 2, order)
|
||
-- this.ElementalResonanceView2:SetPosition(3)
|
||
end
|
||
|
||
if this.tween1 then
|
||
this.tween1:Kill()
|
||
end
|
||
if this.tween2 then
|
||
this.tween2:Kill()
|
||
end
|
||
|
||
enemyMaxHP = 0
|
||
enemyHP = 0
|
||
playerTmpHp = 0
|
||
enemyTmpHp = 0
|
||
|
||
this.PlayerHPTxt.text = ""
|
||
this.EnemyHPTxt.text = ""
|
||
this.EnemyHP.fillAmount = 0
|
||
this.PlayerHP.fillAmount = 0
|
||
|
||
BattleManager.PauseBattle()
|
||
if order > 1 then
|
||
PlayUIAnimBack(this.gameObject,function ()
|
||
for _,v in pairs(tbRole) do
|
||
v.hpSlider.fillAmount = 0
|
||
v.hpPassSlider.fillAmount = 0
|
||
v.hpCache = 0
|
||
if v.spSlider then
|
||
v.spSlider.fillAmount = 0
|
||
end
|
||
end
|
||
|
||
PlayUIAnim(this.gameObject)
|
||
this.EnemyAppear(true)
|
||
end)
|
||
else
|
||
this.UpRoot:SetActive(false)
|
||
this.DownRoot:SetActive(false)
|
||
this.PlayerPanel:SetActive(false)
|
||
this.UpRoot:SetActive(true)
|
||
this.DownRoot:SetActive(true)
|
||
PlayUIAnim(this.gameObject)
|
||
playerMaxHP = 0
|
||
this.PlayerPanel:SetActive(true)
|
||
PlayUIAnim(this.PlayerPanel)
|
||
|
||
BattleLogic.InitOrder()--初始显示双方英雄
|
||
|
||
local func = function ()--显示英雄信息后的战斗逻辑
|
||
if BattleLogic.CurOrder == 1 then
|
||
BattleManager.StartBattle()
|
||
else
|
||
BattleManager.ResumeBattle()
|
||
end
|
||
BattleLogic.StartTurnRound()
|
||
end
|
||
--判断是否需要显示boss信息
|
||
local data = ConfigManager.GetConfigData(ConfigName.MainLevelConfig,FightPointPassManager.curOpenFight)
|
||
local key = PlayerPrefs.GetInt(PlayerManager.uid.."BattleBossShow"..FightPointPassManager.curOpenFight)
|
||
if this.fightType == BATTLE_TYPE.STORY_FIGHT and data.BossPreview and data.BossPreview > 0 and key == 0 then
|
||
|
||
this.EnemyAppear(false)--设置敌人
|
||
this.SetHeadShow()-- 显示头像
|
||
Timer.New(function ()
|
||
UIManager.OpenPanel(UIName.BattleBossInfoPanel,function ()
|
||
func()
|
||
end)
|
||
end,1.5):Start()
|
||
else
|
||
this.EnemyAppear(true) --设置敌人
|
||
this.SetHeadShow() -- 显示头像
|
||
Timer.New(function ()
|
||
func()
|
||
end,1.5):Start()
|
||
end
|
||
|
||
end
|
||
|
||
--刷新敌军站位
|
||
-- local v3 = this.EnemyPanel:GetComponent("RectTransform").anchoredPosition
|
||
this.EnemyPanel.transform.localScale = Vector3.one
|
||
-- this.EnemyPanel:GetComponent("RectTransform").anchoredPosition = Vector2.New(v3.x, posY)
|
||
-- if this.isBoss then
|
||
-- -- boss位置修正
|
||
-- this.EnemyPanel:GetComponent("RectTransform").anchoredPosition = Vector3.New(73, 280, 0)
|
||
-- else
|
||
-- this.EnemyPanel:GetComponent("RectTransform").anchoredPosition = Vector3.New(0, -20, 0)
|
||
-- end
|
||
|
||
for i=1, 6 do
|
||
local enemyPos = Util.GetTransform(this.EnemyPanel, tostring(i))
|
||
local enemyLivePos = Util.GetTransform(this.EnemyPanel, "live_"..i)
|
||
enemyPos.localScale = Vector3.zero
|
||
enemyLivePos.localScale = Vector3.zero
|
||
|
||
-- local myPos = Util.GetTransform(this.PlayerPanel,tostring(i))--.."/root")
|
||
-- myPos:GetComponent("Image").sprite = this.spLoader:LoadSprite("bd_xinkapaifan")
|
||
-- myPos.localScale = Vector3.one
|
||
end
|
||
|
||
end
|
||
|
||
function this.OnAddRole(data)
|
||
local go
|
||
if data.camp == 0 then
|
||
local parent = Util.GetTransform(this.PlayerPanel,tostring(data.position))--.."/root")
|
||
go = BattlePool.GetItem(parent, BATTLE_POOL_TYPE.MY_ROLE)
|
||
playerHP = playerHP + data:GetRoleData(RoleDataName.Hp)
|
||
playerMaxHP = playerMaxHP + data:GetRoleData(RoleDataName.MaxHp)
|
||
|
||
tbRole[data] = PlayerView.New(go, data, data.position, this)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
go.transform.anchoredPosition = Vector2.New(0,-170)
|
||
tbRole[data].Floater:SetPosition(go.transform.position)
|
||
else
|
||
local enemyPos = Util.GetTransform(this.EnemyPanel, tostring(data.position))
|
||
-- go = BattlePool.GetItem(enemyPos, data.position <= 3 and BATTLE_POOL_TYPE.ENEMY_ROLE or BATTLE_POOL_TYPE.ENEMY_ROLE_2)
|
||
go = BattlePool.GetItem(enemyPos, BATTLE_POOL_TYPE.ENEMY_ROLE_2)
|
||
enemyHP = enemyHP + data:GetRoleData(RoleDataName.Hp)
|
||
enemyMaxHP = enemyMaxHP + data:GetRoleData(RoleDataName.MaxHp)
|
||
local isBoss = false
|
||
if this.isBoss and data.position == 2 then
|
||
isBoss = true
|
||
end
|
||
tbRole[data] = EnemyView.New(go, data, data.position, this, isBoss, this.fightData and this.fightData.enemyId or nil)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
go.transform.anchoredPosition = Vector2.New(0,-110)
|
||
tbRole[data].Floater:SetPosition(go.transform.position)
|
||
end
|
||
|
||
-- go.transform.position = Vector3.New(0,-160,0)
|
||
|
||
go:SetActive(true)
|
||
end
|
||
|
||
function this.OnRemoveRole(data)
|
||
local view = tbRole[data]
|
||
if view then
|
||
view:Dispose()
|
||
tbRole[data] = nil
|
||
end
|
||
end
|
||
|
||
function this.OnAddMonster(data)
|
||
LogPink(data.camp.."addmonster"..data.position)
|
||
local posIndex=0
|
||
if data.position==100 then
|
||
posIndex=data.camp + data.position
|
||
else
|
||
posIndex=data.camp * 6 + data.position
|
||
end
|
||
local parent = this.MonsterList[posIndex]
|
||
if parent then
|
||
parent:SetActive(true)
|
||
local go = BattlePool.GetItem(parent.transform, BATTLE_POOL_TYPE.Monster)
|
||
tbMonster[data] = MonsterView.New(go, data, data.position, this)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.New(0,-160,0)
|
||
go.transform.anchoredPosition = Vector2.zero
|
||
if posIndex>=100 then
|
||
go:SetActive(false)
|
||
else
|
||
go:SetActive(true)
|
||
end
|
||
|
||
end
|
||
end
|
||
|
||
|
||
|
||
function this.OnAddWeapon(data)
|
||
--LogError(data.camp.."AddWeapon"..data.position)
|
||
local posIndex=0
|
||
if data.position==100 then
|
||
posIndex=data.camp + data.position
|
||
else
|
||
posIndex=data.camp * 6 + data.position
|
||
end
|
||
local roleData=RoleManager.GetRoleByCampAndPos(data.camp,data.position)
|
||
if roleData==nil then
|
||
return
|
||
end
|
||
local parent = tbRole[roleData]:GetWeaponObj()
|
||
if parent then
|
||
--parent:SetActive(true)
|
||
--local go = BattlePool.GetItem(parent.transform, BATTLE_POOL_TYPE.Monster)
|
||
tbWeapon[data] = WeaponView.New(parent, data, data.position, this)
|
||
-- go.transform.localScale = Vector3.one
|
||
-- go.transform.localPosition = Vector3.zero
|
||
-- go.transform.anchoredPosition = Vector2.zero
|
||
end
|
||
end
|
||
|
||
|
||
-- 遍历灵兽列表
|
||
function this.ForeachMonster(func)
|
||
for _, monster in pairs(tbMonster) do
|
||
if func then
|
||
func(monster)
|
||
end
|
||
end
|
||
end
|
||
|
||
-- 移除灵兽
|
||
function this.OnRemoveMonster(data)
|
||
local view = tbMonster[data]
|
||
if view then
|
||
view:Dispose()
|
||
tbMonster[data] = nil
|
||
end
|
||
end
|
||
|
||
function this.GetRoleView(role)
|
||
return tbRole[role]
|
||
end
|
||
|
||
-- 设置角色高亮
|
||
function this.SetRoleHighLight(caster, targets, func)
|
||
-- 没有目标全部高亮
|
||
if not caster and not targets then
|
||
for _, role in pairs(tbRole) do
|
||
role:SetHighLight(true, 1, 0.2)
|
||
end
|
||
-- 避免战斗结束时状态显示错误的问题
|
||
if tbRoleDispose then
|
||
for _, role in pairs(tbRoleDispose) do
|
||
role:SetHighLight(true, 1, 0.2)
|
||
end
|
||
end
|
||
if func then func() end
|
||
return
|
||
end
|
||
--
|
||
local i = 0
|
||
local max = 0
|
||
local function _Count()
|
||
i = i + 1
|
||
if i >= max then
|
||
if func then func() end
|
||
end
|
||
end
|
||
for _, role in pairs(tbRole) do
|
||
max = max + 1
|
||
role:SetHighLight(false, 0.95, 0.2, _Count)
|
||
end
|
||
if caster and caster.role.type == BattleUnitType.Role then
|
||
max = max - 1
|
||
caster:SetHighLight(true, 1.5, 0.2)
|
||
end
|
||
if targets then
|
||
for _, data in ipairs(targets) do
|
||
if caster ~= tbRole[data] then
|
||
max = max - 1
|
||
if tbRole[data] then
|
||
tbRole[data]:SetHighLight(true, 1, 0.2)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
||
if max == 0 then
|
||
if func then func() end
|
||
end
|
||
end
|
||
|
||
--(新手引导专用)查找同一站位的人,敌方死亡,我方存活的
|
||
function this.GuideCheckEnemyDead(role)
|
||
if not role:IsDead() and role.camp == 0 then
|
||
for r, v in pairs(tbRole) do
|
||
if r:IsDead() and r.camp == 1 and r.position == role.position then
|
||
return true
|
||
end
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
|
||
function this.OnUpdate()
|
||
-- 引导战斗暂停
|
||
if BattleManager.IsGuidePause() then
|
||
return
|
||
end
|
||
-- 判断是否结束
|
||
if BattleLogic.IsEnd then
|
||
-- 所有角色血条
|
||
for r, v in pairs(tbRoleDispose) do
|
||
v:Update()
|
||
end
|
||
end
|
||
if BattleManager.IsBattlePlaying() and not BattleLogic.IsEnd then
|
||
BattleLogic.Update()
|
||
-- 再检测一次战斗结束
|
||
if BattleLogic.IsEnd then return end
|
||
|
||
playerTmpHp = 0
|
||
enemyTmpHp = 0
|
||
-- 所有角色血条
|
||
for r, v in pairs(tbRole) do
|
||
v:Update()
|
||
if r.camp == 0 then
|
||
playerTmpHp = playerTmpHp + r:GetRoleData(RoleDataName.Hp)
|
||
else
|
||
enemyTmpHp = enemyTmpHp + r:GetRoleData(RoleDataName.Hp)
|
||
end
|
||
end
|
||
-- 我方总血条
|
||
if playerTmpHp ~= playerHP then
|
||
local f1 = playerHP
|
||
local f2 = playerTmpHp
|
||
if this.tween1 then
|
||
this.tween1:Kill()
|
||
end
|
||
this.tween1 = DoTween.To(DG.Tweening.Core.DOGetter_float( function () return f1 end),
|
||
DG.Tweening.Core.DOSetter_float(function (t)
|
||
this.PlayerHP.fillAmount = t / playerMaxHP
|
||
end), f2, 0.5):SetEase(Ease.Linear)
|
||
playerHP = playerTmpHp
|
||
this.PlayerHPTxt.text = Language[10230]..math.floor(playerHP / playerMaxHP * 100).."%"
|
||
end
|
||
-- 敌方总血条
|
||
if enemyTmpHp ~= enemyHP then
|
||
local f1 = enemyHP
|
||
local f2 = enemyTmpHp
|
||
if this.tween2 then
|
||
this.tween2:Kill()
|
||
end
|
||
this.tween2 = DoTween.To(DG.Tweening.Core.DOGetter_float( function () return f1 end),
|
||
DG.Tweening.Core.DOSetter_float(function (t)
|
||
this.EnemyHP.fillAmount = t / enemyMaxHP
|
||
end), f2, 0.5):SetEase(Ease.Linear)
|
||
enemyHP = enemyTmpHp
|
||
this.EnemyHPTxt.text = Language[10231]..math.floor(enemyHP / enemyMaxHP * 100).."%"
|
||
end
|
||
|
||
|
||
-- 驱动上层界面
|
||
this.root.OnUpdate()
|
||
end
|
||
|
||
end
|
||
|
||
|
||
function this.OnSkillCast(skill)
|
||
local type = skill.teamSkillType
|
||
local camp = skill.owner.camp
|
||
local pokemonConfig = PokemonEffectConfig[type]
|
||
|
||
if camp == 0 then
|
||
Util.SetGray(this.DiffMonster, true)
|
||
else
|
||
Util.SetGray(this.EnemyDiffMonster, true)
|
||
end
|
||
if camp == 1 then
|
||
local yiPath2 = pokemonConfig.aoe
|
||
local go3 = BattleManager.LoadAsset(yiPath2)
|
||
go3.transform:SetParent(this.transform)
|
||
go3.transform.localScale = Vector3.one
|
||
go3.transform.localPosition = camp == 0 and Vector3.New(0,100,0) or Vector3.New(0,-674,0)
|
||
go3:SetActive(true)
|
||
|
||
this.BG:GetComponent("RectTransform"):DOShakeAnchorPos(1, Vector2.New(500, 100), 100, 50, false, true)
|
||
|
||
addDelayRecycleRes(yiPath2, go3, 3)
|
||
return
|
||
end
|
||
|
||
local go = BattleManager.LoadAsset("casting_skill")
|
||
go:GetComponent("Canvas").sortingOrder = this.root.sortingOrder + 100
|
||
go.transform:SetParent(this.gameObject.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
go:SetActive(true)
|
||
|
||
local path = pokemonConfig.live
|
||
local scale = pokemonConfig.scale
|
||
local tran = Util.GetTransform(go, "player")
|
||
|
||
local liveGO = poolManager:LoadAsset(path, PoolManager.AssetType.GameObject)
|
||
liveGO.transform:SetParent(tran)
|
||
liveGO.transform.localScale = Vector3.one * scale
|
||
liveGO.transform.localPosition = Vector3.New(0, 0, 0)
|
||
liveGO:SetActive(true)
|
||
liveGO:GetComponent("SkeletonGraphic"):DOFade(1, 0)
|
||
liveGO:GetComponent("SkeletonGraphic"):DOColor(Color.New(1,1,1,1), 0)
|
||
|
||
BattleManager.PauseBattle()
|
||
|
||
addDelayRecycleRes("casting_skill", go, 1.6, function ()
|
||
local yiPath1 = pokemonConfig.screen
|
||
local go2 = BattleManager.LoadAsset(yiPath1)
|
||
go2.transform:SetParent(this.transform)
|
||
go2.transform.localScale = Vector3.one
|
||
go2.transform.localPosition = Vector3.zero
|
||
go2:SetActive(true)
|
||
|
||
addDelayRecycleRes(yiPath1, go2, pokemonConfig.screenCD + 3, function ()
|
||
local yiPath2 = pokemonConfig.aoe
|
||
local go3 = BattleManager.LoadAsset(yiPath2)
|
||
go3.transform:SetParent(this.transform)
|
||
go3.transform.localScale = Vector3.one
|
||
go3.transform.localPosition = camp == 0 and Vector3.New(0,100,0) or Vector3.New(0,-674,0)
|
||
go3:SetActive(true)
|
||
|
||
this.BG:GetComponent("RectTransform"):DOShakeAnchorPos(1, Vector2.New(500, 100), 100, 50, false, true)
|
||
|
||
BattleManager.ResumeBattle()
|
||
|
||
addDelayRecycleRes(yiPath2, go3, 3)
|
||
end, pokemonConfig.screenCD)
|
||
end)
|
||
addDelayRecycleRes(path, liveGO, 1.6)
|
||
end
|
||
|
||
-- 清除角色
|
||
function this:ClearRole()
|
||
for _, view in pairs(tbRole) do
|
||
view:Dispose()
|
||
end
|
||
tbRole = {}
|
||
end
|
||
|
||
|
||
|
||
-- 参数:object 抖动物体 timeScale 震动时长 dx, dy震动偏移量
|
||
local isShaking = false
|
||
function this:SetShake(object, timeScale, dx, dy, callBack)
|
||
if isShaking then return end
|
||
isShaking = true
|
||
if not object then
|
||
object = this.gameObject
|
||
end
|
||
if not timeScale or timeScale == 0 then
|
||
timeScale = 0.2
|
||
end
|
||
if not dx or not dy or dy == 0 and dx == 0 then
|
||
dx = 100
|
||
dy = 100
|
||
end
|
||
object:GetComponent("RectTransform"):DOShakeAnchorPos(timeScale, Vector2.New(dx, dy),
|
||
500, 90, true, true):OnComplete(function ()
|
||
if callBack then callBack() end
|
||
isShaking = false
|
||
end)
|
||
end
|
||
|
||
-- 设置boss怒气显示
|
||
function this:SetBossRage(rage)
|
||
if rage <= #this.bossRageList then
|
||
for i = 1, #this.bossRageList do
|
||
this.bossRageList[i]:SetActive(i<=rage)
|
||
end
|
||
else
|
||
for i = 1, rage do
|
||
if not this.bossRageList[i] then
|
||
this.bossRageList[i] = this:GetABossRage(i)
|
||
end
|
||
this.bossRageList[i]:SetActive(i<=rage)
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function this:OnClose()
|
||
|
||
-- 回收所有延迟资源
|
||
BattleManager.RecycleAllDelayRes()
|
||
--
|
||
FixedUpdateBeat:Remove(this.OnUpdate, self)
|
||
-- 清空
|
||
this.Clear()
|
||
for _, v in pairs(tbRoleDispose) do
|
||
v:Dispose()
|
||
end
|
||
tbRoleDispose = {}
|
||
for _, v in pairs(tbMonsterDispose) do
|
||
v:Dispose()
|
||
end
|
||
tbMonsterDispose = {}
|
||
|
||
for k, v in pairs(delayRecycleList) do
|
||
for i=1, #v do
|
||
poolManager:UnLoadAsset(k, v[i], PoolManager.AssetType.GameObject)
|
||
end
|
||
delayRecycleList[k] = nil
|
||
end
|
||
|
||
BattlePool.Clear()
|
||
poolManager:ClearPool()
|
||
|
||
this.mySkillCast:SetActive(false)
|
||
this.enemySkillCast:SetActive(false)
|
||
this.lingshouCastUp:SetActive(false)
|
||
this.lingshouCastDown:SetActive(false)
|
||
--
|
||
BattleManager.StopBattle()
|
||
|
||
this.ClearBattleEvent()
|
||
|
||
|
||
end
|
||
|
||
function this:OnClose2()
|
||
|
||
-- 回收所有延迟资源
|
||
BattleManager.RecycleAllDelayRes()
|
||
--
|
||
FixedUpdateBeat:Remove(this.OnUpdate, self)
|
||
-- 清空
|
||
this.Clear()
|
||
for _, v in pairs(tbRoleDispose) do
|
||
v:Dispose()
|
||
end
|
||
tbRoleDispose = {}
|
||
for _, v in pairs(tbMonsterDispose) do
|
||
v:Dispose()
|
||
end
|
||
tbMonsterDispose = {}
|
||
|
||
for k, v in pairs(delayRecycleList) do
|
||
for i=1, #v do
|
||
poolManager:UnLoadAsset(k, v[i], PoolManager.AssetType.GameObject)
|
||
end
|
||
delayRecycleList[k] = nil
|
||
end
|
||
|
||
BattlePool.Clear2()
|
||
poolManager:ClearPool()
|
||
|
||
this.mySkillCast:SetActive(false)
|
||
this.enemySkillCast:SetActive(false)
|
||
this.lingshouCastUp:SetActive(false)
|
||
this.lingshouCastDown:SetActive(false)
|
||
--
|
||
BattleManager.StopBattle()
|
||
|
||
this.ClearBattleEvent()
|
||
|
||
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function this:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
BattleManager.SetSpLoader(nil)
|
||
|
||
-- SubUIManager.Close(this.ElementalResonanceView)
|
||
-- SubUIManager.Close(this.ElementalResonanceView2)
|
||
-- BattlePool.Destroy()
|
||
-- 回收所有延迟资源
|
||
BattleManager.RecycleAllDelayRes()
|
||
end
|
||
return BattleView |