From d21ab089026bfe22df1e5c36ef2d66554957c188 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 26 九月 2025 18:09:51 +0800
Subject: [PATCH] 197 子 【内政】淘金系统 / 【内政】淘金系统-客户端

---
 Main/System/Hero/UIHeroController.cs |   71 +++++++++++++++++++++++++++--------
 1 files changed, 54 insertions(+), 17 deletions(-)

diff --git a/Main/System/Hero/UIHeroController.cs b/Main/System/Hero/UIHeroController.cs
index 852fcef..b86ec25 100644
--- a/Main/System/Hero/UIHeroController.cs
+++ b/Main/System/Hero/UIHeroController.cs
@@ -17,7 +17,7 @@
 	public void Create(int _skinID, float scale = 0.8f, Action _onComplete = null, string motionName = "idle", bool isLh = false)
 	{
 		if (skinID == _skinID)
-		{ 
+		{
 			//閬垮厤閲嶅鍒涘缓
 			return;
 		}
@@ -49,7 +49,7 @@
 				lhImg.SetTexture2DPNG(skinConfig.Tachie);
 				lhImg.SetNativeSize();
 				if (skeletonGraphic != null)
-				{ 
+				{
 					skeletonGraphic.enabled = false;
 				}
 				lhImg.enabled = true;
@@ -58,26 +58,26 @@
 			else
 			{
 				if (skeletonGraphic != null)
-				{ 
+				{
 					skeletonGraphic.enabled = true;
 				}
 				lhImg.enabled = false;
 			}
 		}
 		else
-		{ 
+		{
 			this.transform.localScale = Vector3.one * scale;
 		}
 
 		onComplete = _onComplete;
 		pool = GameObjectPoolManager.Instance.RequestPool(UILoader.LoadPrefab("UIHero"));
-		
+
 		if (!transform.gameObject.activeSelf)
 		{
 			transform.SetActive(true);
 		}
 		if (instanceGO == null)
-		{ 
+		{
 			instanceGO = pool.Request();
 			instanceGO.transform.SetParent(transform);
 			//transform 鐨凱ivot Y鏄�0锛岃instanceGO 灞呬腑
@@ -109,7 +109,7 @@
 			return;
 		}
 		skeletonGraphic.Initialize(true);
-		
+
 		spineAnimationState = skeletonGraphic.AnimationState;
 		spineAnimationState.Data.DefaultMix = 0f;
 		if (motionName == "")
@@ -124,24 +124,32 @@
 
 	protected void OnDestroy()
 	{
-        if (spineAnimationState != null)
-        {
-            spineAnimationState.Complete -= OnAnimationComplete;
-        }
+		if (spineAnimationState != null)
+		{
+			spineAnimationState.Complete -= OnAnimationComplete;
+		}
 		if (pool != null)
 			pool.Release(instanceGO);
 		skeletonGraphic = null;
 		pool = null;
 	}
 
+	/// <summary>
+	/// 鎾斁 Spine 鍔ㄧ敾
+	/// </summary>
+	/// <param name="motionName">鍔ㄤ綔鍚�</param>
+	/// <param name="loop">寰幆</param>
+	/// <param name="replay">濡傛灉鐩稿悓鍔ㄤ綔鏄惁鍐嶆閲嶆挱锛屾瘮濡傝窇姝ラ噸鎾氨浼氳烦甯т笉椤烘粦</param>
+	public virtual void PlayAnimation(string motionName, bool loop = false, bool replay=true)
+	{
+		if (spineAnimationState == null) return;
 
-    public virtual void PlayAnimation(string motionName, bool loop = false)
-    {
-        if (spineAnimationState == null) return;
+		if (GetCurrentAnimationName() == motionName && !replay)
+			return;
 
 		// 鐩存帴浣跨敤 ToString() 鑰屼笉鏄皟鐢� GetAnimationName
-        spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
-    }
+		spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
+	}
 
 	// 鎾斁绗竴涓姩鐢伙紙浣滀负榛樿鍔ㄧ敾锛�
 	string GetFistSpineAnim()
@@ -156,7 +164,22 @@
 			Debug.LogError("Spine 鏁版嵁涓病鏈夋壘鍒颁换浣曞姩鐢伙紒姝﹀皢鐨偆锛�" + skinID);
 		}
 		return "";
-    }
+	}
+
+	/// <summary>
+	/// 鑾峰彇褰撳墠姝e湪鎾斁鐨� Spine 鍔ㄧ敾鍚嶇О
+	/// </summary>
+	/// <returns>褰撳墠鍔ㄧ敾鍚嶇О锛屽鏋滄病鏈夊姩鐢诲垯杩斿洖绌哄瓧绗︿覆</returns>
+	public string GetCurrentAnimationName()
+	{
+		if (spineAnimationState == null || spineAnimationState.GetCurrent(0) == null)
+		{
+			return string.Empty;
+		}
+		return spineAnimationState.GetCurrent(0).Animation.Name;
+	}
+
+
 
 	/// <summary>
 	/// 鍔ㄧ敾瀹屾垚浜嬩欢澶勭悊
@@ -166,4 +189,18 @@
 		onComplete?.Invoke();
 	}
 
+	//瓒婂ぇ瓒婂揩
+	public void SetSpeed(float speed)
+	{
+		spineAnimationState.TimeScale = speed;
+	}
+
+	public void SetEnabled(bool isEnable)
+	{ 
+		if (skeletonGraphic == null)
+		{
+			return;
+		}
+		skeletonGraphic.enabled = isEnable;
+	}
 }
\ No newline at end of file

--
Gitblit v1.8.0