From 39001a600fcae2bcf27c225df8752d75fb92fef4 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 31 十月 2025 11:18:26 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts
---
Main/System/Battle/UIComp/BattleTips.cs | 138 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 115 insertions(+), 23 deletions(-)
diff --git a/Main/System/Battle/UIComp/BattleTips.cs b/Main/System/Battle/UIComp/BattleTips.cs
index d1b8e07..bda5b8b 100644
--- a/Main/System/Battle/UIComp/BattleTips.cs
+++ b/Main/System/Battle/UIComp/BattleTips.cs
@@ -1,45 +1,137 @@
-
using UnityEngine;
using System;
using UnityEngine.UI;
-public class BattleTips : MonoBehaviour
+public class BattleTips : MonoBehaviour, IBattleFloatingUI
{
public Vector2 beginPos = Vector2.zero;
- public Vector2 endPos = new Vector2(0, 100);
- public float showTime = 0.4f;
- public float timer = 0f;
+ public Vector2 endPos = new Vector2(0, 150);
public RectTransform rectTransform;
-
public Text tipText;
+ public Text artText;
- public Action OnFinish;
+ public Image background;
- public void SetText(string text)
+ public Vector3 normalBeginScale = new Vector3(2f, 2f, 2f);
+ public Vector3 normalEndScale = new Vector3(1f, 1f, 1f);
+
+ public Action OnFinish; // 淇濈暀 OnFinish
+
+ [SerializeField]
+ private BattleFloatingUIController controller;
+
+ void Awake()
{
- tipText.text = text;
- rectTransform.anchoredPosition = Vector2.zero;
- timer = 0f;
- gameObject.SetActive(true);
+ InitController();
}
-
- // 涓嶈浣跨敤update
- public void Run()
+ private void InitController()
{
- if (!gameObject.activeSelf)
- return;
+ if (controller != null) return;
- if (timer >= showTime)
+ controller = new BattleFloatingUIController(rectTransform, gameObject, ApplyColor);
+ controller.beginPos = beginPos;
+ controller.endPos = endPos;
+ controller.normalBeginScale = normalBeginScale;
+ controller.normalEndScale = normalEndScale;
+ }
+
+ public void SetRatio(float speed, float scale)
+ {
+ InitController(); // 纭繚 controller 宸插垵濮嬪寲
+ controller.SetRatio(speed, scale);
+ }
+
+ public void SetText(string text, bool useArtText = false, bool isCrit = false, Color textColor = default)
+ {
+ if (textColor == default)
+ {
+ textColor = Color.white;
+ }
+
+ InitController();
+ if (useArtText)
+ {
+ artText.text = text;
+ tipText.gameObject.SetActive(false);
+ artText.gameObject.SetActive(true);
+ }
+ else
+ {
+ tipText.text = text;
+ artText.gameObject.SetActive(false);
+ tipText.gameObject.SetActive(true);
+ }
+
+ controller.beginColor = new Color(textColor.r, textColor.g, textColor.b, controller.beginColor.a);
+ controller.endColor = new Color(textColor.r, textColor.g, textColor.b, controller.endColor.a);
+ ApplyColor(controller.beginColor);
+ Play(isCrit);
+ }
+
+ public void Play(bool isCrit, Action onComplete = null)
+ {
+ InitController(); // 纭繚 controller 宸插垵濮嬪寲
+
+ // 鍚堝苟 OnFinish 鍜� onComplete
+ Action combinedCallback = () =>
{
OnFinish?.Invoke();
OnFinish = null;
- gameObject.SetActive(false);
- return;
- }
+ onComplete?.Invoke();
+ };
+
+ controller.Play(isCrit, combinedCallback);
+ }
- rectTransform.anchoredPosition = Vector2.Lerp(beginPos, endPos, timer / showTime);
- timer += Time.deltaTime;
+ public void Run()
+ {
+ if (controller == null) return; // 闃叉鍦� Awake 鍓嶈皟鐢�
+ controller.Run();
+ }
+
+ public void Stop()
+ {
+ if (controller == null) return;
+ controller.Stop();
+ }
+
+ public void Resume()
+ {
+ if (controller == null) return;
+ controller.Resume();
+ }
+
+ private void ApplyColor(Color color)
+ {
+ if (tipText.gameObject.activeSelf)
+ tipText.color = color;
+ if (artText.gameObject.activeSelf)
+ artText.color = color;
+ }
+
+ public void ShowBackground(bool showBackground)
+ {
+ // Implement the logic to show or hide the background
+ background.enabled = showBackground;
+ }
+
+ public void UpdatePositions(Vector2 begin, Vector2 end)
+ {
+ InitController();
+ beginPos = begin;
+ endPos = end;
+ controller.beginPos = begin;
+ controller.endPos = end;
+ }
+
+ public void UpdateScales(Vector3 beginScale, Vector3 endScale)
+ {
+ InitController();
+ normalBeginScale = beginScale;
+ normalEndScale = endScale;
+ controller.normalBeginScale = beginScale;
+ controller.normalEndScale = endScale;
}
}
\ No newline at end of file
--
Gitblit v1.8.0