[战斗]======我方单位显示立绘提交

dev_chengFeng
wangzhenxing 2021-11-12 18:58:55 +08:00
parent 9314e90111
commit f23dfe81e7
3 changed files with 1323 additions and 418 deletions

File diff suppressed because it is too large Load Diff

View File

@ -413,6 +413,7 @@ function this.InitBattleEvent()
BattleLogic.Event:AddEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange)
BattleLogic.Event:AddEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange)
BattleLogic.Event:AddEvent(BattleEventName.RoleTurnStart, this.RoleTurnChange)
BattleLogic.Event:AddEvent(BattleEventName.BattleStart, this.OnBattleStart)
end
-- 清除战斗数据
@ -426,6 +427,7 @@ function this.ClearBattleEvent()
BattleLogic.Event:RemoveEvent(BattleEventName.BattleOrderChange, this.BattleOrderChange)
BattleLogic.Event:RemoveEvent(BattleEventName.BattleRoundChange, this.BattleRoundChange)
BattleLogic.Event:RemoveEvent(BattleEventName.RoleTurnStart, this.RoleTurnChange)
BattleLogic.Event:RemoveEvent(BattleEventName.BattleStart, this.OnBattleStart)
end
--敌军出现的表现
@ -489,6 +491,14 @@ function this.EnemyAppear(isStart)
end
end
-- 战斗开始回调
function this.OnBattleStart()
-- 回调UI层
if this.root.OnBattleStart then
this.root.OnBattleStart()
end
end
-- 角色轮转回调(不出手的位置不会回调)
function this.RoleTurnChange(role)
-- 回调UI层
@ -620,7 +630,7 @@ function this.BattleOrderChange(order)
enemyPos.localScale = Vector3.zero
enemyLivePos.localScale = Vector3.zero
local myPos = Util.GetTransform(this.PlayerPanel, "View/"..i.."/root")
local myPos = Util.GetTransform(this.PlayerPanel, i.."/root")
myPos:GetComponent("Image").sprite = this.spLoader:LoadSprite("bd_xinkapaifan")
myPos.localScale = Vector3.one
end
@ -630,7 +640,7 @@ end
function this.OnAddRole(data)
local go
if data.camp == 0 then
local parent = Util.GetTransform(this.PlayerPanel, "View/"..data.position.."/root")
local parent = Util.GetTransform(this.PlayerPanel, data.position.."/root")
go = BattlePool.GetItem(parent, BATTLE_POOL_TYPE.MY_ROLE)
playerHP = playerHP + data:GetRoleData(RoleDataName.Hp)
playerMaxHP = playerMaxHP + data:GetRoleData(RoleDataName.MaxHp)

View File

@ -29,12 +29,12 @@ function PlayerView:onCreate(go, role, position, root)
self.castingEfectNode = self.RootPanel.mySkillCast
self.castingNameNode = Util.GetGameObject(self.castingEfectNode, "TongYong_Casting_Xia/DongHua/MingZi")
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.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")
local nameParent = Util.GetGameObject(go, "Name")
self.nameText = Util.GetGameObject(go, "Text"):GetComponent("Text")
self.level = Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
self.level = Util.GetGameObject(go, "lvObj/lv/Text"):GetComponent("Text")
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")
@ -86,27 +86,40 @@ function PlayerView:onCreate(go, role, position, root)
SetCardStars(self.starGrid, star, starType)
local zs = Util.GetGameObject(go, "zs")
local zsName = GetHeroCardStarZs[role.roleData.star]
if zsName == "" then
zs:SetActive(false)
else
zs:SetActive(true)
zs:GetComponent("Image").sprite = self.spLoader:LoadSprite(zsName)
end
-- 卡牌立绘显示
self.liveRender = Util.GetGameObject(go, "Mask/icon"):GetComponent("RawImage")
self.liveRender.texture, self.RoleLiveGO , _, 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.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)
-- if zsName == "" then
-- zs:SetActive(false)
-- else
-- zs:SetActive(true)
-- zs:GetComponent("Image").sprite = self.spLoader:LoadSprite(zsName)
-- end
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.RootPanel.PlayerPanel, "live_"..position
self.RoleLiveGO.transform:SetParent(Util.GetTransform(self.RootPanel.PlayerPanel, "live_"..position))
self.RoleLiveGO:GetComponent("RectTransform").anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2])-- * 0.5
self.RoleLiveGO.transform.localScale = Vector3.one * self.enemy_liveScale
self.RoleLiveGO:SetActive(true)
--self.RoleLiveParnet=self.RoleLiveGO.transform
-- 卡牌立绘显示
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)
-- 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)
-- casting技能立绘
self.RoleLiveGO2 = poolManager:LoadLive(self.livePath, go.transform.parent, Vector3.one, Vector3.zero)
@ -132,14 +145,19 @@ function PlayerView:onCreate(go, role, position, root)
-- 怒气显示
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.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")
self.effect_rage:SetActive(self.role.Rage >= 4)
self.rageSlider.fillAmount = self.role.Rage / 4
self.rageText.gameObject:SetActive(false)
self.rageText.text = ""
self.lvHpObj=Util.GetGameObject(go, "lvObj")
if position<=3 then
self.lvHpObj:GetComponent("RectTransform").anchoredPosition=Vector3.New(0,450,0)
else
self.lvHpObj:GetComponent("RectTransform").anchoredPosition=Vector3.New(0,0,0)
end
-- 伤害文字显示
self.LastBuffFloatingTime = Time.realtimeSinceStartup
self.BuffFloatingCount = 0
@ -300,12 +318,14 @@ end
--角色被放逐
function PlayerView:OnRoleExile(role)
local color = Color.New(1, 1, 1, 0.4)
Util.SetColor(self.liveRender, color)
--Util.SetColor(self.liveRender, color)
Util.SetColor(self.RoleLiveGO, color)
end
--角色放逐结束
function PlayerView:OnRoleExileEnd(role)
local color = Color.New(1, 1, 1, 1)
Util.SetColor(self.liveRender, color)
--Util.SetColor(self.liveRender, color)
Util.SetColor(self.RoleLiveGO, color)
end
-- 设置高亮
function PlayerView:SetHighLight(isLight, eScale, dur, func)
@ -368,22 +388,23 @@ function PlayerView:OnSkillPlay()
if not self.GameObject then
return
end
self.lvHpObj:SetActive(false)
local battleSorting = BattleManager.GetBattleSorting()
self:ChangeCardSorting(battleSorting + 20)
-- 立绘缩小
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)
-- 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)
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "attack", false)
end
@ -402,11 +423,13 @@ function PlayerView:OnSkillEnd()
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)
end
function PlayerView:OnSkillCastingStart()
-- 提前进入下一阶段
self.RoleLiveGO2:SetActive(true)
self.lvHpObj:SetActive(false)
self:PlaySpineAnim(self.RoleLiveGOGraphic2, 0, "touch", false)
end
@ -456,10 +479,16 @@ local DotTypeTip = {
}
--
function PlayerView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
if skill and skill.continueTime > 0 and skill.attackCount > 1 then
local space = skill.continueTime / skill.attackCount
local count = skill.attackCount
local d = math.floor(dmg/count)
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 space = continue / count
local d = math.floor(dmg / count)
-- 如果平均伤害小于0 则
if d == 0 then
d = dmg
@ -468,7 +497,11 @@ function PlayerView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType
if BattleManager.IsBattleTestPanel() then
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s, 伤害段数:%s每段伤害%s", self.camp, self.role.position, dmg, count, d))
end
-- 伤害文字延时,有些受击特效不是立刻播放文字
self:DelayFunc(delay/1000, function()
-- 伤害文字
if count ~= 1 then
-- 多段伤害
-- 后续伤害延迟打出
self:LoopFunc(space, count - 1, function()
self:OnceDamaged(atkRole, d, bCrit, finalDmg, damageType, dotType, skill)
@ -476,14 +509,24 @@ function PlayerView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType
-- 立刻打出第一次伤害
local fd = dmg - d *(count - 1)
self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect(continue)
else
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect()
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
--
@ -515,43 +558,49 @@ function PlayerView:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotTy
end
end
end
-- 播放受击动画
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
end
-- 播放卡牌受击效果
function PlayerView:DOHitEffect(time, func)
-- 时间修正
if not time or time < 0.3 then
time = 0.3
end
-- 受击放大1.2倍
self:DoScale(1.2, 0.1)
-- 卡面变红
DoTween.To(DG.Tweening.Core.DOGetter_float( function () return 1 end),
DG.Tweening.Core.DOSetter_float(function (progress)
local color = Color.New(1, progress, progress, 1)
Util.SetColor(self.GameObject, color)
Util.SetColor(self.RoleLiveGOGraphic, color)
end), 0, 0.3):SetEase(Ease.Linear):OnComplete(function()
end), 0, 0.1):SetEase(Ease.Linear):OnComplete(function()
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)
Util.SetColor(self.GameObject, color)
Util.SetColor(self.RoleLiveGOGraphic, color)
end), 1, 0.1):SetEase(Ease.Linear)
end), 1, 0.1):SetEase(Ease.Linear):SetDelay(time)
end)
self.GameObject.transform.parent:DOShakeAnchorPos(0.3, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
-- 震动
self.GameObject.transform.parent:DOShakeAnchorPos(time, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
if self.GameObject then
self.GameObject.transform.parent.anchoredPosition = Vector2.New(self.role.position == 1 and -145 or 0, -221)
end
end)
-- 受击放大1.2倍
self:DoScale(1.2, 0.3, function()
-- 恢复大小
self:DoScale(1, 0.1)
end)
-- 播放受击动画
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
-- 播放受击特效
if skill then
local combatId = BattleManager.GetCombatIdBySkin(skill.id, atkRole.roleData.skinId)
local combat = BattleManager.GetSkillCombat(combatId)
self.SkillCaster:CheckSkillHitEffect("hit", combat, skill)
-- 回调
if func then
func()
end
end)
end
function PlayerView:OnHealed(castRole)
local sortingOrder = self.GameObject:GetComponent("Canvas").sortingOrder + 21
local go = BattleManager.LoadAsset(healEffect, sortingOrder)
@ -587,6 +636,8 @@ function PlayerView:OnDead()
self.hpSlider.fillAmount = 0
self.hpPassSlider.fillAmount = 0
self.yujiaSlider.fillAmount = 0
self.RoleLiveGO.gameObject:SetActive(false)
self.lvHpObj:SetActive(false)
--死亡后不把怒气条显示清空,处理触发不灭怒气不足四点 怒气条清空 2021/09/01
--self.rageSlider.fillAmount = 0
self.rageText.text = ""
@ -647,6 +698,8 @@ function PlayerView:onRoleRelive()
BattleManager.AddDelayRecycleRes(reliveEffect1, go, 3)
BattleManager.AddDelayRecycleRes(reliveEffect2, go, 3)
self.Floater:ImageBuffFloating("z_zhandou_fuhuo_zh")
self.RoleLiveGO.gameObject:SetActive(true)
self.lvHpObj:SetActive(true)
end
@ -666,6 +719,7 @@ function PlayerView:onDispose()
self.RoleLiveGOGraphic.freeze = false
self.RoleLiveGOGraphic2.freeze = false
poolManager:UnLoadLive(self.livePath, self.RoleLiveGO2)
poolManager:UnLoadLive(self.livePath, self.RoleLiveGO)
-- 回收本节点
BattlePool.RecycleItem(self.GameObject, BATTLE_POOL_TYPE.MY_ROLE)
self.GameObject = nil