From 3b2a6bb9047cfce9f501593b3669a9c1af6c5df4 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 05 十一月 2025 17:40:23 +0800
Subject: [PATCH] 130 战斗修改回合样式
---
Main/Component/UI/Common/TimerBehaviour.cs | 123 ++++++++++++++++++++---------------------
1 files changed, 60 insertions(+), 63 deletions(-)
diff --git a/Main/Component/UI/Common/TimerBehaviour.cs b/Main/Component/UI/Common/TimerBehaviour.cs
index 6064160..f5b5e52 100644
--- a/Main/Component/UI/Common/TimerBehaviour.cs
+++ b/Main/Component/UI/Common/TimerBehaviour.cs
@@ -1,5 +1,5 @@
锘�//--------------------------------------------------------
-// [Author]: 绗簩涓栫晫
+// [Author]: 鐜╀釜娓告垙
// [ Date ]: Saturday, November 11, 2017
//--------------------------------------------------------
using UnityEngine;
@@ -7,90 +7,87 @@
using UnityEngine.UI;
using System;
-namespace vnxbqy.UI
+
+public class TimerBehaviour : MonoBehaviour
{
+ [SerializeField] protected Text m_TimeShow;
+ public Text timeShow { get { return m_TimeShow; } }
- public class TimerBehaviour : MonoBehaviour
+ [SerializeField] Pattern m_Pattern = Pattern.English;
+
+ protected DateTime endTime;
+ Action onTime;
+
+ float secondTimer = 0f;
+
+ public void Begin(int seconds, Action _callBack = null)
{
- [SerializeField] protected Text m_TimeShow;
- public Text timeShow { get { return m_TimeShow; } }
-
- [SerializeField] Pattern m_Pattern = Pattern.English;
-
- protected DateTime endTime;
- Action onTime;
-
- float secondTimer = 0f;
-
- public void Begin(int seconds, Action _callBack = null)
+ endTime = TimeUtility.ServerNow + new TimeSpan(seconds * TimeSpan.TicksPerSecond);
+ onTime = _callBack;
+ if (endTime > TimeUtility.ServerNow)
{
- endTime = TimeUtility.ServerNow + new TimeSpan(seconds * TimeSpan.TicksPerSecond);
- onTime = _callBack;
- if (endTime > TimeUtility.ServerNow)
- {
- this.SetActive(true);
- UpdateTimeShow();
- }
- else
- {
- this.SetActive(false);
- }
+ this.SetActive(true);
+ UpdateTimeShow();
}
-
- public void Stop()
+ else
{
- endTime = DateTime.MinValue;
- onTime = null;
this.SetActive(false);
}
+ }
- private void LateUpdate()
+ public void Stop()
+ {
+ endTime = DateTime.MinValue;
+ onTime = null;
+ this.SetActive(false);
+ }
+
+ private void LateUpdate()
+ {
+ if (TimeUtility.ServerNow > endTime)
{
- if (TimeUtility.ServerNow > endTime)
+ if (onTime != null)
{
- if (onTime != null)
- {
- onTime();
- onTime = null;
- }
-
- this.SetActive(false);
+ onTime();
+ onTime = null;
}
- else
+
+ this.SetActive(false);
+ }
+ else
+ {
+ secondTimer += Time.deltaTime;
+ if (secondTimer > 1f)
{
- secondTimer += Time.deltaTime;
- if (secondTimer > 1f)
- {
- secondTimer = 0f;
- UpdateTimeShow();
- }
+ secondTimer = 0f;
+ UpdateTimeShow();
}
}
+ }
- protected virtual void UpdateTimeShow()
+ protected virtual void UpdateTimeShow()
+ {
+ var lastSecond = (float)(endTime - TimeUtility.ServerNow).TotalSeconds;
+
+ switch (m_Pattern)
{
- var lastSecond = (float)(endTime - TimeUtility.ServerNow).TotalSeconds;
-
- switch (m_Pattern)
- {
- case Pattern.English:
- m_TimeShow.text = TimeUtility.SecondsToHMS(Mathf.RoundToInt(lastSecond));
- break;
- case Pattern.Chinese:
- m_TimeShow.text = TimeUtility.SecondsToDHMSCHS(Mathf.RoundToInt(lastSecond));
- break;
- }
+ case Pattern.English:
+ m_TimeShow.text = TimeUtility.SecondsToHMS(Mathf.RoundToInt(lastSecond));
+ break;
+ case Pattern.Chinese:
+ m_TimeShow.text = TimeUtility.SecondsToDHMSCHS(Mathf.RoundToInt(lastSecond));
+ break;
}
+ }
- public enum Pattern
- {
- English = 0,
- Chinese = 1,
- }
-
+ public enum Pattern
+ {
+ English = 0,
+ Chinese = 1,
}
}
+
--
Gitblit v1.8.0