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

837 lines
28 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 = 400
local posOffset = 0
local tbRole = {}
local tbRoleDispose = {}
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:InitComponent(root)
-- body
this.root = root
this.gameObject = root.gameObject
this.transform = root.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.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")
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")
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")
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)
-- 初始化角色展示界面
-- RoleShowView.Init(Util.GetGameObject(this.gameObject, "RoleShow"))
end
function this:BindEvent()
end
-- 正常接口
function this:OnOpen(data)
this.ElementalResonanceView:OnOpen({sortOrder=BattleManager.GetBattleSorting()})
this.ElementalResonanceView2:OnOpen({sortOrder=BattleManager.GetBattleSorting()})
this:Init()
this:SetData(data.fightData, data.fightSeed, data.fightType, data.maxRound)
end
function this:OnSortingOrderChange(battleSorting)
-- 层级
this.FirstEffect:GetComponent("Canvas").sortingOrder = battleSorting + 30
this.skillEffectRoot:GetComponent("Canvas").sortingOrder = battleSorting + 40
local skillSorting = battleSorting + 300
this.mySkillCast:GetComponent("Canvas").sortingOrder = skillSorting
this.enemySkillCast:GetComponent("Canvas").sortingOrder = skillSorting
if not self.oSortingOrder then
self.oSortingOrder = skillSorting
Util.AddParticleSortLayer(self.mySkillCast, skillSorting)
Util.AddParticleSortLayer(self.enemySkillCast, skillSorting)
else
Util.AddParticleSortLayer(self.mySkillCast, skillSorting - self.oSortingOrder)
Util.AddParticleSortLayer(self.enemySkillCast, skillSorting - self.oSortingOrder)
end
for _, v in pairs(tbRole) do
v:OnSortingOrderChange(battleSorting)
end
for _, v in pairs(tbRoleDispose) 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)
-- 层级
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.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)
end
end
-- 设置数据数据
function this:SetData(_fightData, _seed, _battleType, _maxRound)
-- body
this.fightData = _fightData
this.seed = _seed
this.battleType = _battleType or 0
this.maxRound = _maxRound
--
if not this.seed then
this.seed = math.random(0, 2147483647)
LogBlue(Language[10268].. 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
}
this.recordId = BattleRecordManager.SetBattleRecord(record)
BattleRecordManager.SetBattleBothNameStr(this.nameStr, this.recordId)
end
-- 设置攻击双方的名称
function this:SetNameStr(_nameStr)
this.nameStr = _nameStr
end
-- 开始战斗
function this:StartBattle()
--
this.InitBattleData()
-- 初始化战斗数据
FixedUpdateBeat:Add(this.OnUpdate, self)
-- 预加载资源
poolManager:PreLoadAsset("FloatingText",10, PoolManager.AssetType.GameObject, function()
poolManager:PreLoadAsset("BuffFloatingText",10, PoolManager.AssetType.GameObject, function()
this.BattleOrderChange(1)
end)
end)
end
-- 暂停战斗
function this:PauseBattle()
BattleManager.PauseBattle()
end
-- 继续战斗
function this:ResumeBattle()
BattleManager.ResumeBattle()
end
--
function this:StopBattle()
BattleManager.StopBattle()
end
-- 结束战斗
function this.EndBattle(result)
-- 清空数据
this.Clear()
-- 判断结果
result = result or BattleRecordManager.GetBattleRecordResult(this.recordId)
-- 战斗结束
this.root.BattleEnd(result)
end
--
function this.Clear()
tbRoleDispose = {} --战斗统计前将roleView收集到该容器中tbRole清理掉
for _, v in pairs(tbRole) do
table.insert(tbRoleDispose, v)
end
tbRole = {}
end
-- 初始化战斗数据
function this.InitBattleData()
Random.SetSeed(this.seed)
--BattleLogic.IsOpenBattleRecord = true
BattleLogic.Init(this.fightData, {uid = PlayerManager.uid}, this.maxRound)
BattleLogic.Type = this.battleType
this.InitBattleEvent()
this.EnemyPanel:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, posY)
end
-- 注册战斗事件
function this.InitBattleEvent()
BattleLogic.Event:AddEvent(BattleEventName.AddRole, this.OnAddRole)
BattleLogic.Event:AddEvent(BattleEventName.RemoveRole, this.OnRemoveRole)
BattleLogic.Event:AddEvent(BattleEventName.BattleEnd, this.EndBattle)
BattleLogic.Event:AddEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange)
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange)
end
-- 清除战斗数据
function this.ClearBattleEvent()
BattleLogic.Event:RemoveEvent(BattleEventName.AddRole, this.OnAddRole)
BattleLogic.Event:RemoveEvent(BattleEventName.RemoveRole, this.OnRemoveRole)
BattleLogic.Event:RemoveEvent(BattleEventName.BattleEnd, this.EndBattle)
BattleLogic.Event:RemoveEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange)
BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange)
end
--敌军出现的表现
function this.EnemyAppear()
SoundManager.PlaySound(SoundConfig.Sound_BattleStart_03)
local go
if BattleLogic.CurOrder == 1 then
go = this.FirstEffect
elseif BattleLogic.CurOrder == 2 then
go = this.FirstEffect
elseif BattleLogic.CurOrder == 3 then
go = this.ThirdEffect
end
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--(1 - math.abs(i-pos[1]+posOffset) * 0.15) --敌人依次缩放出现
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 == 4 then
-- 提前播放音效
-- if BattleLogic.CurOrder == 1 then
-- SoundManager.PlaySound(SoundConfig.Sound_BattleStart_04)
-- end
elseif 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
v:OrderStart()
end
Timer.New(function ()
go:SetActive(false)
playerHP = 0
this.PlayerHPTxt.text = Language[10269]..math.floor(playerHP / playerMaxHP * 100).."%"
enemyHP = 0
this.EnemyHPTxt.text = Language[10270]..math.floor(enemyHP / enemyMaxHP * 100).."%"
Timer.New(function ()
if BattleLogic.CurOrder == 1 then
BattleManager.StartBattle()
else
BattleManager.ResumeBattle()
end
end, 0.1):Start()
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 = loadAsset("fx_Effect_enemy_birth")
go2.transform:SetParent(this.EnemyPanel.transform)
go2.transform.localScale = Vector3.one
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.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层
this.root.OnOrderChanged(order)
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()
-- this.BG:GetComponent("RectTransform").anchoredPosition = Vector2.zero
-- this.BG:GetComponent("Image").sprite = Util.LoadSprite(scene[order])
if order > 1 then
-- this.LastBG:GetComponent("Image").sprite = Util.LoadSprite(scene[order-1])
-- this.LastBG:SetActive(true)
-- this.LastBG:GetComponent("Image"):DOFade(1,0):OnComplete(function ()
-- this.LastBG:GetComponent("Image"):DOFade(0,1):OnComplete(function ()
-- this.LastBG:SetActive(false)
-- end)
-- end)
-- this.BG:GetComponent("Image"):DOFade(0,0):OnComplete(function ()
-- this.BG:GetComponent("Image"):DOFade(1,1)
-- end)
--
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)
this.EnemyAppear()
end)
else
this.UpRoot:SetActive(false)
this.DownRoot:SetActive(false)
this.PlayerPanel:SetActive(false)
-- RoleShowView.Show(function()
-- RoleShowView.Recycle()
this.UpRoot:SetActive(true)
this.DownRoot:SetActive(true)
PlayUIAnim(this.gameObject)
-- Timer.New(function()
-- SoundManager.PlaySound(SoundConfig.Sound_BattleStart_02)
-- end, 1):Start()
playerMaxHP = 0
BattleLogic.StartOrder()
-- 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
this.PlayerPanel:SetActive(true)
PlayUIAnim(this.PlayerPanel)
this.EnemyAppear()
-- 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)
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, "View/"..i.."/root")
myPos.localScale = Vector3.one
end
end
function this.OnAddRole(data)
local go
if data.camp == 0 then
local parent = Util.GetTransform(this.PlayerPanel, "View/"..data.position.."/root")
-- if data.position == 1 then
-- parent.localPosition = Vector3.New(-145, -221, 0)
-- else
-- parent.localPosition = Vector3.New(0, -221, 0)
-- end
go = BattlePool.GetItem(parent, BATTLE_POOL_TYPE.MY_ROLE)
playerHP = playerHP + data:GetRoleData(RoleDataName.Hp)
playerMaxHP = playerMaxHP + data:GetRoleData(RoleDataName.MaxHp)
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)
enemyHP = enemyHP + data:GetRoleData(RoleDataName.Hp)
enemyMaxHP = enemyMaxHP + data:GetRoleData(RoleDataName.MaxHp)
end
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
go.transform.anchoredPosition = Vector2.zero
go:SetActive(true)
tbRole[data] = RoleView.New(go, data, data.position, this)
end
function this.OnRemoveRole(data)
local view = tbRole[data]
if view then
view:Dispose()
tbRole[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 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
tbRole[data]:SetHighLight(true, 1, 0.2)
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 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[10269]..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[10270]..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 = 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 = 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 = 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 = 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
--界面关闭时调用(用于子类重写)
function this:OnClose()
FixedUpdateBeat:Remove(this.OnUpdate, self)
for _, v in pairs(tbRoleDispose) do
v:Dispose()
end
tbRoleDispose = {}
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)
--
BattleManager.StopBattle()
this.ClearBattleEvent()
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
SubUIManager.Close(this.ElementalResonanceView)
SubUIManager.Close(this.ElementalResonanceView2)
BattlePool.Destroy()
end
return BattleView