From eba6c39cc97723bfe2056e2eac2c2d1cf59ab12a Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 22 十月 2025 18:13:54 +0800
Subject: [PATCH] 125 战斗 技能飘字

---
 Main/System/Battle/BattleField/BattleField.cs |    5 +
 Main/System/Battle/UIComp/SkillTips.cs.meta   |   11 +++
 Main/System/Battle/StoryBossBattleWin.cs      |   47 +++++++++++++++
 Main/System/Battle/UIComp/SkillTips.cs        |   99 +++++++++++++++++++++++++++++++++
 4 files changed, 161 insertions(+), 1 deletions(-)

diff --git a/Main/System/Battle/BattleField/BattleField.cs b/Main/System/Battle/BattleField/BattleField.cs
index 01f1573..63d86b9 100644
--- a/Main/System/Battle/BattleField/BattleField.cs
+++ b/Main/System/Battle/BattleField/BattleField.cs
@@ -7,6 +7,8 @@
 
 public class BattleField
 {
+    public Action<int, int> OnRoundChange;
+
     public BattleObjMgr battleObjMgr;
 
     public BattleEffectMgr battleEffectMgr;
@@ -108,6 +110,7 @@
         blueTeamList = _blueTeamList;
         FuncLineID = _FuncLineID;
         extendData = _extendData;
+        round = 0;
         this.turnMax = turnMax;
 
         redTeamIndex = 0;
@@ -140,6 +143,7 @@
         }
         SetRootNodePosition();
         rejectNewPackage = false;
+        OnRoundChange?.Invoke(round, turnMax);
     }
 
     public void SetSpeedRatio(float ratio)
@@ -271,6 +275,7 @@
         uint FuncLineID, JsonData extendData)
     {
         round = TurnNum;
+        OnRoundChange?.Invoke(round, turnMax);
     }
 
     public virtual void OnTurnFightObjAction(int turnNum, int ObjID)
diff --git a/Main/System/Battle/StoryBossBattleWin.cs b/Main/System/Battle/StoryBossBattleWin.cs
index 1761f06..76f6173 100644
--- a/Main/System/Battle/StoryBossBattleWin.cs
+++ b/Main/System/Battle/StoryBossBattleWin.cs
@@ -41,6 +41,10 @@
 
     public TotalDamageDisplayer totalDamageDisplayer;
 
+    public SkillTips skillTipsRed;
+
+    public SkillTips skillTipsBlue;
+
     private BattleObject bossBattleObject = null;
 
     [SerializeField] public List<BattleBuffCell> buffCells;
@@ -90,6 +94,7 @@
         // SetBattleField(BattleManager.Instance.storyBattleField);
         BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField;
         EventBroadcast.Instance.AddListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken);
+        EventBroadcast.Instance.AddListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnCastSkill);
 
         UIManager.Instance.CloseWindow<MainWin>();
     }
@@ -101,6 +106,7 @@
         base.OnPreClose();
         BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField;
         EventBroadcast.Instance.RemoveListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken);
+        EventBroadcast.Instance.RemoveListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnCastSkill);
 
         UIManager.Instance.CloseWindow<BattleHUDWin>();
 
@@ -112,6 +118,29 @@
             bossBattleObject.buffMgr.onBuffChanged -= OnBuffChanged;
             bossBattleObject = null;
         }
+
+        if (battleField != null)
+        {
+            battleField.OnRoundChange -= OnRoundChange;
+            battleField = null;
+        }
+    }
+
+    private void OnCastSkill(string guid, SkillConfig skillConfig, TeamHero teamHero)
+    {
+        if (battleField == null)
+            return;
+
+        if (battleField.guid != guid)
+            return;
+
+        BattleObject battleObject = battleField.battleObjMgr.GetBattleObject(teamHero.ObjID);
+
+        bool isRed = battleObject.Camp == BattleCamp.Red;
+
+        SkillTips tips = isRed ? skillTipsRed : skillTipsBlue;
+
+        tips.PlayMotion(battleField, isRed, teamHero, skillConfig);
     }
 
     private void OnCreateBattleField(string arg1, BattleField field)
@@ -165,11 +194,14 @@
             Debug.LogError("鎵句笉鍒癰oss");
         }
 
-        txtBattleRound.text = string.Format("{0}/{1}", battleField.round, battleField.turnMax);
+        OnRoundChange(battleField.round, battleField.turnMax);
 
         OnBuffChanged();
 
         totalDamageDisplayer.SetActive(false);
+
+        skillTipsBlue.SetActive(false);
+        skillTipsRed.SetActive(false);
     }
 
     private void OnBuffChanged()
@@ -231,6 +263,12 @@
 
     public void SetBattleField(StoryBossBattleField _battleField)
     {
+        if (battleField != null)
+        {
+            battleField.OnRoundChange -= OnRoundChange;
+            battleField = null;
+        }
+
         battleField = _battleField;
         if (battleRootNode != null)
         {
@@ -256,6 +294,8 @@
         buttonsAdjuster.SetSortingOrder(BattleConst.ActiveHeroActionSortingOrder);
 
         Refresh();
+
+        battleField.OnRoundChange += OnRoundChange;
 
         textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString();
     }
@@ -312,4 +352,9 @@
             }
         }
     }
+
+    private void OnRoundChange(int round, int maxRound)
+    {
+        txtBattleRound.text = string.Format("{0}/{1}", round, maxRound);
+    }
 }
diff --git a/Main/System/Battle/UIComp/SkillTips.cs b/Main/System/Battle/UIComp/SkillTips.cs
new file mode 100644
index 0000000..08aca89
--- /dev/null
+++ b/Main/System/Battle/UIComp/SkillTips.cs
@@ -0,0 +1,99 @@
+using System.Collections;
+using System.Collections.Generic;
+using DG.Tweening;
+using UnityEngine.UI;
+using UnityEngine;
+
+public class SkillTips : MonoBehaviour
+{
+    public const float tweenDuration = 1f;
+
+    public const float delayDuration = 0.4f;
+
+    public const float beginingX = 400f;
+
+    [SerializeField]public Image imgIcon;
+
+    [SerializeField]public Image imgSkillName;
+
+    [SerializeField] public Image imageBg;
+
+    private Tween tween1;
+    private Tween tween2;
+    private Tween tween3;
+
+    public void PlayMotion(BattleField battleField, bool isRed, TeamHero teamHero, SkillConfig skillConfig)
+    {
+        if (teamHero == null || skillConfig == null)
+        {
+            return;
+        }
+
+        if (skillConfig.FuncType != 2)
+            return;
+
+        KillAllTweens();
+
+        imgIcon.sprite = UILoader.LoadSprite("HeroHead", teamHero.skinConfig.SquareIcon);
+        imgSkillName.sprite = UILoader.LoadSprite("SkillNameIcon", skillConfig.SkillTipsName);
+
+        // 淇濊瘉寮�濮嬫椂鎵�鏈夊浘鐗囦负鍙锛坅lpha=1锛�
+        if (imageBg != null) { var c = imageBg.color; c.a = 1f; imageBg.color = c; }
+        if (imgIcon != null) { var c = imgIcon.color; c.a = 1f; imgIcon.color = c; }
+        if (imgSkillName != null) { var c = imgSkillName.color; c.a = 1f; imgSkillName.color = c; }
+
+        gameObject.SetActive(true);
+        float posY = transform.localPosition.y;
+        transform.localPosition = isRed ? new Vector3(-beginingX, posY, 0f) : new Vector3(beginingX, posY, 0f);
+        tween1 = transform.DOLocalMoveX(0, tweenDuration / battleField.speedRatio, false).SetEase(Ease.Linear).OnComplete(() =>
+        {
+            tween1 = null;
+            tween3 = DOVirtual.DelayedCall(delayDuration / battleField.speedRatio, () =>
+            {
+                tween3 = null;
+
+                // tween2 鏀逛负鍋氬噺娣★紙瀵� imageBg銆乮mgIcon銆乮mgSkillName 鍚屾娣″嚭锛�
+                float fadeDuration = tweenDuration / battleField.speedRatio;
+                Sequence seq = DOTween.Sequence();
+                if (imageBg != null)
+                    seq.Join(imageBg.DOFade(0f, fadeDuration).SetEase(Ease.InQuad));
+                if (imgIcon != null)
+                    seq.Join(imgIcon.DOFade(0f, fadeDuration).SetEase(Ease.InQuad));
+                if (imgSkillName != null)
+                    seq.Join(imgSkillName.DOFade(0f, fadeDuration).SetEase(Ease.InQuad));
+
+                seq.OnComplete(() =>
+                {
+                    tween2 = null;
+                    transform.localPosition = isRed ? new Vector3(-beginingX, posY, 0f) : new Vector3(beginingX, posY, 0f);
+                    gameObject.SetActive(false);
+                });
+
+                tween2 = seq;
+                battleField.battleTweenMgr.OnPlayTween(tween2);
+            });
+            battleField.battleTweenMgr.OnPlayTween(tween3);
+        });
+        battleField.battleTweenMgr.OnPlayTween(tween1);
+    }
+    
+    public void KillAllTweens()
+    {
+        if (tween1 != null)
+        {
+            tween1.Kill();
+            tween1 = null;
+        }
+        if (tween2 != null)
+        {
+            tween2.Kill();
+            tween2 = null;
+        }
+        if (tween3 != null)
+        {
+            tween3.Kill();
+            tween3 = null;
+        }
+    }
+
+}
diff --git a/Main/System/Battle/UIComp/SkillTips.cs.meta b/Main/System/Battle/UIComp/SkillTips.cs.meta
new file mode 100644
index 0000000..d351dcc
--- /dev/null
+++ b/Main/System/Battle/UIComp/SkillTips.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f240ee927c9d417439aa146953d50208
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

--
Gitblit v1.8.0