From 09bc892c7283df8757a07b646d5af21ddaa263d1 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期四, 06 十一月 2025 18:22:34 +0800
Subject: [PATCH] 164 天子的考验-客户端
---
Main/System/Battle/BattleObject/BattleObject.cs | 230 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 176 insertions(+), 54 deletions(-)
diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index f7b532a..266ee05 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -32,13 +32,13 @@
public BattleObjectBuffMgr buffMgr;
+ public BattleObjectLayerMgr layerMgr;
+
public int ObjID { get; set; }
public BattleCamp Camp { get; protected set; }
public TeamHero teamHero { get; protected set; }
-
- // public BuffMgr buffMgr;
public MotionBase motionBase;
@@ -48,7 +48,7 @@
private set;
}
- protected BattleDrops battleDrops;
+ protected BattleDrops m_battleDrops;
private RectTransform m_heroRectTrans;
@@ -83,10 +83,14 @@
teamHero = _teamHero;
Camp = _camp;
motionBase = new MotionBase();
- motionBase.Init(heroGo.GetComponentInChildren<SkeletonGraphic>(true));
- motionBase.onAnimationComplete += OnAnimationComplete;
+ motionBase.Init(heroGo.GetComponentInChildren<SkeletonAnimation>(true));
buffMgr = new BattleObjectBuffMgr();
buffMgr.Init(this);
+
+ buffMgr.onIsControlChanged += OnControledChange;
+
+ layerMgr = new BattleObjectLayerMgr();
+ layerMgr.Init(this);
renderers = heroGo.GetComponentsInChildren<Renderer>(true);
@@ -98,6 +102,8 @@
heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1;
heroInfoBar.transform.localScale = heroInfoBarScale;
+ heroInfoBar.SetActive(true);
+ SetFront();
}
@@ -105,6 +111,7 @@
{
motionBase.Run();
heroInfoBar.Run();
+ buffMgr.Run();
}
public virtual void Pause()
@@ -119,10 +126,12 @@
public virtual void Destroy()
{
- motionBase.onAnimationComplete -= OnAnimationComplete;
motionBase.Release();
motionBase = null;
+ buffMgr.onIsControlChanged -= OnControledChange;
+ buffMgr.Release();
+ buffMgr = null;
teamHero = null;
ObjID = 0;
@@ -133,8 +142,30 @@
}
}
+ // 鏈夊彉鍖栦簡鎵嶄細璋冪敤杩欎釜鍑芥暟
+ private void OnControledChange(int groupType, bool value)
+ {
+ // 杩欓噷鏄彈鍒扮‖鎺ф椂鍊� 闇�瑕佽〃鐜扮殑鍔ㄧ敾
+ if (groupType == BattleConst.HardControlGroup)
+ {
+ // 浠庢病琚‖鎺у埌琚‖鎺�
+ if (value)
+ {
+ motionBase.SetControledAnimation();
+ }
+ else
+ {
+ motionBase.CancelControledAnimation();
+ }
+ }
+ }
+
public void OnObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo)
{
+ // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉¢�昏緫
+ BattleObject boss = battleField.FindBoss();
+ if (boss != null && battleField.MapID == 30020 && boss.ObjID == _refreshInfo.ObjID)
+ return;
switch ((PlayerDataType)_refreshInfo.RefreshType)
{
case PlayerDataType.HP:
@@ -144,14 +175,43 @@
break;
case PlayerDataType.MaxHP:
teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
+ heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp);
break;
case PlayerDataType.XP:
long toXp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
- heroInfoBar.UpdateHP(teamHero.rage, toXp, 100);
+ heroInfoBar.UpdateXP(teamHero.rage, toXp, 100);
teamHero.rage = (int)GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
break;
default:
- BattleDebug.LogError("BattleObject.ObjInfoRefresh 鍑虹幇鎰忓绫诲瀷 " + _refreshInfo.RefreshType.ToString());
+ Debug.LogError("BattleObject.ObjInfoRefresh 鍑虹幇鎰忓绫诲瀷 " + _refreshInfo.RefreshType.ToString());
+ break;
+ }
+ }
+
+ public void ObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData)
+ {
+ // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉¢�昏緫
+ BattleObject boss = battleField.FindBoss();
+ if (boss != null && battleField.MapID == 30020 && boss.ObjID == vNetData.ObjID)
+ return;
+ switch ((PlayerDataType)vNetData.RefreshType)
+ {
+ case PlayerDataType.HP:
+ long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
+ heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
+ teamHero.curHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
+ break;
+ case PlayerDataType.MaxHP:
+ teamHero.maxHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
+ heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp);
+ break;
+ case PlayerDataType.XP:
+ long toXp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
+ heroInfoBar.UpdateXP(teamHero.rage, toXp, 100);
+ teamHero.rage = (int)GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
+ break;
+ default:
+ Debug.LogError("BattleObject.ObjPropertyRefreshView 鍑虹幇鎰忓绫诲瀷 " + vNetData.RefreshType.ToString());
break;
}
}
@@ -239,71 +299,112 @@
return true;
}
- public virtual void Hurt(List<long> damageValues, long _totalDamage, uint attackType)
+ public virtual void Hurt(BattleHurtParam battleHurtParam)
{
- PopDamage(teamHero.curHp, damageValues, attackType);
+ bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
+ bool firstHit = battleHurtParam.hitIndex == 0;
+ BattleDmgInfo dmgInfo = PopDamage(battleHurtParam);
- motionBase.PlayAnimation(MotionName.hit, false);
- // 鎵h
-
- teamHero.curHp -= _totalDamage;
+ // 杩欓噷
+ if (dmgInfo.IsType(DamageType.Dodge) && !buffMgr.isControled[BattleConst.HardControlGroup])
+ {
+ if (isLastHit)
+ {
+ DodgeFinishAction dodgeFinish = new DodgeFinishAction(battleField, this);
+ battleField.recordPlayer.InsertRecord(dodgeFinish);
+ }
+
+ if (firstHit)
+ {
+ OnDodgeBegin();
+ }
+ }
+
+
+
+ bool isFatalAttack = (null != battleHurtParam.deadPack) && isLastHit;
+
+ if (isFatalAttack)
+ {
+ if (null != battleHurtParam.battleDrops)
+ {
+ PushDropItems(battleHurtParam.battleDrops);
+ }
+ battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { battleHurtParam.deadPack });
+
+ }
+ else
+ {
+ if (dmgInfo.IsType(DamageType.Block))
+ {
+ battleField.battleEffectMgr.PlayEffect(this, 19999, heroRectTrans, Camp);
+ }
+ else
+ {
+ if ((dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsRealdamage()))
+ {
+ if (!buffMgr.isControled[BattleConst.HardControlGroup])
+ {
+ motionBase.PlayAnimation(MotionName.hit, false);
+ }
+ }
+ }
+
+ }
}
- public void SuckHp(uint suckHP)
- {
- }
-
- public void HurtByReflect(uint bounceHP)
- {
-
- }
-
+ const float pingpongTime = 0.4f;
// 闂伩寮�濮�
public virtual void OnDodgeBegin()
{
- float pingpongTime = 0.2f;
RectTransform rectTrans = heroRectTrans;
- var tween = rectTrans.DOAnchorPos(new Vector3(-50, 50, 0), pingpongTime)
+ var tween = rectTrans.DOAnchorPos(new Vector3(-30, 0, 0), pingpongTime)
.SetEase(Ease.OutCubic);
+
+ motionBase.ShowIllusionShadow(true);
+
+ tween.onComplete += () =>
+ {
+ motionBase.ShowIllusionShadow(false);
+ };
battleField.battleTweenMgr.OnPlayTween(tween);
}
// 闂伩缁撴潫
- public virtual void OnDodgeEnd()
+ public virtual void OnDodgeEnd(Action _complete = null)
{
- float pingpongTime = 0.2f;
RectTransform rectTrans = heroRectTrans;
var tween = rectTrans.DOAnchorPos(Vector3.zero, pingpongTime)
.SetEase(Ease.OutCubic);
+
+ tween.onComplete += () =>
+ {
+ _complete?.Invoke();
+ };
battleField.battleTweenMgr.OnPlayTween(tween);
}
public virtual void OnDeath(Action _onDeathAnimationComplete)
{
- BattleDebug.LogError(ObjID + " OnDeath called");
- onDeathAnimationComplete = _onDeathAnimationComplete;
- motionBase.PlayAnimation(MotionName.dead, false);
- }
-
- protected virtual void OnAnimationComplete(MotionName motionName)
- {
- if (motionName == MotionName.dead)
+ motionBase.PlayAnimation(MotionName.dead, false, () =>
{
+ teamHero.isDead = true;
OnDeadAnimationComplete();
- onDeathAnimationComplete?.Invoke();
- onDeathAnimationComplete = null;
- }
+ _onDeathAnimationComplete?.Invoke();
+ });
}
protected virtual void OnDeadAnimationComplete()
{
// 鎴栬鐪嬬湅婧惰В鐗规晥锛� YYL TODO
heroGo.SetActive(false);
+
+ buffMgr.RemoveAllBuff();
}
public void OnReborn(HB423_tagMCTurnFightObjReborn vNetData)
@@ -315,21 +416,26 @@
}
// 浼ゅ杩樿鐪� 鏄惁闂伩 鏆村嚮 and so on 闇�瑕佹湁涓�涓狣amageType 鏈嶅姟鍣ㄥ簲璇ヤ細缁�
- protected virtual void PopDamage(long curHp, List<long> damageValues, uint attackType)
+ protected virtual BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam)
{
- // 鍏跺疄搴旇閫氱煡鍑哄幓缁橴I鐣岄潰瑙h�� 璁︰I鐣岄潰鑷繁鏉ユ樉绀虹殑 YYL TODO
- // 鎾斁浼ゅ鏁板瓧
- // 杩欓噷鍙互瀹炵幇涓�涓激瀹虫暟瀛楃殑寮瑰嚭鏁堟灉
- // 姣斿浣跨敤涓�涓猆I缁勪欢鏉ユ樉绀轰激瀹虫暟瀛�
- foreach (var damage in damageValues)
+ BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam);
+ // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉¢�昏緫
+ BattleObject boss = battleField.FindBoss();
+ if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurtObj.ObjID)
{
- Debug.Log($"Damage: {damage}");
+ EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+ return battleDmgInfo;
+ }
+ else
+ {
+ // 浣跨敤浼犲叆鐨� fromHp 鍜� toHp 鏇存柊琛�鏉℃樉绀�
+ heroInfoBar.UpdateHP(battleHurtParam.fromHp, battleHurtParam.toHp, teamHero.maxHp);
+
+ // YYL TODO 鏄惁闇�瑕佹寕鍦ㄥ湪鑷韩鐨刦ollow鐐逛笂
+ EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+ return battleDmgInfo;
}
- BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, damageValues, this, (int)attackType);
-
- // YYL TODO 鏄惁闇�瑕佹寕鍦ㄥ湪鑷韩鐨刦ollow鐐逛笂
- EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
}
public RectTransform GetAliasTeamNode()
@@ -353,31 +459,47 @@
// 浼戞伅鐘舵��
// 澶氫竴涓獄zz鐨勪竴涓壒鏁�
heroGo.SetActive(true);
- motionBase.PlayAnimation(MotionName.idle, true);
+ motionBase.HaveRest();
heroRectTrans.anchoredPosition = Vector2.zero;
+
+ heroInfoBar.SetActive(false);
+ SetFront();
}
public void PushDropItems(BattleDrops _battleDrops)
{
- battleDrops = _battleDrops;
+ m_battleDrops = _battleDrops;
}
public void PerformDrop()
{
- if (null == battleDrops)
+ if (null == m_battleDrops || m_battleDrops.dropItemPackIndex.Count == 0)
return;
EventBroadcast.Instance.Broadcast<string, BattleDrops, Action>(
- EventName.BATTLE_DROP_ITEMS, battleField.guid, battleDrops, OnPerformDropFinish);
+ EventName.BATTLE_DROP_ITEMS, battleField.guid, m_battleDrops, OnPerformDropFinish);
}
protected void OnPerformDropFinish()
{
- battleDrops = null;
+ m_battleDrops = null;
}
+ public void SetBack()
+ {
+ layerMgr.SetBack();
+ }
+ public void SetFront()
+ {
+ layerMgr.SetFront();
+ }
+ public void SetSpeedRatio(float ratio)
+ {
+ motionBase.SetSpeedRatio(ratio);
+ heroInfoBar.SetSpeedRatio(ratio);
+ }
#if UNITY_EDITOR_STOP_USING
--
Gitblit v1.8.0