881 lines
36 KiB
Lua
881 lines
36 KiB
Lua
|
||
local RoleConfig = ConfigManager.GetConfig(ConfigName.RoleConfig)
|
||
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
||
local SkillLogicConfig = ConfigManager.GetConfig(ConfigName.SkillLogicConfig)
|
||
local healEffect = "c_xy_0012_skeff_tapsk_healeff"
|
||
local rageEffect = "s_jieling_hs_3006_skeff_casting_buff_nuqi"
|
||
local reliveEffect1 = "fx_chongsheng_lianhua"
|
||
local reliveEffect2 = "fx_chongsheng_lizhi"
|
||
local BattlePanel = require("Modules/Battle/View/GuideBattleLogic")
|
||
EnemyView = BattleUnit.New()
|
||
|
||
function EnemyView.New(go, role, position, root, isBoss,enemysId)
|
||
local o = BattleUnit.New(go, role, position, root)
|
||
setmetatable(o, EnemyView)
|
||
EnemyView.__index = EnemyView
|
||
o:ctor(go, role, position, root, isBoss,enemysId)
|
||
return o
|
||
end
|
||
|
||
|
||
function EnemyView:onCreate(go, role, position, root, isBoss,enemyId)
|
||
self.spLoader = SpriteLoader.New()
|
||
self.RootPanel = root
|
||
self.GameObject = go
|
||
self.role = role
|
||
self.camp = role.camp
|
||
self.isBoss = isBoss
|
||
self.enemysId=enemyId --剧情id,用于处理剧情特殊显示
|
||
-- 创建技能播放器
|
||
self.castingEfectNode = self.RootPanel.enemySkillCast
|
||
self.castingNameNode = Util.GetGameObject(self.castingEfectNode, "TongYong_Casting_Shang/DongHua/MingZi2")
|
||
self.hpSlider = Util.GetGameObject(go, "hpProgress/hp"):GetComponent("Image")
|
||
self.hpPassSlider = Util.GetGameObject(go, "hpProgress/hpPass"):GetComponent("Image")
|
||
self.yujiaSlider=Util.GetGameObject(go, "hpProgress/yujia"):GetComponent("Image")
|
||
self.nameText = Util.GetGameObject(go, "Name/Text"):GetComponent("Text")
|
||
self.level = Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
|
||
self.elementImg = Util.GetGameObject(go, "Pro/Image"):GetComponent("Image")
|
||
self.nameParent = Util.GetGameObject(go, "Name")
|
||
self.proPar=Util.GetGameObject(go, "Pro")
|
||
self.nameObj=Util.GetGameObject(go, "GameObject")
|
||
self.newName=Util.GetGameObject(go, "GameObject/Text"):GetComponent("Text")
|
||
self.newPro=Util.GetGameObject(go, "GameObject/pro"):GetComponent("Image")
|
||
--
|
||
local roleId=role.roleData.roleId
|
||
self.roleId=roleId
|
||
local live=HeroConfig[role.roleData.roleId].Live
|
||
LogError("roleid========================="..roleId)
|
||
-- 判断是否有皮肤
|
||
if not role.roleData.skinId or role.roleData.skinId == 0 then
|
||
self.skinId = 0
|
||
else
|
||
self.skinId = role.roleData.skinId
|
||
self.roleId=self.skinId
|
||
end
|
||
--如果英雄装备皮肤
|
||
if self.skinId and self.skinId > 0 then
|
||
roleId = self.skinId
|
||
local skin=ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",roleId)
|
||
if skin then
|
||
live=skin.Live
|
||
end
|
||
end
|
||
|
||
self.hpCache = self.role:GetRoleData(RoleDataName.Hp) / self.role:GetRoleData(RoleDataName.MaxHp)
|
||
self.hpSlider.fillAmount = self.hpCache
|
||
self.hpPassSlider.fillAmount = self.hpCache
|
||
self.yujiaSlider.fillAmount = 0
|
||
self.livePath = GetResourcePath(live)
|
||
self.livePath2=GetResourcePath(HeroConfig[role.roleData.roleId].Painting)
|
||
|
||
self.play_liveScale = RoleConfig[roleId].play_liveScale
|
||
self.enemy_liveScale = RoleConfig[roleId].enemy_liveScale
|
||
self.offset = RoleConfig[roleId].offset
|
||
self.outOffset = RoleConfig[roleId].enemy_offset
|
||
self.spAtkTime = RoleConfig[roleId].CastingSkills/1000
|
||
self.atkSoundTime = RoleConfig[roleId].CastingAudio/1000
|
||
self.attackSound = RoleConfig[roleId].sond
|
||
self.readingName = GetLanguageStrById(HeroConfig[role.roleData.roleId].ReadingName)
|
||
|
||
--
|
||
self.nameText.text = SubString2(self.readingName,9)
|
||
self.level.text = role:GetRoleData(RoleDataName.Level)
|
||
self.elementImg.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(role.roleData.element))
|
||
self.newName.text = SubString2(self.readingName,9)
|
||
self.newPro.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(role.roleData.element))
|
||
LogError("加战斗ID::::"..tostring(self.enemysId))
|
||
if self.enemysId and self.enemysId==1017 then
|
||
Util.GetGameObject(go, "Name"):GetComponent("RectTransform").anchoredPosition=Vector3.New(20,-180,0)
|
||
Util.GetGameObject(go, "Pro"):GetComponent("RectTransform").anchoredPosition=Vector3.New(-77,-180,0)
|
||
end
|
||
|
||
self.liveRoot = Util.GetGameObject(self.RootPanel.EnemyPanel, "live_"..position)
|
||
self.liveRoot:GetComponent("Canvas").overrideSorting = true
|
||
self.SingleHitEffectRoot=Util.GetGameObject(self.liveRoot, "SingleHitEffectRoot")
|
||
self.RoleLiveGO = poolManager:LoadLive(self.livePath, go.transform.parent, Vector3.one, Vector3.zero)
|
||
self.RoleLiveGOGraphic = self.RoleLiveGO:GetComponent("SkeletonGraphic")
|
||
self.RoleLiveGOTran = self.RoleLiveGO:GetComponent("RectTransform")
|
||
self.RoleLiveGOGraphic.AnimationState:SetAnimation(0, "idle", true)
|
||
self.RoleLiveGOTran.sizeDelta = Vector2.New(1000, 1000)
|
||
self.RoleLiveGO.transform:SetParent(self.liveRoot.transform)
|
||
self.RoleLiveGO:GetComponent("RectTransform").anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2])-- * 0.5
|
||
self.RoleLiveGO.transform.localScale = Vector3.one * self.enemy_liveScale --* 0.75
|
||
self.RoleLiveGO:SetActive(true)
|
||
self.startPos=self.RoleLiveGO.transform.position
|
||
-- Log("IsBoss: "..tostring(self.isBoss))
|
||
if self.isBoss then
|
||
self.RoleLiveGO.transform.localScale = self.RoleLiveGO.transform.localScale * 1.5 -- boss 放大1.5倍
|
||
end
|
||
local combatId = BattleManager.GetCombatIdBySkin(self.role.skill[1],self.skinId)
|
||
local combat = BattleManager.GetSkillCombat(combatId)
|
||
self.SkillAttackDisplaceoffset=combat.AttackDisplaceoffset
|
||
if combat.CloseRangeHit~=nil and combat.CloseRangeHit~="" then
|
||
|
||
self.RoleSkillLiveGo=poolManager:LoadLive(combat.CloseRangeHit, go.transform.parent, combat.CloseRangeHitScale==nil and Vector3.one or Vector3.New( combat.CloseRangeHitScale[1]/1000, combat.CloseRangeHitScale[2]/1000,1), Vector3.zero)
|
||
|
||
self.RoleSkillLiveGoTran = self.RoleSkillLiveGo:GetComponent("RectTransform")
|
||
self.RoleSkillLiveGoTran:SetParent(self.RoleLiveGO.transform)
|
||
LogError("3"..tostring(self.RoleSkillLiveGoTran.localScale))
|
||
self.RoleSkillLiveGoTran.anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2])-- * 0.5
|
||
self.RoleSkillLiveGoTran.localScale = combat.CloseRangeHitScale==nil and Vector3.one or Vector3.New( combat.CloseRangeHitScale[1]/1000, combat.CloseRangeHitScale[2]/1000,1)
|
||
self.RoleSkillLiveGoTran.sizeDelta = Vector2.New(1000, 1000)
|
||
self.RoleSkillLiveGoGraphic = self.RoleSkillLiveGo:GetComponent("SkeletonGraphic")
|
||
self.RoleSkillLiveGoGraphic.AnimationState.TimeScale=combat.SkillTimeScale/1000
|
||
self.RoleSkillLiveGoGraphic.AnimationState:SetAnimation(0, "idle", true)
|
||
end
|
||
local combatId2 = BattleManager.GetCombatIdBySkin(self.role.superSkill[1],self.skinId)
|
||
local combat2 = BattleManager.GetSkillCombat(combatId2)
|
||
self.superSkillAttackDisplaceoffset=combat2.AttackDisplaceoffset
|
||
if combat2.CloseRangeHit~=nil and combat2.CloseRangeHit~="" then
|
||
self.RoleSkillLiveGo2=poolManager:LoadLive(combat2.CloseRangeHit, go.transform.parent, combat2.CloseRangeHitScale==nil and Vector3.one or Vector3.New( combat2.CloseRangeHitScale[1]/1000, combat2.CloseRangeHitScale[2]/1000,1), Vector3.zero)
|
||
self.RoleSkillLiveGoTran2 = self.RoleSkillLiveGo2:GetComponent("RectTransform")
|
||
self.RoleSkillLiveGoTran2:SetParent(self.RoleLiveGO.transform)
|
||
-- self.RoleSkillLiveGoTran2.anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2])-- * 0.5
|
||
if combat2.CloseRangeHitOffset~=nil then
|
||
self.RoleSkillLiveGoTran2.localPosition = Vector2.New(combat2.CloseRangeHitOffset[1], combat2.CloseRangeHitOffset[2])-- * 0.5
|
||
else
|
||
self.RoleSkillLiveGoTran2.localPosition = Vector2.New(0, 0)-- * 0.5
|
||
end
|
||
|
||
self.RoleSkillLiveGoTran2.localScale = combat2.CloseRangeHitScale==nil and Vector3.one or Vector3.New( combat2.CloseRangeHitScale[1]/1000, combat2.CloseRangeHitScale[2]/1000,1)
|
||
self.RoleSkillLiveGoTran2.sizeDelta = Vector2.New(1000, 1000)
|
||
self.RoleSkillLiveGoGraphic2 = self.RoleSkillLiveGo2:GetComponent("SkeletonGraphic")
|
||
self.RoleSkillLiveGoGraphic2.AnimationState.TimeScale=combat2.SkillTimeScale/1000
|
||
-- local t= self.RoleLiveGOGraphic.SkeletonData.animations
|
||
self.RoleSkillLiveGoGraphic2.AnimationState:SetAnimation(0, "idle", true)
|
||
self.RoleSkillLiveGo2:SetActive(true)
|
||
end
|
||
-- casting技能立绘
|
||
self.RoleLiveGO2 = poolManager:LoadLive(self.livePath2, go.transform.parent, Vector3.one, Vector3.zero)
|
||
self.RoleLiveGOGraphic2 = self.RoleLiveGO2:GetComponent("SkeletonGraphic")
|
||
self.RoleLiveGOTran2 = self.RoleLiveGO2:GetComponent("RectTransform")
|
||
if role.roleData.roleId==10016 or role.roleData.roleId== 21063 then
|
||
self.RoleLiveGOGraphic2.AnimationState:SetAnimation(0, "idle", true)
|
||
else
|
||
self.RoleLiveGOGraphic2.AnimationState:SetAnimation(0, "idle", true)
|
||
end
|
||
self.RoleLiveGOTran2.sizeDelta = Vector2.New(1000, 1000)
|
||
self.RoleLiveGO2.transform:SetParent(self.RootPanel.enemySkillCastRoot.transform)
|
||
self.RoleLiveGO2:GetComponent("RectTransform").anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2] + 400)
|
||
self.RoleLiveGO2.transform.localScale = Vector3.one * self.enemy_liveScale --* 2
|
||
self.RoleLiveGO2:SetActive(false)
|
||
local toward=0
|
||
if self.skinId~=0 then
|
||
toward=RoleConfig[roleId].Toward
|
||
else
|
||
toward=HeroConfig[role.roleData.roleId].Toward
|
||
end
|
||
if toward==2 then
|
||
local mirrOffset=RoleConfig[roleId].mirrorimage_offset
|
||
if mirrOffset and mirrOffset[1]~=0 and mirrOffset[2]~=0 then
|
||
self.RoleLiveGO:GetComponent("RectTransform").anchoredPosition = Vector2.New(mirrOffset[1],mirrOffset[2])
|
||
self.RoleLiveGO2:GetComponent("RectTransform").anchoredPosition = Vector2.New(mirrOffset[1],mirrOffset[2]+400)
|
||
self.outOffset = RoleConfig[roleId].mirrorimage_offset
|
||
end
|
||
|
||
self.RoleLiveGO:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0,180, 0))
|
||
self.RoleLiveGO2:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0,180, 0))
|
||
end
|
||
-- 阴影
|
||
self.shadow = Util.GetGameObject(self.liveRoot, "shadow")
|
||
self.shadow:SetActive(true)
|
||
|
||
-- 死亡特凶啊
|
||
self.effect_dead = Util.GetGameObject(go, "effect_Dead")
|
||
self.deadIconGO = Util.GetGameObject(go, "buttom/dead")
|
||
self.effect_dead:SetActive(false)
|
||
self.deadIconGO:SetActive(false)
|
||
|
||
-- 测试用
|
||
Util.GetGameObject(go, "buttom/pos"):GetComponent("Image").sprite = self.spLoader:LoadSprite("r_zhandou_difangweizhi_0"..role.position)
|
||
|
||
self.rageCache = nil
|
||
self.rageSlider = Util.GetGameObject(go, "rageProgress/rage"):GetComponent("Image")
|
||
self.rageText = Util.GetGameObject(go, "rageProgress/Text"):GetComponent("Text")
|
||
self.effect_rage = Util.GetGameObject(go, "rageProgress/effect")
|
||
self.effect_rage:SetActive(self.role.Rage >= 4)
|
||
self.rageSlider.fillAmount = self.role.Rage / 4
|
||
self.rageText.gameObject:SetActive(false)
|
||
self.rageText.text = ""
|
||
self.currAniName="idle"
|
||
self.effect_fly = Util.GetGameObject(go, "c_long_zhandou_lizi")
|
||
self.effect_fly:SetActive(self.role.star>=14)
|
||
-- 伤害文字显示
|
||
self.LastBuffFloatingTime = Time.realtimeSinceStartup
|
||
self.BuffFloatingCount = 0
|
||
self.weaponObj=Util.GetGameObject(go, "weapon")
|
||
self.weaponImg=Util.GetGameObject(go, "weapon/Image"):GetComponent("Image")
|
||
self.weaponObj:SetActive(false)
|
||
-- 层级设置
|
||
local battleSorting = BattleManager.GetBattleSorting()
|
||
self:ChangeCardSorting(battleSorting)
|
||
|
||
-- 飘字管理
|
||
self.Floater = FloatNode.New(self, self.RootPanel, self.GameObject)
|
||
-- buff管理
|
||
if self.isBoss then
|
||
self.BuffCtrl = BuffCtrl.New(self, self.RootPanel.bossBuffRoot)
|
||
else
|
||
self.BuffCtrl = BuffCtrl.New(self, Util.GetGameObject(go, "buff"))
|
||
end
|
||
-- 创建技能播放器
|
||
self.SkillCaster = SkillCaster.New(self, self.spAtkTime, self.atkSoundTime, self.attackSound, self.castingEfectNode, self.castingNameNode)
|
||
|
||
role.Event:AddEvent(BattleEventName.BeHitMiss, self.OnBeHitMiss, self)
|
||
role.Event:AddEvent(BattleEventName.RoleBeDamaged, self.OnDamaged, self)
|
||
role.Event:AddEvent(BattleEventName.RoleBeTreated, self.OnTreated, self)
|
||
role.Event:AddEvent(BattleEventName.RoleBeHealed, self.OnHealed, self)
|
||
role.Event:AddEvent(BattleEventName.RoleDead, self.OnDead, self)
|
||
role.Event:AddEvent(BattleEventName.RoleRealDead, self.OnRealDead, self)
|
||
role.Event:AddEvent(BattleEventName.RoleRageChange, self.RoleRageChange, self)
|
||
role.Event:AddEvent(BattleEventName.RoleRelive, self.onRoleRelive, self)
|
||
role.Event:AddEvent(BattleEventName.AOE, self.OnAOE, self)
|
||
role.Event:AddEvent(BattleEventName.BeSeckill, self.onBeSecKill, self)
|
||
role.Event:AddEvent(BattleEventName.ShildTrigger, self.OnShieldTrigger, self)
|
||
role.Event:AddEvent(BattleEventName.ShowHintText,self.OnShowHintText,self)
|
||
role.Event:AddEvent(BattleEventName.RoleBeExile,self.OnRoleExile,self)
|
||
role.Event:AddEvent(BattleEventName.RoleExileEnd,self.OnRoleExileEnd,self)
|
||
role.Event:AddEvent(BattleEventName.BloodValueChange,self.OnBloodValueChange,self)
|
||
role.Event:AddEvent(BattleEventName.WeaponSkillCast,self.OnWeaponSkillCast,self)
|
||
if IsOpenBattleDebug then
|
||
local URoleProperty = go:GetComponent(typeof(RoleProperty))
|
||
if not URoleProperty then
|
||
URoleProperty = go:AddComponent(typeof(RoleProperty))
|
||
end
|
||
self.URoleProperty = URoleProperty
|
||
self.URoleProperty.uid = role.uid
|
||
role.data:Foreach(function (name, value)
|
||
--self.URoleProperty:AddProperty(name, value)
|
||
end)
|
||
end
|
||
|
||
-- boss 不显示
|
||
self.hpPassSlider.transform.parent.gameObject:SetActive(not self.isBoss)
|
||
self.nameText.transform.parent.gameObject:SetActive(not self.isBoss)
|
||
self.level.transform.parent.gameObject:SetActive(not self.isBoss)
|
||
self.elementImg.transform.parent.gameObject:SetActive(not self.isBoss)
|
||
self.rageSlider.transform.parent.gameObject:SetActive(not self.isBoss)
|
||
-- if BattlePanel and BattlePanel.guideType then
|
||
-- LogError("BattlePanel.guidetype=="..BattlePanel.guideType)
|
||
-- if BattlePanel.guideType==3 then
|
||
-- self.nameObj:SetActive(true)
|
||
-- self.nameParent:SetActive(false)
|
||
-- self.proPar:SetActive(false)
|
||
-- self.nameText.transform.parent.gameObject:SetActive(false)
|
||
-- self.elementImg.transform.parent.gameObject:SetActive(false)
|
||
-- else
|
||
-- self.nameParent:SetActive(true)
|
||
-- self.proPar:SetActive(true)
|
||
-- self.nameObj:SetActive(false)
|
||
-- end
|
||
-- else
|
||
-- self.nameObj:SetActive(false)
|
||
-- end
|
||
-- go.transform.localPosition=Vector3.New(0,-160,0)
|
||
|
||
self.nameObj:SetActive(false)
|
||
self.nameParent:SetActive(false)
|
||
self.proPar:SetActive(false)
|
||
self.nameText.transform.parent.gameObject:SetActive(false)
|
||
self.elementImg.transform.parent.gameObject:SetActive(false)
|
||
end
|
||
|
||
--
|
||
function EnemyView:OnSortingOrderChange(battleSorting)
|
||
self:ChangeCardSorting(battleSorting)
|
||
end
|
||
|
||
-- 改变卡牌层级
|
||
function EnemyView:ChangeCardSorting(sortingOrder)
|
||
-- 重计算层级
|
||
local pos = (self.role.position + 2) % 6 + 1
|
||
|
||
local sort = sortingOrder + (self.role.position>3 and (6-self.role.position+1) or self.role.position)
|
||
--
|
||
self.liveRoot:GetComponent("Canvas").sortingOrder = sort
|
||
self.GameObject:GetComponent("Canvas").sortingOrder = sort + 2 --血条层级加2
|
||
self.effect_rage:GetComponent("Canvas").sortingOrder = sort + 3
|
||
self.effect_dead:GetComponent("Canvas").sortingOrder = sort + 3
|
||
Util.SetParticleSortLayer(self.effect_rage, sort + 3)
|
||
Util.SetParticleSortLayer(self.effect_dead, sort + 3)
|
||
SetParticleSortLayer(self.effect_fly,sort+3)
|
||
end
|
||
|
||
function EnemyView:Update()
|
||
if self.role:IsRealDead() then
|
||
return
|
||
end
|
||
|
||
local hp = self.role:GetRoleData(RoleDataName.Hp) / self.role:GetRoleData(RoleDataName.MaxHp)
|
||
if self.hpCache ~= hp then
|
||
local f1 = self.hpCache
|
||
local f2 = hp
|
||
if f1 > f2 then
|
||
if self.hpTween then
|
||
self.hpTween:Kill()
|
||
end
|
||
self.hpSlider.fillAmount = hp
|
||
self.hpTween = DoTween.To(DG.Tweening.Core.DOGetter_float( function () return f1 end),
|
||
DG.Tweening.Core.DOSetter_float(function (progress)
|
||
self.hpPassSlider.fillAmount = progress
|
||
end), f2, 0.5):SetEase(Ease.Linear)
|
||
else
|
||
if self.hpPassTween then
|
||
self.hpPassTween:Kill()
|
||
end
|
||
self.hpPassSlider.fillAmount = hp
|
||
self.hpPassTween = DoTween.To(DG.Tweening.Core.DOGetter_float( function () return f1 end),
|
||
DG.Tweening.Core.DOSetter_float(function (progress)
|
||
self.hpSlider.fillAmount = progress
|
||
end), f2, 0.5):SetEase(Ease.Linear)
|
||
end
|
||
self.hpCache = hp
|
||
end
|
||
|
||
local rage = self.role.Rage / 4
|
||
if self.rageCache ~= rage then
|
||
-- 判断是否播放满怒动画
|
||
if (not self.rageCache or self.rageCache < 1) and rage >= 1 then
|
||
local go = BattleManager.LoadAsset(rageEffect)
|
||
go.transform:SetParent(self.GameObject.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero
|
||
go:SetActive(true)
|
||
BattleManager.AddDelayRecycleRes(rageEffect, go, 3)
|
||
end
|
||
|
||
self.effect_rage:SetActive(rage >= 1)
|
||
|
||
self.rageCache = rage
|
||
self.rageSlider.fillAmount = self.rageCache
|
||
self.rageText.gameObject:SetActive(self.rageCache >= 1)
|
||
self.rageText.text = self.role.Rage
|
||
|
||
if self.isBoss then
|
||
self.RootPanel:SetBossRage(self.role.Rage)
|
||
end
|
||
end
|
||
|
||
if self.BuffCtrl and self.BuffCtrl.Update then
|
||
self.BuffCtrl:Update()
|
||
end
|
||
|
||
if IsOpenBattleDebug then
|
||
self.role.data:Foreach(function (name, value)
|
||
--self.URoleProperty:SetValue(name, value)
|
||
end)
|
||
end
|
||
end
|
||
|
||
function EnemyView:OnWeaponSkillCast(value,type,num)
|
||
self.weaponObj:SetActive(true)
|
||
BattleLogic.WaitForTrigger(1.5,function()
|
||
self.weaponObj:SetActive(false)
|
||
end)
|
||
|
||
end
|
||
function EnemyView:GetWeaponObj()
|
||
return self.weaponObj
|
||
end
|
||
--角色被放逐
|
||
function EnemyView:OnRoleExile(role)
|
||
local color = Color.New(1,1,1,0.4)
|
||
Util.SetColor(self.RoleLiveGOGraphic, color)
|
||
end
|
||
--角色放逐结束
|
||
function EnemyView:OnRoleExileEnd(role)
|
||
local color = Color.New(1, 1, 1, 1)
|
||
Util.SetColor(self.RoleLiveGOGraphic, color)
|
||
end
|
||
|
||
function EnemyView:OnBloodValueChange(value,type,num)
|
||
self.yujiaSlider.fillAmount = value
|
||
if type and num then
|
||
if type==1 then
|
||
self.Floater:ArtFloating(ArtFloatingType.yujiaAdd, ArtFloatingColor.Green,num,TextFloatingColor.Green)
|
||
end
|
||
end
|
||
end
|
||
-- 缩放
|
||
function EnemyView:DoScale(scale, dur, func)
|
||
|
||
if self.dsTween then
|
||
self.dsTween:Kill()
|
||
end
|
||
if self.GameObject==nil then
|
||
return
|
||
end
|
||
self.dsTween = self.GameObject.transform.parent:DOScale(Vector3.one * scale, dur)
|
||
:OnComplete(function ()
|
||
-- Log("DoScale = "..scale)
|
||
if func then
|
||
func()
|
||
end
|
||
end)
|
||
|
||
if self.dsTween2 then
|
||
self.dsTween2:Kill()
|
||
end
|
||
--local liveScale = self.role.position <= 3 and 0.6 or 0.5
|
||
local liveScale=0.6
|
||
-- self.dsTween2 = self.RoleLiveGO.transform.parent:DOScale(Vector3.one * liveScale * scale, dur)
|
||
|
||
end
|
||
|
||
|
||
-- 设置高亮
|
||
function EnemyView:SetHighLight(isLight, eScale, dur, func)
|
||
-- 设置变灰
|
||
if self.isDead then
|
||
Util.SetGray(self.GameObject, true)
|
||
Util.SetSpineGray(self.RoleLiveGOGraphic, true)
|
||
Util.SetGray(self.deadIconGO, false)
|
||
|
||
local color = Color.New(75, 75, 75, 255)/255
|
||
Util.SetColor(self.GameObject, color)
|
||
Util.SetColor(self.RoleLiveGOGraphic, color)
|
||
Util.SetColor(self.deadIconGO, Color.New(1, 1, 1, 1))
|
||
self:DoScale(0.8, dur, func)
|
||
return
|
||
end
|
||
if self.isBoss then
|
||
eScale = 1
|
||
end
|
||
self:DoScale(1, dur, func)
|
||
-- 颜色变灰
|
||
local sc = isLight and 0.3 or 1
|
||
local ec = isLight and 1 or 0.3
|
||
if self.hlTween3 then
|
||
self.hlTween3:Kill()
|
||
end
|
||
self.hlTween3 = DoTween.To(DG.Tweening.Core.DOGetter_float( function () return sc end),
|
||
DG.Tweening.Core.DOSetter_float(function (progress)
|
||
local aaa=1
|
||
if self.role.isExile then
|
||
aaa=0.4
|
||
end
|
||
local color = Color.New(progress, progress, progress,aaa)
|
||
Util.SetColor(self.GameObject, color)
|
||
Util.SetColor(self.RoleLiveGOGraphic, color)
|
||
end), ec, dur):SetEase(Ease.Linear)
|
||
end
|
||
|
||
|
||
-- 播放动画
|
||
function EnemyView:PlaySpineAnim(gog, time, name, isLoop)
|
||
|
||
if isLoop then
|
||
gog.AnimationState:SetAnimation(time, name, isLoop)
|
||
self.currAniName=name
|
||
else
|
||
local _complete = nil
|
||
_complete = function(state)
|
||
gog.AnimationState.Complete = gog.AnimationState.Complete - _complete
|
||
gog.AnimationState:SetAnimation(0, "idle", true)
|
||
self.currAniName="idle"
|
||
end
|
||
gog.AnimationState:ClearTracks() -- 清除上一个动画的影响(修复概率攻击动画播放错误的问题)
|
||
gog.AnimationState:SetAnimation(time, name, isLoop)
|
||
self.currAniName=name
|
||
gog.AnimationState.Complete = gog.AnimationState.Complete + _complete
|
||
end
|
||
end
|
||
|
||
|
||
--单纯显示提示文字
|
||
function EnemyView:OnShowHintText(_ArtFontType)
|
||
local config = BattleManager.GetArtFontConfig(_ArtFontType)
|
||
if config then
|
||
self.Floater:ImageBuffFloating(config)
|
||
end
|
||
end
|
||
|
||
|
||
function EnemyView:OnSkillPlay(type)
|
||
-- local name="attack"
|
||
-- if type and type==1 then
|
||
-- name="skill"
|
||
-- end
|
||
|
||
local name="attack"
|
||
local humanname="attack"
|
||
if type and type==2 then
|
||
humanname="skill"
|
||
end
|
||
|
||
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, humanname, false)
|
||
if type==0 and self.RoleSkillLiveGoGraphic~=nil then
|
||
self:PlaySpineAnim(self.RoleSkillLiveGoGraphic, 0, name, false)
|
||
|
||
elseif self.RoleSkillLiveGoGraphic~=nil then
|
||
-- name="skill"
|
||
self:PlaySpineAnim(self.RoleSkillLiveGoGraphic2, 0, name, false)
|
||
end
|
||
|
||
end
|
||
|
||
function EnemyView:OnSkillEnd()
|
||
end
|
||
|
||
function EnemyView:OnSkillCastingStart()
|
||
-- 提前进入下一阶段
|
||
self.RoleLiveGO2:SetActive(true)
|
||
local name="idle"
|
||
if self.role.roleData.roleId==10016 or self.role.roleData.roleId== 21063 then
|
||
-- name="skill"
|
||
-- name="skill"
|
||
name="idle"
|
||
end
|
||
|
||
self:PlaySpineAnim(self.RoleLiveGOGraphic2, 0, name, false)
|
||
end
|
||
|
||
|
||
function EnemyView:OnSkillCastingEnd()
|
||
self.RoleLiveGO2:SetActive(false)
|
||
end
|
||
|
||
|
||
|
||
|
||
-- 治疗
|
||
function EnemyView:OnTreated(castRole, realTreat, treat)
|
||
self.Floater:ArtFloating(ArtFloatingType.Treat, ArtFloatingColor.Green, treat)
|
||
|
||
local sortingOrder = nil
|
||
local go = BattleManager.LoadAsset(healEffect, sortingOrder)
|
||
go.transform:SetParent(self.GameObject.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero--self.GameObject.transform.localPosition
|
||
go:SetActive(true)
|
||
BattleManager.AddDelayRecycleRes(healEffect, go, 3)
|
||
end
|
||
|
||
|
||
-- 盾效果触发
|
||
function EnemyView:OnShieldTrigger(shield,isImmuneAllReduceShield)
|
||
if shield.shieldType == ShieldTypeName.AllReduce then
|
||
if atkRole and not isImmuneAllReduceShield then
|
||
self.Floater:ImageBuffFloating("z_zhandou_wudizi_zh")
|
||
end
|
||
elseif shield.shieldType == ShieldTypeName.ThornsReduce then
|
||
|
||
elseif shield.shieldType == ShieldTypeName.ImmuneReduce then
|
||
-- body
|
||
else
|
||
self.Floater:ImageBuffFloating("z_zhandou_jianshang_zh")
|
||
end
|
||
end
|
||
|
||
-- 哈哈,没打着
|
||
function EnemyView:OnBeHitMiss(atkRole, skill)
|
||
self.Floater:ImageBuffFloating("z_zhandou_weimingzhong_zh")
|
||
end
|
||
|
||
local DotTypeTip = {
|
||
[0] = Language[10241],
|
||
[1] = Language[10242],
|
||
[2] = Language[10243],
|
||
[3] = Language[10244],
|
||
}
|
||
--
|
||
function EnemyView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill,isImmune)
|
||
if isImmune and isImmune==true then
|
||
return
|
||
end
|
||
if skill then
|
||
-- 技能配置
|
||
local combatId = BattleManager.GetCombatIdBySkin(skill.id, atkRole.roleData.skinId)
|
||
local combat = BattleManager.GetSkillCombat(combatId)
|
||
--
|
||
local delay = combat.DamageDelay or 0
|
||
local continue = skill.continueTime or 0
|
||
local count = type(combat.SkillNumbetTime[1][1]) == "userdata" and 1 or #combat.SkillNumbetTime
|
||
|
||
local space = continue / count
|
||
local d = math.floor(dmg / count)
|
||
-- 如果平均伤害小于0 则
|
||
if d == 0 then
|
||
d = dmg
|
||
count = 1
|
||
end
|
||
if BattleManager.IsBattleTestPanel() then
|
||
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s, 伤害段数:%s,每段伤害:%s", self.camp, self.role.position, dmg, count, d))
|
||
end
|
||
-- 伤害文字延时,有些受击特效不是立刻播放文字
|
||
|
||
-- 伤害文字
|
||
-- if count ~= 1 and skill.SkillNumbetTime==nil and skill.SkillNumbetTime~=0 then
|
||
if count ~=1 then
|
||
if combat.SkillNumbetTime and combat.SkillNumbetTime[1] and (type(combat.SkillNumbetTime[1][1]) ~= "userdata" and combat.SkillNumbetTime[1][1]~=0) then
|
||
for i = 1, #combat.SkillNumbetTime do
|
||
self:DelayFunc(combat.SkillNumbetTime[i][2]/1000, function()
|
||
local fd = dmg - d *(count - 1)
|
||
self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
|
||
-- 被伤害卡牌表现
|
||
self:DOHitEffect(continue)
|
||
self:DOHitMoveMent(continue,combat)
|
||
end)
|
||
end
|
||
end
|
||
-- 多段伤害
|
||
-- 后续伤害延迟打出
|
||
-- self:LoopFunc(space, count - 1, function()
|
||
-- self:OnceDamaged(atkRole, d, bCrit, finalDmg, damageType, dotType, skill)
|
||
-- end)
|
||
-- -- 立刻打出第一次伤害
|
||
-- local fd = dmg - d *(count - 1)
|
||
-- self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
|
||
-- -- 被伤害卡牌表现
|
||
-- self:DOHitEffect(continue)
|
||
|
||
else
|
||
self:DelayFunc(delay/1000, function()
|
||
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
|
||
-- 被伤害卡牌表现
|
||
self:DOHitEffect()
|
||
self:DOHitMoveMent(nil,combat)
|
||
end)
|
||
end
|
||
|
||
-- 播放特效
|
||
self.SkillCaster:CheckSkillHitEffect("hit", combat, skill)
|
||
else
|
||
if BattleManager.IsBattleTestPanel() then
|
||
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s", self.camp, self.role.position, dmg))
|
||
end
|
||
-- 伤害文字
|
||
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
|
||
-- 被伤害卡牌表现
|
||
self:DOHitEffect()
|
||
-- self:DOHitMoveMent(nil,combat)
|
||
end
|
||
end
|
||
--
|
||
function EnemyView:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
|
||
--王振兴注释,为了解决英雄死亡多段伤害显示不完整 2020/8/17
|
||
--if self.isDead then return end
|
||
if dotType then
|
||
if dotType == DotType.Poison then
|
||
self.Floater:ArtFloating(ArtFloatingType.PoisonDamage, ArtFloatingColor.Poison, dmg,TextFloatingColor.DarkGreen)
|
||
elseif dotType == DotType.Burn then
|
||
self.Floater:ArtFloating(ArtFloatingType.FireDamage, ArtFloatingColor.Fire, dmg)
|
||
elseif dotType == DotType.Blooding then
|
||
self.Floater:ArtFloating(ArtFloatingType.BleedDamage, ArtFloatingColor.Fire, dmg)
|
||
else
|
||
self.Floater:TextBuffFloating(2, DotTypeTip[dotType]..dmg)
|
||
end
|
||
else
|
||
if bCrit then -- 暴击红色并显示暴击
|
||
self.Floater:ArtFloating(ArtFloatingType.CritDamage, ArtFloatingColor.Red, dmg)
|
||
else
|
||
if atkRole.isTeam then -- 异妖紫色
|
||
self.Floater:ArtFloating(ArtFloatingType.Damage, ArtFloatingColor.Purple, dmg)
|
||
else
|
||
if skill and skill.type == BattleSkillType.Special then -- 技能黄色
|
||
self.Floater:ArtFloating(ArtFloatingType.Damage, ArtFloatingColor.Yellow, dmg)
|
||
else -- 普攻白色
|
||
self.Floater:ArtFloating(ArtFloatingType.Damage, ArtFloatingColor.White, dmg)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
-- 播放受击动画
|
||
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
|
||
end
|
||
|
||
-- 播放卡牌受击效果
|
||
function EnemyView:DOHitEffect(time, func)
|
||
-- 时间修正
|
||
if not time or time < 0.3 then
|
||
time = 0.3
|
||
end
|
||
|
||
if self.currAniName=="hit" then
|
||
-- 受击放大1.2倍
|
||
self:DoScale(1.2, 0.2)
|
||
-- 卡面变红
|
||
self.RoleLiveGOGraphic:DOColor(Color.New(1,0,0,1), 0.3):OnComplete(function ()
|
||
self.RoleLiveGOGraphic:DOColor(Color.New(1,1,1,1), 0.3):SetDelay(time)
|
||
end)
|
||
-- 震动
|
||
self.RoleLiveGOTran:DOShakeAnchorPos(time, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
|
||
self.RoleLiveGO.transform.anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2] )
|
||
-- 恢复大小
|
||
self:DoScale(1, 0.1)
|
||
-- 回调
|
||
if func then
|
||
func()
|
||
end
|
||
end)
|
||
else
|
||
-- 回调
|
||
if func then
|
||
func()
|
||
end
|
||
end
|
||
|
||
end
|
||
-- 播放卡牌受击位移
|
||
function EnemyView:DOHitMoveMent(time,combat,isback)
|
||
-- 时间修正
|
||
|
||
if not combat.AttackMove then
|
||
return
|
||
end
|
||
if not time or time < 0.05 then
|
||
time = 0.2
|
||
end
|
||
local target=Vector3.New(self.camp==0 and self.startPos.x-combat.AttackMove[1]/1000 or self.startPos.x+combat.AttackMove[1]/1000,self.startPos.y+combat.AttackMove[2] ,100)
|
||
self.RoleLiveGO.transform:DOMove(target, time, false):OnComplete(function ()
|
||
self.RoleLiveGO.transform:DOMove(self.startPos, time, false)
|
||
end)
|
||
end
|
||
function EnemyView:OnHealed(castRole)
|
||
local sortingOrder = nil
|
||
local go = BattleManager.LoadAsset(healEffect, sortingOrder)
|
||
go.transform:SetParent(self.GameObject.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.zero--self.GameObject.transform.localPosition
|
||
go:SetActive(true)
|
||
BattleManager.AddDelayRecycleRes(healEffect, go, 3)
|
||
end
|
||
|
||
|
||
-- 怒气值改变
|
||
function EnemyView:RoleRageChange(deltaRage)
|
||
if self.role:IsRealDead() then
|
||
return
|
||
end
|
||
if deltaRage ~= 0 then
|
||
if deltaRage > 0 then
|
||
self.Floater:ImageBuffFloating("z_zhandou_nuqijia_zh", nil, deltaRage)
|
||
else
|
||
self.Floater:ImageBuffFloating("z_zhandou_nuqijian_zh", nil, deltaRage,0,1)
|
||
--self.Floater:TextBuffFloating(1, Language[10245]..tostring(deltaRage))
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
function EnemyView:OnDead()
|
||
if self.hpTween then
|
||
self.hpTween:Kill()
|
||
end
|
||
if self.hpPassTween then
|
||
self.hpPassTween:Kill()
|
||
end
|
||
self.hpSlider.fillAmount = 0
|
||
self.yujiaSlider.fillAmount = 0
|
||
self.hpPassSlider.fillAmount = 0
|
||
--死亡后不把怒气条显示清空,处理触发不灭怒气不足四点 怒气条清空 2021/09/01
|
||
--self.rageSlider.fillAmount = 0
|
||
self.rageText.text = ""
|
||
end
|
||
|
||
-- 暴毙
|
||
function EnemyView:onBeSecKill()
|
||
self.Floater:ImageBuffFloating("z_zhandou_baobi_zh")
|
||
end
|
||
|
||
function EnemyView:OnRealDead()
|
||
|
||
self.effect_rage:SetActive(false)
|
||
self.effect_dead:SetActive(true)
|
||
self.RoleLiveGO:SetActive(true)
|
||
local order = BattleLogic.CurOrder
|
||
BattleManager.PauseBattle()
|
||
self.RoleLiveGOGraphic:DOFade(1, 0):OnComplete(function ()
|
||
self.RoleLiveGOGraphic:DOFade(0, 1):OnComplete(function ()
|
||
BattleManager.ResumeBattle()
|
||
self.RoleLiveGOGraphic.color = Color.New(1,1,1,1)
|
||
if order ~= BattleLogic.CurOrder then return end
|
||
self.GameObject:SetActive(false)
|
||
self.RoleLiveGO:SetActive(false)
|
||
self.effect_dead:SetActive(false)
|
||
if self.shadow then
|
||
self.shadow:SetActive(false)
|
||
end
|
||
end)
|
||
end)
|
||
self.deadIconGO:SetActive(true)
|
||
|
||
local color = Color.New(75, 75, 75, 255)/255
|
||
Util.SetColor(self.GameObject, color)
|
||
Util.SetColor(self.RoleLiveGOGraphic, color)
|
||
Util.SetGray(self.deadIconGO, false)
|
||
|
||
self.BuffCtrl:Dispose()
|
||
|
||
self.RoleLiveGOGraphic.freeze = true
|
||
self.RoleLiveGOGraphic2.freeze = true
|
||
|
||
self.isDead = true
|
||
end
|
||
|
||
function EnemyView:onRoleRelive()
|
||
self.effect_dead:SetActive(false)
|
||
self.GameObject:SetActive(true)
|
||
self.RoleLiveGO:SetActive(true)
|
||
if self.shadow then
|
||
self.shadow:SetActive(true)
|
||
end
|
||
self.deadIconGO:SetActive(false)
|
||
|
||
local color = Color.New(1, 1, 1, 1)
|
||
Util.SetColor(self.GameObject, color)
|
||
Util.SetColor(self.RoleLiveGOGraphic, color)
|
||
Util.SetGray(self.GameObject, false)
|
||
Util.SetSpineGray(self.RoleLiveGOGraphic, false)
|
||
self:DoScale(1, 0)
|
||
|
||
self.RoleLiveGOGraphic.freeze = false
|
||
self.RoleLiveGOGraphic2.freeze = false
|
||
|
||
self.isDead = false
|
||
self.yujiaSlider.fillAmount = 0
|
||
self.hpSlider.fillAmount=self.role:GetRoleData(RoleDataName.Hp) / self.role:GetRoleData(RoleDataName.MaxHp)
|
||
local sortingOrder = self.GameObject.transform:GetComponent("Canvas").sortingOrder + 21
|
||
local go = BattleManager.LoadAsset(reliveEffect1,sortingOrder)
|
||
go.transform:SetParent(self.GameObject.transform)
|
||
go.transform.localScale = Vector3.one
|
||
go.transform.localPosition = Vector3.New(0,-150,0)
|
||
go:SetActive(true)
|
||
BattleManager.AddDelayRecycleRes(reliveEffect1, go, 3)
|
||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function ()--加个延时,防止击杀的角色复活计算不准确
|
||
local go2 = BattleManager.LoadAsset(reliveEffect2,sortingOrder)
|
||
go2.transform:SetParent(self.GameObject.transform)
|
||
go2.transform.localScale = Vector3.one
|
||
go2.transform.localPosition = Vector3.New(0,-150,0)
|
||
go2:SetActive(true)
|
||
BattleManager.AddDelayRecycleRes(reliveEffect2, go, 3)
|
||
self.Floater:ImageBuffFloating("z_zhandou_fuhuo_zh")
|
||
end)
|
||
|
||
|
||
end
|
||
|
||
|
||
function EnemyView:onDispose()
|
||
self.spLoader:Destroy()
|
||
self.role.Event:RemoveEvent(BattleEventName.BloodValueChange,self.OnBloodValueChange,self)
|
||
self.GameObject.transform.parent.localScale = Vector3.one
|
||
|
||
self.Floater:Dispose()
|
||
self.BuffCtrl:Dispose()
|
||
--
|
||
Util.SetSpineGray(self.RoleLiveGOGraphic, false)
|
||
Util.SetSpineGray(self.RoleLiveGOGraphic2, false)
|
||
Util.SetColor(self.RoleLiveGOGraphic, Color.New(1, 1, 1, 1))
|
||
Util.SetColor(self.RoleLiveGOGraphic2, Color.New(1, 1, 1, 1))
|
||
self.RoleLiveGOGraphic.freeze = false
|
||
self.RoleLiveGOGraphic2.freeze = false
|
||
self.RoleLiveGO:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0,0, 0))
|
||
self.RoleLiveGO2:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0,0, 0))
|
||
poolManager:UnLoadLive(self.livePath, self.RoleLiveGO)
|
||
poolManager:UnLoadLive(self.livePath2, self.RoleLiveGO2)
|
||
-- poolManager:UnLoadLive(self.livePath2, self.RoleSkillLiveGo2)
|
||
-- poolManager:UnLoadLive(self.livePath2, self.RoleSkillLiveGo)
|
||
-- 回收本节点
|
||
BattlePool.RecycleItem(self.GameObject, BATTLE_POOL_TYPE.ENEMY_ROLE)
|
||
end |