From dc7922d80c1d133b6261b8af1d521567d2c0a35d Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 30 十月 2025 16:51:39 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts

---
 Main/System/Battle/UIComp/BattleHeroInfoBar.cs |   62 ++++++++++++++++++++++++------
 1 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
index cfa66d5..1ba959c 100644
--- a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
+++ b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
@@ -12,6 +12,11 @@
         public string message;
         public bool useArtText;
         public bool followCharacter;
+        public float scaleRatio;
+
+        public Color textColor = Color.white;
+
+        public bool showBackground = false;
     }
 
     protected BattleObject battleObject;
@@ -87,14 +92,20 @@
         }
         tipsList.Clear();
     }
-    public void ShowTips(string message, bool useArtText = false, bool followCharacter = false)
+    public void ShowTips(string message, bool useArtText = false, bool followCharacter = true, float scaleRatio = 1f)
     {
         messages.Add(new TipsInfo
         {
             message = message,
             useArtText = useArtText,
-            followCharacter = followCharacter
+            followCharacter = followCharacter,
+            scaleRatio = scaleRatio
         });
+    }
+
+    public void ShowTips(TipsInfo tipsInfo)
+    {
+        messages.Add(tipsInfo);
     }
 
     public void SetActive(bool active)
@@ -102,28 +113,45 @@
         gameObject.SetActive(active);
     }
 
-    public void PopUpTipsDirectly(string message, bool useArtText = false, bool followCharacter = false)
+    public void PopUpTipsDirectly(TipsInfo tipsInfo)
     {
         GameObject prefab = textTips.gameObject;
 
-        GameObject go = GameObject.Instantiate(prefab, followCharacter ? transform : battleObject.battleField.battleRootNode.transform);
+        GameObject go = GameObject.Instantiate(prefab, tipsInfo.followCharacter ? transform : battleObject.battleField.battleRootNode.transform);
 
         BattleTips tips = go.GetComponent<BattleTips>();
 
-        if (!followCharacter)
+        if (!tipsInfo.followCharacter)
         {
-            go.transform.position = prefab.transform.position;
-            tips.beginPos = go.transform.localPosition;
-            tips.endPos = tips.endPos + new Vector2(go.transform.localPosition.x, go.transform.localPosition.y);
+            var contentRect = go.GetComponent<RectTransform>();
+            var contentParentRect = contentRect.parent as RectTransform;
+            var infoBarRect = GetComponent<RectTransform>();
+
+            Vector3 worldTargetPos = infoBarRect.transform.TransformPoint(infoBarRect.rect.center);
+
+            Vector2 anchoredPos;
+            RectTransformUtility.ScreenPointToLocalPointInRectangle(
+                contentParentRect,
+                RectTransformUtility.WorldToScreenPoint(null, worldTargetPos),
+                null,
+                out anchoredPos);
+
+            tips.UpdatePositions(anchoredPos, anchoredPos + new Vector2(0, 150));
+            
+            // 鍚屾椂鏇存柊缂╂斁
+            Vector3 newBeginScale = tips.normalBeginScale * tipsInfo.scaleRatio;
+            Vector3 newEndScale = tips.normalEndScale * tipsInfo.scaleRatio;
+            tips.UpdateScales(newBeginScale, newEndScale);
         }
 
-        tips.SetSpeedRatio(battleObject.battleField.speedRatio);
+        tips.SetRatio(battleObject.battleField.speedRatio, 1f);
 
-        tips.SetText(message, useArtText);
+        tips.SetText(tipsInfo.message, tipsInfo.useArtText, false, tipsInfo.textColor);
+
+        tips.ShowBackground(tipsInfo.showBackground);
 
         tips.OnFinish = () =>
         {
-            //  TODO YYL 鑰冭檻姹犲寲
             tipsList.Remove(tips);
             GameObject.DestroyImmediate(tips.gameObject);
         };
@@ -189,12 +217,20 @@
         if (messages.Count > 0 && timer >= PopUpInterval)
         {
             // 鎾斁椋樺瓧
-            TipsInfo message = messages[0];
+            TipsInfo tipsInfo = messages[0];
             messages.RemoveAt(0);
 
-            PopUpTipsDirectly(message.message, message.useArtText, message.followCharacter);
+            PopUpTipsDirectly(tipsInfo);
 
             timer = 0f;
         }
     }
+
+    public void SetSpeedRatio(float ratio)
+    {
+        for (int i = 0; i < tipsList.Count; i++)
+        {
+            tipsList[i].SetRatio(ratio, 1f);
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0