2021-04-20 13:58:00 +08:00
2020-11-01 15:46:48 +08:00
local RoleConfig = ConfigManager.GetConfig ( ConfigName.RoleConfig )
local HeroConfig = ConfigManager.GetConfig ( ConfigName.HeroConfig )
2023-04-06 14:02:32 +08:00
local shenbingSkill = ConfigManager.GetConfig ( ConfigName.ShenBingSkill )
2020-11-01 15:46:48 +08:00
local SkillLogicConfig = ConfigManager.GetConfig ( ConfigName.SkillLogicConfig )
2022-05-24 11:57:47 +08:00
local BattlePanel = require ( " Modules/Battle/View/GuideBattleLogic " )
2020-11-01 15:46:48 +08:00
local healEffect = " c_xy_0012_skeff_tapsk_healeff "
local rageEffect = " s_jieling_hs_3006_skeff_casting_buff_nuqi "
2021-08-25 14:37:10 +08:00
local reliveEffect1 = " fx_chongsheng_lianhua "
local reliveEffect2 = " fx_chongsheng_lizhi "
2020-11-01 15:46:48 +08:00
PlayerView = BattleUnit.New ( )
function PlayerView . New ( go , role , position , root )
local o = BattleUnit.New ( go , role , position , root )
setmetatable ( o , PlayerView )
PlayerView.__index = PlayerView
o : ctor ( go , role , position , root )
return o
end
function PlayerView : onCreate ( go , role , position , root )
self.RootPanel = root
self.GameObject = go
self.role = role
self.camp = role.camp
2021-04-21 13:12:04 +08:00
self.spLoader = SpriteLoader.New ( )
2020-11-01 15:46:48 +08:00
self.castingEfectNode = self.RootPanel . mySkillCast
2023-12-29 17:34:32 +08:00
self.castingNameNode = Util.GetGameObject ( self.castingEfectNode , " TongYong_Casting_Xia/DongHua/MingZi2 " )
2021-11-17 17:29:17 +08:00
self.hpSlider = Util.GetGameObject ( go , " lvObj/hpProgress/hp " ) : GetComponent ( " Image " )
self.hpPassSlider = Util.GetGameObject ( go , " lvObj/hpProgress/hpPass " ) : GetComponent ( " Image " )
self.yujiaSlider = Util.GetGameObject ( go , " lvObj/hpProgress/yujia " ) : GetComponent ( " Image " )
2022-05-24 11:57:47 +08:00
self.nameParent = Util.GetGameObject ( go , " Name " )
self.proPar = Util.GetGameObject ( go , " Pro " )
2021-01-26 17:08:39 +08:00
self.nameText = Util.GetGameObject ( go , " Text " ) : GetComponent ( " Text " )
2021-11-17 17:29:17 +08:00
self.level = Util.GetGameObject ( go , " lvObj/lv/Text " ) : GetComponent ( " Text " )
2020-11-01 15:46:48 +08:00
self.elementImg = Util.GetGameObject ( go , " Pro/Image " ) : GetComponent ( " Image " )
self.bg1 = Util.GetGameObject ( go , " Bg1 " ) : GetComponent ( " Image " )
self.bg2 = Util.GetGameObject ( go , " Bg2 " ) : GetComponent ( " Image " )
self.hpCache = self.role : GetRoleData ( RoleDataName.Hp ) / self.role : GetRoleData ( RoleDataName.MaxHp )
self.hpSlider . fillAmount = self.hpCache
self.hpPassSlider . fillAmount = self.hpCache
2021-09-15 11:23:04 +08:00
self.yujiaSlider . fillAmount = 0
2020-11-06 10:12:24 +08:00
local roleId = role.roleData . roleId
2021-12-20 10:02:38 +08:00
self.roleId = role.roleData . roleId
2023-04-06 14:02:32 +08:00
self.weaponObj = Util.GetGameObject ( go , " weapon " )
self.weaponImg = Util.GetGameObject ( go , " weapon/Image " ) : GetComponent ( " Image " )
self.weaponObj : SetActive ( false )
2023-12-13 11:19:32 +08:00
2023-07-13 14:38:34 +08:00
2021-12-13 17:07:31 +08:00
-- 身外化身引导立绘展示处理
2021-12-20 10:02:38 +08:00
if self.roleId == 21061 then
2021-11-30 23:14:06 +08:00
self.skinId = 0
2021-12-13 17:07:31 +08:00
if NameManager.roleSex == ROLE_SEX.BOY then
2023-12-04 17:19:01 +08:00
self.livePath = " live2d_caomaolufei "
2021-12-13 17:07:31 +08:00
else
2023-12-04 17:19:01 +08:00
self.livePath = " live2d_namei "
2021-12-13 17:07:31 +08:00
end
2021-11-30 23:14:06 +08:00
else
2021-12-13 17:07:31 +08:00
local live = HeroConfig [ role.roleData . roleId ] . Live
-- 判断是否有皮肤
if not role.roleData . skinId or role.roleData . skinId == 0 then
self.skinId = 0
else
self.skinId = role.roleData . skinId
2021-12-29 13:08:32 +08:00
self.roleId = self.skinId
2021-12-13 17:07:31 +08:00
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
2023-08-30 20:33:29 +08:00
2020-11-06 10:12:24 +08:00
end
2021-12-13 17:07:31 +08:00
self.livePath = GetResourcePath ( live )
2023-07-06 14:08:10 +08:00
self.livePath2 = GetResourcePath ( HeroConfig [ role.roleData . roleId ] . Painting )
2023-08-16 10:49:55 +08:00
-- if role.roleData.roleId==10016 or role.roleData.roleId== 21063 then
-- self.livePath2=GetResourcePath(HeroConfig[role.roleData.roleId].Painting)
-- end
2021-11-30 23:14:06 +08:00
end
2020-11-06 10:12:24 +08:00
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
2021-01-26 17:08:39 +08:00
self.readingName = GetLanguageStrById ( HeroConfig [ role.roleData . roleId ] . ReadingName )
self.nameText . text = self.readingName
SetTextVerTial ( self.nameText , Vector3.New ( 33.6 , - 7.4 , 0 ) , " MiddleLeft " , nil , 6 )
2020-11-01 15:46:48 +08:00
self.level . text = role : GetRoleData ( RoleDataName.Level )
2021-04-21 13:12:04 +08:00
self.elementImg . sprite = self.spLoader : LoadSprite ( GetProStrImageByProNum ( role.roleData . element ) )
2022-05-24 11:57:47 +08:00
Util.GetGameObject ( go , " GameObject/name " ) : GetComponent ( " Text " ) . text = self.readingName
Util.GetGameObject ( go , " GameObject/pro " ) : GetComponent ( " Image " ) . sprite = self.spLoader : LoadSprite ( GetProStrImageByProNum ( role.roleData . element ) )
self.nameObj = Util.GetGameObject ( go , " GameObject " )
self.nameObj : SetActive ( false )
2022-06-29 14:54:23 +08:00
-- if BattlePanel and BattlePanel.guideType then
-- LogError("11111111111111==="..BattlePanel.guideType)
-- if BattlePanel.guideType==3 then
-- LogError("222222222")
-- self.nameParent:SetActive(true)
-- self.proPar:SetActive(true)
-- else
-- self.nameParent:SetActive(false)
-- self.proPar:SetActive(false)
-- end
-- else
-- self.nameParent:SetActive(false)
2023-07-04 10:28:57 +08:00
self.proPar : SetActive ( false )
2022-06-29 14:54:23 +08:00
-- end
2023-06-20 18:01:51 +08:00
self.nameParent . transform.parent . gameObject : SetActive ( false )
2023-07-04 10:28:57 +08:00
--self.proPar:SetActive(true)
2021-04-21 13:12:04 +08:00
self.bg1 . sprite = self.spLoader : LoadSprite ( GetBattleHeroCardStarBg [ role.roleData . star ] )
self.bg2 . sprite = self.spLoader : LoadSprite ( GetHeroCardStarFg [ role.roleData . star ] )
2021-11-05 18:13:32 +08:00
self.starGrid = Util.GetGameObject ( go , " StarGrid " )
2021-10-29 15:14:01 +08:00
local star = role.roleData . star or 5
local starType = 1
if role.roleData . godSoulLv and role.roleData . godSoulLv > 0 then
star = role.roleData . godSoulLv
starType = 3
self.bg2 . sprite = self.spLoader : LoadSprite ( " t_zhandoukuang_zhuangshi006 " )
2021-11-05 18:13:32 +08:00
-- self.starGrid:GetComponent("Image").enabled = false
2021-10-29 15:14:01 +08:00
end
2022-05-24 11:57:47 +08:00
2022-11-03 14:39:58 +08:00
--SetCardStars(self.starGrid, star, starType)
2020-11-01 15:46:48 +08:00
local zs = Util.GetGameObject ( go , " zs " )
local zsName = GetHeroCardStarZs [ role.roleData . star ]
2021-11-17 17:29:17 +08:00
-- if zsName == "" then
-- zs:SetActive(false)
-- else
-- zs:SetActive(true)
-- zs:GetComponent("Image").sprite = self.spLoader:LoadSprite(zsName)
-- end
2021-11-22 15:18:44 +08:00
-- 阴影
2023-12-13 11:19:32 +08:00
2021-11-25 14:46:46 +08:00
self.liveRoot = Util.GetGameObject ( self.RootPanel . PlayerPanel , " live_ " .. position )
self.liveRoot : GetComponent ( " Canvas " ) . overrideSorting = true
2023-12-13 11:19:32 +08:00
self.SingleHitEffectRoot = Util.GetGameObject ( self.liveRoot , " SingleHitEffectRoot " )
2021-11-25 14:46:46 +08:00
self.shadow = Util.GetGameObject ( self.liveRoot , " shadow " )
2021-11-22 15:18:44 +08:00
self.shadow : SetActive ( true )
2021-11-17 17:29:17 +08:00
self.RoleLiveGO = poolManager : LoadLive ( self.livePath , go.transform . parent , Vector3.one , Vector3.zero )
2020-11-01 15:46:48 +08:00
self.RoleLiveGOTran = self.RoleLiveGO : GetComponent ( " RectTransform " )
2021-11-25 14:46:46 +08:00
self.RoleLiveGOTran : SetParent ( self.liveRoot . transform )
self.RoleLiveGOTran . anchoredPosition = Vector2.New ( self.outOffset [ 1 ] , self.outOffset [ 2 ] ) -- * 0.5
self.RoleLiveGOTran . localScale = Vector3.one * self.enemy_liveScale
2020-11-01 15:46:48 +08:00
self.RoleLiveGOTran . sizeDelta = Vector2.New ( 1000 , 1000 )
2021-11-25 14:46:46 +08:00
self.RoleLiveGOGraphic = self.RoleLiveGO : GetComponent ( " SkeletonGraphic " )
2023-07-02 21:52:32 +08:00
-- local t= self.RoleLiveGOGraphic.SkeletonData.animations
2023-06-28 15:58:29 +08:00
self.RoleLiveGOGraphic . AnimationState : SetAnimation ( 0 , " idle " , true )
2021-11-17 17:29:17 +08:00
self.RoleLiveGO : SetActive ( true )
2023-12-13 11:19:32 +08:00
self.startPos = self.RoleLiveGO . transform.position
2023-11-14 13:50:52 +08:00
LogError ( " self.roleId=========================== " .. self.roleId )
2023-07-13 14:38:34 +08:00
local combatId = BattleManager.GetCombatIdBySkin ( self.role . skill [ 1 ] , self.skinId )
2023-08-04 18:58:14 +08:00
self.combat = BattleManager.GetSkillCombat ( combatId )
self.SkillAttackDisplaceoffset = self.combat . AttackDisplaceoffset
if self.combat . CloseRangeHit ~= nil and self.combat . CloseRangeHit ~= " " then
2023-11-08 16:35:53 +08:00
self.RoleSkillLiveGo = poolManager : LoadLive ( self.combat . CloseRangeHit , go.transform . parent , self.combat . CloseRangeHitScale == nil and Vector3.one or Vector3.New ( self.combat . CloseRangeHitScale [ 1 ] / 1000 , self.combat . CloseRangeHitScale [ 2 ] / 1000 , 1 ) , Vector3.zero )
2023-07-13 17:04:48 +08:00
self.RoleSkillLiveGoTran = self.RoleSkillLiveGo : GetComponent ( " RectTransform " )
self.RoleSkillLiveGoTran : SetParent ( self.RoleLiveGO . transform )
self.RoleSkillLiveGoTran . anchoredPosition = Vector2.New ( self.outOffset [ 1 ] , self.outOffset [ 2 ] ) -- * 0.5
2023-11-08 17:43:15 +08:00
self.RoleSkillLiveGoTran . localScale = self.combat . CloseRangeHitScale == nil and Vector3.one or Vector3.New ( self.combat . CloseRangeHitScale [ 1 ] / 1000 , self.combat . CloseRangeHitScale [ 2 ] / 1000 , 1 )
2023-07-13 17:04:48 +08:00
self.RoleSkillLiveGoTran . sizeDelta = Vector2.New ( 1000 , 1000 )
self.RoleSkillLiveGoGraphic = self.RoleSkillLiveGo : GetComponent ( " SkeletonGraphic " )
self.RoleSkillLiveGoGraphic . AnimationState : SetAnimation ( 0 , " idle " , true )
2023-12-27 19:05:37 +08:00
self.RoleSkillLiveGoGraphic . AnimationState.TimeScale = self.combat . SkillTimeScale / 1000
2023-07-13 14:38:34 +08:00
2023-07-13 17:04:48 +08:00
end
2023-07-13 14:38:34 +08:00
local combatId2 = BattleManager.GetCombatIdBySkin ( self.role . superSkill [ 1 ] , self.skinId )
2023-08-04 18:58:14 +08:00
self.combat2 = BattleManager.GetSkillCombat ( combatId2 )
if self.combat2 . CloseRangeHit ~= nil and self.combat2 . CloseRangeHit ~= " " then
self.superSkillAttackDisplaceoffset = self.combat2 . AttackDisplaceoffset
2023-11-08 16:35:53 +08:00
self.RoleSkillLiveGo2 = poolManager : LoadLive ( self.combat2 . CloseRangeHit , go.transform . parent , self.combat2 . CloseRangeHitScale == nil and Vector3.one or Vector3.New ( self.combat2 . CloseRangeHitScale [ 1 ] / 1000 , self.combat2 . CloseRangeHitScale [ 2 ] / 1000 , 1 ) , Vector3.zero )
2023-07-13 14:38:34 +08:00
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
2023-09-04 15:21:09 +08:00
if self.combat2 . CloseRangeHitOffset ~= nil then
2023-08-04 18:58:14 +08:00
self.RoleSkillLiveGoTran2 . localPosition = Vector2.New ( self.combat2 . CloseRangeHitOffset [ 1 ] , self.combat2 . CloseRangeHitOffset [ 2 ] ) -- * 0.5
2023-09-04 15:21:09 +08:00
else
self.RoleSkillLiveGoTran2 . localPosition = Vector2.New ( 0 , 0 ) -- * 0.5
end
2023-11-08 17:43:15 +08:00
self.RoleSkillLiveGoTran2 . localScale = self.combat2 . CloseRangeHitScale == nil and Vector3.one or Vector3.New ( self.combat2 . CloseRangeHitScale [ 1 ] / 1000 , self.combat2 . CloseRangeHitScale [ 2 ] / 1000 , 1 )
2023-07-13 14:38:34 +08:00
self.RoleSkillLiveGoTran2 . sizeDelta = Vector2.New ( 1000 , 1000 )
self.RoleSkillLiveGoGraphic2 = self.RoleSkillLiveGo2 : GetComponent ( " SkeletonGraphic " )
2023-12-27 19:05:37 +08:00
self.RoleSkillLiveGoGraphic2 . AnimationState.TimeScale = self.combat2 . SkillTimeScale / 1000
2023-07-13 14:38:34 +08:00
-- local t= self.RoleLiveGOGraphic.SkeletonData.animations
self.RoleSkillLiveGoGraphic2 . AnimationState : SetAnimation ( 0 , " idle " , true )
self.RoleSkillLiveGo2 : SetActive ( true )
2023-07-13 17:04:48 +08:00
end
2023-08-04 18:58:14 +08:00
2021-11-17 17:29:17 +08:00
-- 卡牌立绘显示
--self.liveRender = Util.GetGameObject(go, "Mask/icon"):GetComponent("RawImage")
--self.liveRender.texture, self.aaa , _, self.RoleLiveParnet = CardRendererManager.GetSpineTexture(role.position, self.livePath, Vector3.one * self.play_liveScale, Vector3.New(self.offset[1], self.offset[2], 0), false) --self.spLoader:LoadSprite(heroData.painting)
--self.liveRender.gameObject:SetActive(false)
-- self.liveRender.material = resMgr:LoadAsset("UI_AlphaMask "..position)
-- self.liveRender.transform:SetParent(Util.GetGameObject(go, "Mask").transform)
-- self.liveRender.transform.localScale = Vector3.one --* self.play_liveScale * 2
-- self.liveRender.transform.anchoredPosition = Vector3.zero--Vector2.New(self.offset[1], self.offset[2])
-- self.liveRender.gameObject:SetActive(true)
-- self.liveRender.material:SetInt("_IsMask", 1)
2020-11-01 15:46:48 +08:00
-- casting技能立绘
2023-08-16 10:49:55 +08:00
LogRed ( " painting== " .. self.livePath2 )
2023-06-28 15:58:29 +08:00
self.RoleLiveGO2 = poolManager : LoadLive ( self.livePath2 , go.transform . parent , Vector3.one , Vector3.zero )
2020-11-01 15:46:48 +08:00
self.RoleLiveGO2 . transform : SetParent ( self.RootPanel . mySkillCastRoot.transform )
2021-11-19 11:19:18 +08:00
self.RoleLiveGO2 . transform.localScale = Vector3.one * self.enemy_liveScale -- * 0.75--* 1.5
2020-11-01 15:46:48 +08:00
self.RoleLiveGO2 . transform.anchoredPosition = Vector2.New ( self.outOffset [ 1 ] , self.outOffset [ 2 ] - 300 )
self.RoleLiveGO2 : SetActive ( false )
self.RoleLiveGOGraphic2 = self.RoleLiveGO2 : GetComponent ( " SkeletonGraphic " )
self.RoleLiveGOTran2 = self.RoleLiveGO2 : GetComponent ( " RectTransform " )
2023-08-04 18:58:14 +08:00
-- 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
2023-06-28 15:58:29 +08:00
2020-11-01 15:46:48 +08:00
self.RoleLiveGOTran2 . sizeDelta = Vector2.New ( 1000 , 1000 )
2021-11-30 20:43:56 +08:00
local toward = 0
if self.skinId ~= 0 then
toward = RoleConfig [ roleId ] . Toward
else
toward = HeroConfig [ role.roleData . roleId ] . Toward
end
2021-11-25 15:04:55 +08:00
if toward == 1 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 ] )
2021-11-27 16:34:46 +08:00
self.RoleLiveGO2 : GetComponent ( " RectTransform " ) . anchoredPosition = Vector2.New ( mirrOffset [ 1 ] , mirrOffset [ 2 ] - 300 )
2021-11-30 23:14:06 +08:00
self.outOffset = RoleConfig [ roleId ] . mirrorimage_offset
2021-11-25 15:04:55 +08:00
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
2020-11-01 15:46:48 +08:00
--
self.RoleIconGO = Util.GetGameObject ( go , " func " )
self.RoleIconGO : SetActive ( true )
Util.SetGray ( self.RoleIconGO , false )
self.RoleIconTran = self.RoleIconGO : GetComponent ( " RectTransform " )
self.RoleIconTran . anchoredPosition = Vector2.zero
-- 死亡动画
self.deadIconGO = Util.GetGameObject ( self.RoleIconGO , " dead " )
self.deadIconGO : SetActive ( false )
self.effect_dead = Util.GetGameObject ( self.deadIconGO , " effect " )
-- 怒气显示
self.rageCache = nil
2021-11-17 17:29:17 +08:00
self.rageSlider = Util.GetGameObject ( go , " lvObj/rageProgress/rage " ) : GetComponent ( " Image " )
self.rageText = Util.GetGameObject ( go , " lvObj/rageProgress/Text " ) : GetComponent ( " Text " )
self.effect_rage = Util.GetGameObject ( go , " lvObj/rageProgress/effect " )
2020-11-01 15:46:48 +08:00
self.effect_rage : SetActive ( self.role . Rage >= 4 )
self.rageSlider . fillAmount = self.role . Rage / 4
2022-01-05 18:17:44 +08:00
self.effect_fly = Util.GetGameObject ( go , " c_long_zhandou_lizi " )
self.effect_fly : SetActive ( self.role . star >= 14 )
2020-11-01 15:46:48 +08:00
self.rageText . gameObject : SetActive ( false )
self.rageText . text = " "
2021-11-17 17:29:17 +08:00
self.lvHpObj = Util.GetGameObject ( go , " lvObj " )
2022-01-13 13:56:08 +08:00
self.buffRoot = Util.GetGameObject ( go , " buff " )
2023-06-29 15:04:58 +08:00
-- if position<=3 then
-- self.buffRoot:GetComponent("RectTransform").anchoredPosition=Vector3.New(0,389,0)
-- self.lvHpObj:GetComponent("RectTransform").anchoredPosition=Vector3.New(0,469,0)
-- self.nameParent:GetComponent("RectTransform").anchoredPosition=Vector3.New(-86,172,0)
-- self.proPar:GetComponent("RectTransform").anchoredPosition=Vector3.New(-86,238,0)
-- else
-- self.buffRoot:GetComponent("RectTransform").anchoredPosition=Vector3.New(0,-80,0)
-- self.lvHpObj:GetComponent("RectTransform").anchoredPosition=Vector3.New(0,0,0)
-- self.nameParent:GetComponent("RectTransform").anchoredPosition=Vector3.New(-86,-60,0)
-- self.proPar:GetComponent("RectTransform").anchoredPosition=Vector3.New(-86,6,0)
2022-05-24 13:35:24 +08:00
2023-06-29 15:04:58 +08:00
-- end
self.buffRoot : GetComponent ( " RectTransform " ) . anchoredPosition = Vector3.New ( 0 , 389 , 0 )
self.lvHpObj : GetComponent ( " RectTransform " ) . anchoredPosition = Vector3.New ( 0 , 469 , 0 )
self.nameParent : GetComponent ( " RectTransform " ) . anchoredPosition = Vector3.New ( - 86 , 172 , 0 )
self.proPar : GetComponent ( " RectTransform " ) . anchoredPosition = Vector3.New ( - 86 , 238 , 0 )
2021-12-07 16:33:04 +08:00
self.currAniName = " "
2020-11-01 15:46:48 +08:00
-- 伤害文字显示
self.LastBuffFloatingTime = Time.realtimeSinceStartup
self.BuffFloatingCount = 0
-- 层级设置
local battleSorting = BattleManager.GetBattleSorting ( )
2021-11-25 14:46:46 +08:00
self : ChangeCardSorting ( battleSorting )
2020-11-01 15:46:48 +08:00
-- 飘字管理
self.Floater = FloatNode.New ( self , self.RootPanel , self.GameObject )
-- buff管理
2022-01-13 13:56:08 +08:00
self.BuffCtrl = BuffCtrl.New ( self , self.buffRoot )
2020-11-01 15:46:48 +08:00
-- 创建技能播放器
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 )
2021-03-27 20:22:14 +08:00
role.Event : AddEvent ( BattleEventName.RoleBeExile , self.OnRoleExile , self )
role.Event : AddEvent ( BattleEventName.RoleExileEnd , self.OnRoleExileEnd , self )
2021-09-15 11:23:04 +08:00
role.Event : AddEvent ( BattleEventName.BloodValueChange , self.OnBloodValueChange , self )
2023-04-06 14:02:32 +08:00
role.Event : AddEvent ( BattleEventName.WeaponSkillCast , self.OnWeaponSkillCast , self )
2020-11-01 15:46:48 +08:00
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
2023-04-19 17:49:29 +08:00
-- local bbb={}
-- bbb=self.URoleProperty:GetNames()
-- --LogError("# aaa len=="..#bbb)
-- for key, value in pairs(bbb) do
-- LogError("# aaa i=="..value)
-- end
2020-11-01 15:46:48 +08:00
role.data : Foreach ( function ( name , value )
2023-04-19 17:49:29 +08:00
--self.URoleProperty:AddProperty(name, value)
2020-11-01 15:46:48 +08:00
end )
end
end
--
function PlayerView : OnSortingOrderChange ( battleSorting )
2021-11-25 14:46:46 +08:00
self : ChangeCardSorting ( battleSorting )
2020-11-01 15:46:48 +08:00
end
2021-09-30 09:53:31 +08:00
-- type==1 增加
function PlayerView : OnBloodValueChange ( value , type , num )
2022-08-03 14:20:57 +08:00
2021-09-15 11:23:04 +08:00
self.yujiaSlider . fillAmount = value
2021-09-30 09:53:31 +08:00
if type and num then
if type == 1 then
self.Floater : ArtFloating ( ArtFloatingType.yujiaAdd , ArtFloatingColor.Green , num , TextFloatingColor.Green )
end
end
2021-09-15 11:23:04 +08:00
end
2023-04-06 14:02:32 +08:00
function PlayerView : OnWeaponSkillCast ( value , type , num )
self.weaponObj : SetActive ( true )
2024-01-09 18:30:51 +08:00
BattleLogic.WaitForTrigger ( 2.5 , function ( )
2023-04-06 14:02:32 +08:00
self.weaponObj : SetActive ( false )
end )
end
function PlayerView : GetWeaponObj ( )
return self.weaponObj
end
2021-09-15 11:23:04 +08:00
2020-11-01 15:46:48 +08:00
-- 改变卡牌层级
function PlayerView : ChangeCardSorting ( sortingOrder )
2021-11-25 14:46:46 +08:00
-- 重计算层级
2023-06-29 15:04:58 +08:00
local pos = self.role . position
2023-07-02 21:52:32 +08:00
local sort = sortingOrder + ( pos > 3 and ( 6 - pos + 1 ) or pos )
2021-11-25 14:46:46 +08:00
self.liveRoot : GetComponent ( " Canvas " ) . sortingOrder = sort
self.GameObject : GetComponent ( " Canvas " ) . sortingOrder = sort + 2 --血条层级加一
2021-11-26 10:33:30 +08:00
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 )
2022-01-05 18:17:44 +08:00
SetParticleSortLayer ( self.effect_fly , sort + 3 )
2020-11-01 15:46:48 +08:00
end
function PlayerView : 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
-- TODO: 战斗引导相关调整
if rage == 1 then
Game.GlobalEvent : DispatchEvent ( GameEvent.Guide . GuideBattleCDDone , self )
end
end
if self.BuffCtrl and self.BuffCtrl . Update then
self.BuffCtrl : Update ( )
end
if IsOpenBattleDebug then
self.role . data : Foreach ( function ( name , value )
2023-04-19 17:49:29 +08:00
--self.URoleProperty:SetValue(name, value)
2020-11-01 15:46:48 +08:00
end )
end
end
-- 缩放
function PlayerView : DoScale ( scale , dur , func )
if self.dsTween then
self.dsTween : Kill ( )
end
2023-04-07 16:11:39 +08:00
if self.GameObject == nil then
return
end
2020-11-01 15:46:48 +08:00
self.dsTween = self.GameObject . transform.parent : DOScale ( Vector3.one * scale , dur )
: OnComplete ( function ( )
-- Log("DoScale = "..scale)
if func then
func ( )
end
end )
2021-11-17 17:29:17 +08:00
if self.dsTween2 then
self.dsTween2 : Kill ( )
end
2021-11-18 18:29:13 +08:00
--local liveScale = self.role.position <= 3 and 0.6 or 0.5
local liveScale = 0.6
2021-11-26 17:20:28 +08:00
-- self.dsTween2 = self.RoleLiveGO.transform.parent:DOScale(Vector3.one * liveScale * scale, dur)
2020-11-01 15:46:48 +08:00
end
2021-03-27 20:22:14 +08:00
--角色被放逐
function PlayerView : OnRoleExile ( role )
2021-11-17 17:29:17 +08:00
local color1 = Color.New ( 1 , 1 , 1 , 0.4 )
--Util.SetColor(self.liveRender, color)
Util.SetColor ( self.RoleLiveGOGraphic , color1 )
2021-03-27 20:22:14 +08:00
end
--角色放逐结束
function PlayerView : OnRoleExileEnd ( role )
2021-11-17 17:29:17 +08:00
local color2 = Color.New ( 1 , 1 , 1 , 1 )
--Util.SetColor(self.liveRender, color)
Util.SetColor ( self.RoleLiveGOGraphic , color2 )
2021-03-27 20:22:14 +08:00
end
2020-11-01 15:46:48 +08:00
-- 设置高亮
function PlayerView : 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
2023-06-28 15:58:29 +08:00
self : DoScale ( 1 , dur , func )
2020-11-01 15:46:48 +08:00
-- 颜色变灰
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 )
2021-11-17 17:29:17 +08:00
local aaa = 1
if self.role . isExile then
aaa = 0.4
end
local color = Color.New ( progress , progress , progress , aaa )
2020-11-01 15:46:48 +08:00
Util.SetColor ( self.GameObject , color )
Util.SetColor ( self.RoleLiveGOGraphic , color )
end ) , ec , dur ) : SetEase ( Ease.Linear )
end
-- 播放动画
2021-12-07 16:33:04 +08:00
2020-11-01 15:46:48 +08:00
function PlayerView : PlaySpineAnim ( gog , time , name , isLoop )
2021-12-10 09:57:08 +08:00
if startWith ( gog.gameObject . name , " live2d_npc " ) then
return
end
2020-11-01 15:46:48 +08:00
if isLoop then
2021-12-07 16:33:04 +08:00
self.currAniName = name
2020-11-01 15:46:48 +08:00
gog.AnimationState : SetAnimation ( time , name , isLoop )
else
local _complete = nil
_complete = function ( state )
gog.AnimationState . Complete = gog.AnimationState . Complete - _complete
2021-12-07 16:33:04 +08:00
self.currAniName = " idle "
2020-11-01 15:46:48 +08:00
gog.AnimationState : SetAnimation ( 0 , " idle " , true )
end
gog.AnimationState : ClearTracks ( ) -- 清除上一个动画的影响(修复概率攻击动画播放错误的问题)
2021-12-07 16:33:04 +08:00
self.currAniName = name
2020-11-01 15:46:48 +08:00
gog.AnimationState : SetAnimation ( time , name , isLoop )
gog.AnimationState . Complete = gog.AnimationState . Complete + _complete
end
end
2020-11-13 19:34:41 +08:00
--单纯显示提示文字
function PlayerView : OnShowHintText ( _ArtFontType )
local config = BattleManager.GetArtFontConfig ( _ArtFontType )
if config then
2021-06-30 10:40:52 +08:00
self.Floater : ImageBuffFloating ( config )
2020-11-13 19:34:41 +08:00
end
end
2023-08-04 18:58:14 +08:00
function PlayerView : OnSkillPlay ( type , combat )
2021-05-29 15:21:41 +08:00
if not self.GameObject then
return
end
2021-11-17 17:29:17 +08:00
self.lvHpObj : SetActive ( false )
--local battleSorting = BattleManager.GetBattleSorting()
-- self:ChangeCardSorting(battleSorting + 20)
2020-11-01 15:46:48 +08:00
-- 立绘缩小
2021-11-17 17:29:17 +08:00
-- if self.rlgTween2 then self.rlgTween2:Kill() end
-- self.rlgTween2 = self.RoleLiveParnet.transform:DOScale(Vector3.one * 0.85, 0.3):SetEase(Ease.OutSine)
-- -- 立绘位置剧中
-- if self.rlgTween3 then self.rlgTween3:Kill() end
-- self.rlgTween3 = self.RoleLiveParnet.transform:DOLocalMove(Vector3.New(0, 100, 0), 0.3, false):SetEase(Ease.OutSine)
-- if self.liveRender then
-- local mask2 = Util.GetGameObject(self.GameObject, "Mask2")
-- if mask2 then
-- self.liveRender.transform:SetParent(mask2.transform)
-- end
-- end
-- local cardRenderMat = self.liveRender.material
-- cardRenderMat:SetInt("_IsMask", 0)
2023-06-28 15:58:29 +08:00
-- if self.role.roleData.roleId==10016 then
-- type=1
-- end
2023-07-13 14:38:34 +08:00
local humanname = " attack "
2021-12-20 10:02:38 +08:00
local name = " attack "
2023-07-13 14:38:34 +08:00
if type ~= 0 then
humanname = " skill "
end
2023-09-18 15:41:32 +08:00
2023-07-13 14:38:34 +08:00
self : PlaySpineAnim ( self.RoleLiveGOGraphic , 0 , humanname , false )
2023-07-13 17:04:48 +08:00
if type == 0 and self.RoleSkillLiveGoGraphic ~= nil then
2023-07-13 14:38:34 +08:00
self : PlaySpineAnim ( self.RoleSkillLiveGoGraphic , 0 , name , false )
2023-08-04 18:58:14 +08:00
elseif self.RoleSkillLiveGoGraphic2 ~= nil and self.combat2 . EffectType == 8 then
2023-07-13 14:38:34 +08:00
-- name="skill"
2023-08-04 18:58:14 +08:00
-- local offset=Vector3.New(self.combat2.Offset[1],self.combat2.Offset[2],0)
2023-08-15 13:31:06 +08:00
-- self.RoleSkillLiveGoGraphic2.gameObject.transform.localPosition=Vector3.New(self.combat2.Offset[1],self.combat2.Offset[2],0)
2023-07-13 14:38:34 +08:00
self : PlaySpineAnim ( self.RoleSkillLiveGoGraphic2 , 0 , name , false )
2021-12-20 10:02:38 +08:00
end
2023-07-13 14:38:34 +08:00
2020-11-01 15:46:48 +08:00
end
function PlayerView : OnSkillEnd ( )
2021-05-29 15:21:41 +08:00
if not self.GameObject then
return
end
2021-11-25 14:46:46 +08:00
-- local battleSorting = BattleManager.GetBattleSorting()
-- self:ChangeCardSorting(battleSorting)
2021-11-17 17:29:17 +08:00
-- self.liveRender.transform:SetParent(Util.GetGameObject(self.GameObject, "Mask").transform)
--local cardRenderMat = self.liveRender.material
--cardRenderMat:SetInt("_IsMask", 1)
2021-05-28 13:31:06 +08:00
-- 动画播放就停止
2021-12-07 16:33:04 +08:00
--if self.rlgTween2 then self.rlgTween2:Kill() end
--if self.rlgTween3 then self.rlgTween3:Kill() end
2021-11-17 17:29:17 +08:00
--self.RoleLiveParnet.transform.localScale = Vector3.one --Vector2.New(self.offset[1], self.offset[2])
--self.RoleLiveParnet.transform.localPosition = Vector3(0, 0, 0)
--self.liveRender.transform.anchoredPosition = Vector2.zero--Vector2.New(self.offset[1], self.offset[2])
self.lvHpObj : SetActive ( true )
2020-11-01 15:46:48 +08:00
end
2021-12-20 10:02:38 +08:00
function PlayerView : OnSkillCastingStart ( type )
2020-11-01 15:46:48 +08:00
-- 提前进入下一阶段
self.RoleLiveGO2 : SetActive ( true )
2021-11-17 17:29:17 +08:00
self.lvHpObj : SetActive ( false )
2023-07-13 14:38:34 +08:00
local name = " idle "
2023-06-28 15:58:29 +08:00
type = 0
2023-07-13 14:38:34 +08:00
-- if (self.role.roleData.roleId==10016 or self.role.roleData.roleId== 21063 or self.role.roleData.roleId== 21064) then
-- type=0
-- name="animation"
-- coroutine.start(function()
-- coroutine.wait(1.1)
-- end)
-- end
-- if type and type~=0 then
-- name="skill"
-- end
-- coroutine.start(function()
-- coroutine.wait(1.1)
-- end)
2023-06-28 15:58:29 +08:00
2021-12-20 10:02:38 +08:00
self : PlaySpineAnim ( self.RoleLiveGOGraphic2 , 0 , name , false )
2020-11-01 15:46:48 +08:00
end
function PlayerView : OnSkillCastingEnd ( )
self.RoleLiveGO2 : SetActive ( false )
end
-- 治疗
2024-01-13 18:54:16 +08:00
function PlayerView : OnTreated ( castRole , realTreat , treat , skill )
if skill then
-- 技能配置
local combatId = BattleManager.GetCombatIdBySkin ( skill.id , castRole.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 ( treat / count )
-- 如果平均伤害小于0 则
if d == 0 then
d = treat
count = 1
end
local t = { }
-- 伤害文字延时,有些受击特效不是立刻播放文字
-- 伤害文字
-- 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 ( )
self.Floater : ArtFloating ( ArtFloatingType.Treat , ArtFloatingColor.Green , d , t )
local sortingOrder = self.GameObject : GetComponent ( " Canvas " ) . sortingOrder + 21
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 )
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.Floater : ArtFloating ( ArtFloatingType.Treat , ArtFloatingColor.Green , d , t )
local sortingOrder = self.GameObject : GetComponent ( " Canvas " ) . sortingOrder + 21
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
else
self.Floater : ArtFloating ( ArtFloatingType.Treat , ArtFloatingColor.Green , treat )
local sortingOrder = self.GameObject : GetComponent ( " Canvas " ) . sortingOrder + 21
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
2020-11-01 15:46:48 +08:00
end
-- 盾效果触发
2020-12-26 17:43:46 +08:00
function PlayerView : OnShieldTrigger ( shield , isImmuneAllReduceShield )
2020-11-01 15:46:48 +08:00
if shield.shieldType == ShieldTypeName.AllReduce then
2020-12-26 17:43:46 +08:00
if atkRole and not isImmuneAllReduceShield then
2021-01-26 17:08:39 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_wudizi_zh " )
2021-12-10 15:22:18 +08:00
end
elseif shield.shieldType == ShieldTypeName.ThornsReduce then
2022-03-17 16:50:40 +08:00
elseif shield.shieldType == ShieldTypeName.ImmuneReduce then
-- body
2020-11-01 15:46:48 +08:00
else
2021-06-30 10:40:52 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_jianshang_zh " )
2020-11-01 15:46:48 +08:00
end
end
-- 哈哈,没打着
function PlayerView : OnBeHitMiss ( atkRole , skill )
2021-06-30 10:40:52 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_weimingzhong_zh " )
2020-11-01 15:46:48 +08:00
end
local DotTypeTip = {
2021-04-09 12:26:35 +08:00
[ 0 ] = Language [ 10241 ] ,
[ 1 ] = Language [ 10242 ] ,
[ 2 ] = Language [ 10243 ] ,
[ 3 ] = Language [ 10244 ] ,
2020-11-01 15:46:48 +08:00
}
--
2024-01-02 18:24:32 +08:00
-- function PlayerView: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 = skill.attackCount or 1
-- 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()
-- end
-- end
-- --
-- function PlayerView: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,self.role)
-- elseif dotType == DotType.Burn then
-- self.Floater:ArtFloating(ArtFloatingType.FireDamage, ArtFloatingColor.Fire, dmg,self.role)
-- elseif dotType == DotType.Blooding then
-- self.Floater:ArtFloating(ArtFloatingType.BleedDamage, ArtFloatingColor.Fire, dmg,self.role)
-- else
-- self.Floater:TextBuffFloating(2, DotTypeTip[dotType]..dmg)
-- end
-- else
-- if bCrit then -- 暴击红色并显示暴击
-- self.Floater:ArtFloating(ArtFloatingType.CritDamage, ArtFloatingColor.Red, dmg,self.role)
-- else
-- if atkRole.isTeam then -- 异妖紫色
-- self.Floater:ArtFloating(ArtFloatingType.Damage, ArtFloatingColor.Purple, dmg,self.role)
-- else
-- if skill and skill.type == BattleSkillType.Special then -- 技能黄色
-- self.Floater:ArtFloating(ArtFloatingType.Damage, ArtFloatingColor.Yellow, dmg,self.role)
-- else -- 普攻白色
-- self.Floater:ArtFloating(ArtFloatingType.Damage, ArtFloatingColor.White, dmg,self.role)
-- end
-- end
-- end
-- end
-- -- 播放受击动画
-- self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
-- end
2022-01-06 15:30:40 +08:00
function PlayerView : OnDamaged ( atkRole , dmg , bCrit , finalDmg , damageType , dotType , skill , isImmune )
if isImmune and isImmune == true then
2024-01-02 18:24:32 +08:00
return
2022-01-06 15:30:40 +08:00
end
2024-01-02 18:24:32 +08:00
local t = { }
local pos = self.GameObject . transform.position
2021-11-12 11:59:40 +08:00
if skill then
-- 技能配置
local combatId = BattleManager.GetCombatIdBySkin ( skill.id , atkRole.roleData . skinId )
local combat = BattleManager.GetSkillCombat ( combatId )
2024-01-02 18:24:32 +08:00
--
2021-11-12 11:59:40 +08:00
local delay = combat.DamageDelay or 0
2024-01-02 18:24:32 +08:00
local continue = skill.continueTime or 0
2023-12-02 16:57:39 +08:00
local count = type ( combat.SkillNumbetTime [ 1 ] [ 1 ] ) == " userdata " and 1 or # combat.SkillNumbetTime
2024-01-02 18:24:32 +08:00
2021-11-12 11:59:40 +08:00
local space = continue / count
local d = math.floor ( dmg / count )
2020-11-01 15:46:48 +08:00
-- 如果平均伤害小于0 则
if d == 0 then
d = dmg
count = 1
end
2020-11-14 17:37:24 +08:00
if BattleManager.IsBattleTestPanel ( ) then
LogYellow ( string.format ( " 目标阵营:%s, 位置:%s, 总伤害:%s, 伤害段数:%s, 每段伤害: %s " , self.camp , self.role . position , dmg , count , d ) )
end
2021-11-12 11:59:40 +08:00
-- 伤害文字延时,有些受击特效不是立刻播放文字
2024-01-02 18:24:32 +08:00
2021-11-12 11:59:40 +08:00
-- 伤害文字
2024-01-02 18:24:32 +08:00
-- if count ~= 1 and skill.SkillNumbetTime==nil and skill.SkillNumbetTime~=0 then
2023-12-02 16:57:39 +08:00
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
2023-11-30 13:38:19 +08:00
self : DelayFunc ( combat.SkillNumbetTime [ i ] [ 2 ] / 1000 , function ( )
local fd = dmg - d * ( count - 1 )
2024-01-02 18:24:32 +08:00
self : OnceDamaged ( atkRole , fd , bCrit , finalDmg , damageType , dotType , skill , t , pos )
2023-11-30 13:38:19 +08:00
-- 被伤害卡牌表现
self : DOHitEffect ( continue )
2023-12-13 11:19:32 +08:00
self : DOHitMoveMent ( continue , combat )
2023-12-02 16:57:39 +08:00
end )
end
end
-- 多段伤害
2021-11-12 11:59:40 +08:00
-- 后续伤害延迟打出
2023-11-30 13:38:19 +08:00
-- 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)
2023-12-02 16:57:39 +08:00
2021-11-12 11:59:40 +08:00
else
2023-12-02 16:57:39 +08:00
self : DelayFunc ( delay / 1000 , function ( )
2024-01-02 18:24:32 +08:00
self : OnceDamaged ( atkRole , dmg , bCrit , finalDmg , damageType , dotType , skill , t , pos )
2021-11-12 11:59:40 +08:00
-- 被伤害卡牌表现
2023-12-02 16:57:39 +08:00
self : DOHitEffect ( )
2023-12-13 11:19:32 +08:00
self : DOHitMoveMent ( nil , combat )
2023-12-02 16:57:39 +08:00
end )
2021-11-12 11:59:40 +08:00
end
2023-11-30 13:38:19 +08:00
2021-11-12 11:59:40 +08:00
-- 播放特效
self.SkillCaster : CheckSkillHitEffect ( " hit " , combat , skill )
2020-11-01 15:46:48 +08:00
else
2020-11-14 17:37:24 +08:00
if BattleManager.IsBattleTestPanel ( ) then
LogYellow ( string.format ( " 目标阵营:%s, 位置:%s, 总伤害:%s " , self.camp , self.role . position , dmg ) )
end
2021-11-12 11:59:40 +08:00
-- 伤害文字
2024-01-02 18:24:32 +08:00
self : OnceDamaged ( atkRole , dmg , bCrit , finalDmg , damageType , dotType , skill , t , pos )
2021-11-12 11:59:40 +08:00
-- 被伤害卡牌表现
self : DOHitEffect ( )
2024-01-02 18:24:32 +08:00
-- self:DOHitMoveMent(nil,combat)
2020-11-01 15:46:48 +08:00
end
end
--
2024-01-02 18:24:32 +08:00
function PlayerView : OnceDamaged ( atkRole , dmg , bCrit , finalDmg , damageType , dotType , skill , t , pos )
2020-11-01 15:46:48 +08:00
--王振兴注释,为了解决英雄死亡多段伤害显示不完整 2020/8/17
--if self.isDead then return end
if dotType then
if dotType == DotType.Poison then
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.PoisonDamage , ArtFloatingColor.Poison , dmg , t , pos )
2020-11-01 15:46:48 +08:00
elseif dotType == DotType.Burn then
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.FireDamage , ArtFloatingColor.Fire , dmg , t , pos )
2021-11-23 10:46:52 +08:00
elseif dotType == DotType.Blooding then
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.BleedDamage , ArtFloatingColor.Fire , dmg , t , pos )
2020-11-01 15:46:48 +08:00
else
self.Floater : TextBuffFloating ( 2 , DotTypeTip [ dotType ] .. dmg )
end
else
if bCrit then -- 暴击红色并显示暴击
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.CritDamage , ArtFloatingColor.Red , dmg , t , pos )
2020-11-01 15:46:48 +08:00
else
if atkRole.isTeam then -- 异妖紫色
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.Damage , ArtFloatingColor.Purple , dmg , t , pos )
2020-11-01 15:46:48 +08:00
else
if skill and skill.type == BattleSkillType.Special then -- 技能黄色
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.Damage , ArtFloatingColor.Yellow , dmg , t , pos )
2020-11-01 15:46:48 +08:00
else -- 普攻白色
2024-01-02 18:24:32 +08:00
self.Floater : ArtFloating ( ArtFloatingType.Damage , ArtFloatingColor.White , dmg , t , pos )
2020-11-01 15:46:48 +08:00
end
end
end
end
2021-11-12 11:59:40 +08:00
-- 播放受击动画
self : PlaySpineAnim ( self.RoleLiveGOGraphic , 0 , " hit " , false )
end
2020-11-01 15:46:48 +08:00
2021-11-12 11:59:40 +08:00
-- 播放卡牌受击效果
function PlayerView : DOHitEffect ( time , func )
-- 时间修正
if not time or time < 0.3 then
time = 0.3
end
2022-11-16 13:31:13 +08:00
if self.currAniName == " hit " then
2021-12-07 16:33:04 +08:00
-- 受击放大1.2倍
2022-11-16 13:31:13 +08:00
self : DoScale ( 1.2 , 0.2 )
2021-12-07 16:33:04 +08:00
-- 卡面变红
DoTween.To ( DG.Tweening . Core.DOGetter_float ( function ( ) return 1 end ) ,
2020-11-01 15:46:48 +08:00
DG.Tweening . Core.DOSetter_float ( function ( progress )
local color = Color.New ( 1 , progress , progress , 1 )
2022-11-16 13:31:13 +08:00
-- Util.SetColor(self.GameObject, color)
2020-11-01 15:46:48 +08:00
Util.SetColor ( self.RoleLiveGOGraphic , color )
2022-11-16 13:31:13 +08:00
end ) , 0 , 0.3 ) : SetEase ( Ease.Linear ) : OnComplete ( function ( )
2021-12-07 16:33:04 +08:00
DoTween.To ( DG.Tweening . Core.DOGetter_float ( function ( ) return 0 end ) ,
DG.Tweening . Core.DOSetter_float ( function ( progress )
local color = Color.New ( 1 , progress , progress , 1 )
2022-11-16 13:31:13 +08:00
-- Util.SetColor(self.GameObject, color)
2021-12-07 16:33:04 +08:00
Util.SetColor ( self.RoleLiveGOGraphic , color )
2022-11-16 13:31:13 +08:00
end ) , 1 , 0.3 ) : SetEase ( Ease.Linear ) : SetDelay ( time )
2021-12-07 16:33:04 +08:00
end )
-- 震动
self.RoleLiveGOTran : DOShakeAnchorPos ( time , Vector2.New ( 200 , 100 ) , 100 , 50 , false , true ) : OnComplete ( function ( )
self.RoleLiveGOTran . anchoredPosition = Vector2.New ( self.outOffset [ 1 ] , self.outOffset [ 2 ] )
-- if self.GameObject then
-- self.GameObject.transform.parent.anchoredPosition = Vector2.New(self.role.position == 1 and -145 or 0, -221)
-- end
-- 恢复大小
self : DoScale ( 1 , 0.1 )
-- 回调
if func then
func ( )
end
end )
else
2021-11-12 11:59:40 +08:00
if func then
func ( )
end
2021-12-07 16:33:04 +08:00
end
2020-11-01 15:46:48 +08:00
end
2023-12-13 11:19:32 +08:00
-- 播放卡牌受击位移
function PlayerView : DOHitMoveMent ( time , combat , isback )
-- 时间修正
2021-11-12 11:59:40 +08:00
2023-12-13 11:19:32 +08:00
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
2021-11-12 11:59:40 +08:00
2020-11-01 15:46:48 +08:00
function PlayerView : OnHealed ( castRole )
local sortingOrder = self.GameObject : GetComponent ( " Canvas " ) . sortingOrder + 21
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 PlayerView : RoleRageChange ( deltaRage )
2021-01-08 18:51:26 +08:00
if self.role : IsRealDead ( ) then
return
end
2020-11-01 15:46:48 +08:00
if deltaRage ~= 0 then
if deltaRage > 0 then
2021-01-26 17:08:39 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_nuqijia_zh " , nil , deltaRage )
2020-11-01 15:46:48 +08:00
else
2021-06-30 18:06:56 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_nuqijian_zh " , nil , deltaRage , 0 , 1 )
2020-11-01 15:46:48 +08:00
end
end
end
function PlayerView : OnDead ( )
if self.hpTween then
self.hpTween : Kill ( )
end
if self.hpPassTween then
self.hpPassTween : Kill ( )
end
self.hpSlider . fillAmount = 0
self.hpPassSlider . fillAmount = 0
2021-09-15 11:23:04 +08:00
self.yujiaSlider . fillAmount = 0
2021-11-17 17:29:17 +08:00
--self.RoleLiveGO.gameObject:SetActive(false)
self.lvHpObj : SetActive ( false )
2023-08-15 15:50:24 +08:00
self : PlaySpineAnim ( self.RoleLiveGOGraphic , 0 , " death " , false )
2021-09-01 18:40:32 +08:00
--死亡后不把怒气条显示清空,处理触发不灭怒气不足四点 怒气条清空 2021/09/01
--self.rageSlider.fillAmount = 0
2020-11-01 15:46:48 +08:00
self.rageText . text = " "
end
-- 暴毙
function PlayerView : onBeSecKill ( )
2021-06-30 10:40:52 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_baobi_zh " )
2020-11-01 15:46:48 +08:00
end
function PlayerView : OnRealDead ( )
Util.SetGray ( self.RoleIconGO , true )
2024-01-02 13:32:17 +08:00
self.effect_dead : SetActive ( false )
2020-11-01 15:46:48 +08:00
self.effect_rage : SetActive ( false )
2021-11-17 17:29:17 +08:00
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 )
2020-11-01 15:46:48 +08:00
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 PlayerView : onRoleRelive ( )
2021-11-22 17:21:59 +08:00
self.GameObject : SetActive ( true )
2020-11-01 15:46:48 +08:00
Util.SetGray ( self.RoleIconGO , false )
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
2021-09-15 11:23:04 +08:00
self.yujiaSlider . fillAmount = 0
2021-01-18 16:13:51 +08:00
self.hpSlider . fillAmount = self.role : GetRoleData ( RoleDataName.Hp ) / self.role : GetRoleData ( RoleDataName.MaxHp )
2021-08-25 14:37:10 +08:00
local sortingOrder = self.GameObject : 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 , - 180 , 0 )
go : SetActive ( true )
local go2 = BattleManager.LoadAsset ( reliveEffect2 , sortingOrder )
go2.transform : SetParent ( self.GameObject . transform )
go2.transform . localScale = Vector3.one
go2.transform . localPosition = Vector3.New ( 0 , - 180 , 0 )
go2 : SetActive ( true )
BattleManager.AddDelayRecycleRes ( reliveEffect1 , go , 3 )
BattleManager.AddDelayRecycleRes ( reliveEffect2 , go , 3 )
2021-06-30 10:40:52 +08:00
self.Floater : ImageBuffFloating ( " z_zhandou_fuhuo_zh " )
2021-11-17 17:29:17 +08:00
self.RoleLiveGO . gameObject : SetActive ( true )
self.lvHpObj : SetActive ( true )
2021-08-25 14:37:10 +08:00
2020-11-01 15:46:48 +08:00
end
function PlayerView : onDispose ( )
self.GameObject . transform.parent . localScale = Vector3.one
2022-08-03 14:20:57 +08:00
self.role . Event : RemoveEvent ( BattleEventName.BloodValueChange , self.OnBloodValueChange , self )
2021-04-21 13:12:04 +08:00
self.spLoader : Destroy ( )
self.Floater : Dispose ( )
2020-11-01 15:46:48 +08:00
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
2021-11-26 11:24:46 +08:00
self.RoleLiveGO : GetComponent ( " RectTransform " ) . rotation = Quaternion.Euler ( Vector3.New ( 0 , 0 , 0 ) )
self.RoleLiveGO2 : GetComponent ( " RectTransform " ) . rotation = Quaternion.Euler ( Vector3.New ( 0 , 0 , 0 ) )
2023-07-13 14:38:34 +08:00
poolManager : UnLoadLive ( self.livePath2 , self.RoleLiveGO2 )
2021-11-17 17:29:17 +08:00
poolManager : UnLoadLive ( self.livePath , self.RoleLiveGO )
2023-08-04 18:58:14 +08:00
poolManager : UnLoadLive ( self.combat2 . CloseRangeHit , self.RoleSkillLiveGo2 )
poolManager : UnLoadLive ( self.combat . CloseRangeHit , self.RoleSkillLiveGo )
-- -- 回收本节点
2020-11-01 15:46:48 +08:00
BattlePool.RecycleItem ( self.GameObject , BATTLE_POOL_TYPE.MY_ROLE )
2021-05-27 22:11:06 +08:00
self.GameObject = nil
2020-11-01 15:46:48 +08:00
end
return PlayerView