From 8d08a63c70fc473472c74693113450acd0ed86ad Mon Sep 17 00:00:00 2001 From: "chiyu.lin" Date: Tue, 18 Nov 2025 16:14:50 +0800 Subject: [PATCH] add GlobalData fix Q10 --- .gitignore | 1 + .../ClientGameTalkingSceneController.cs | 4 +-- .../Scripts/Server/ServerGameTalkingPanel.cs | 14 ++++----- Assets/Scripts/Utils.meta | 8 +++++ Assets/Scripts/Utils/GlobalData.cs | 30 +++++++++++++++++++ Assets/Scripts/Utils/GlobalData.cs.meta | 2 ++ 6 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 Assets/Scripts/Utils.meta create mode 100644 Assets/Scripts/Utils/GlobalData.cs create mode 100644 Assets/Scripts/Utils/GlobalData.cs.meta diff --git a/.gitignore b/.gitignore index a14cfb8..b5c8977 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,4 @@ InitTestScene*.unity* # Auto-generated scenes by play mode tests /[Aa]ssets/[Ii]nit[Tt]est[Ss]cene*.unity* +.idea/ diff --git a/Assets/Scripts/Client/ClientGameTalkingSceneController.cs b/Assets/Scripts/Client/ClientGameTalkingSceneController.cs index d5e51c8..9fda9e1 100644 --- a/Assets/Scripts/Client/ClientGameTalkingSceneController.cs +++ b/Assets/Scripts/Client/ClientGameTalkingSceneController.cs @@ -23,7 +23,7 @@ public class ClientGameTalkingSceneController : MonoBehaviour public Button finishGoToNextButton; public Button finishBackToMenuButton; - private int playCountdownSecVal = 120; + private int playCountdownSecVal = GlobalData.GAME_TALK_COUNTDOWN_TIME; private void Awake() { @@ -116,7 +116,7 @@ public class ClientGameTalkingSceneController : MonoBehaviour if (step == 1) { playCount++; - playCountdownSecVal = 120; + playCountdownSecVal = GlobalData.GAME_TALK_COUNTDOWN_TIME; } } diff --git a/Assets/Scripts/Server/ServerGameTalkingPanel.cs b/Assets/Scripts/Server/ServerGameTalkingPanel.cs index 2ebf1d0..83fed1e 100644 --- a/Assets/Scripts/Server/ServerGameTalkingPanel.cs +++ b/Assets/Scripts/Server/ServerGameTalkingPanel.cs @@ -26,7 +26,7 @@ public class ServerGameTalkingPanel : MonoBehaviour public Button sample4Button; public Button sample5Button; - private int gameTimeCountdownSecVal = 100; + private int gameTimeCountdownSecVal = GlobalData.GAME_TALK_COUNTDOWN_TIME; private string[] sampleTexts = { "汝行街上,見一老嫗跌倒,身旁五千金鈔隨風散。若只得一瞬之舉,汝先救人,抑或先拾錢?", @@ -160,7 +160,7 @@ public class ServerGameTalkingPanel : MonoBehaviour { yield return new WaitForSeconds(1f); - if (gameTimeCountdownSecVal == 100) + if (gameTimeCountdownSecVal == GlobalData.GAME_TALK_COUNTDOWN_TIME) { if (NetworkMessageHandler.Instance) { @@ -191,7 +191,7 @@ public class ServerGameTalkingPanel : MonoBehaviour introPanel.SetActive(step == 1); if (step == 1) { - gameTimeCountdownSecVal = 100; + gameTimeCountdownSecVal = GlobalData.GAME_TALK_COUNTDOWN_TIME; } } if (playPanel) @@ -200,12 +200,8 @@ public class ServerGameTalkingPanel : MonoBehaviour if (step == 2) { playChatText.text = ""; - - if (statusText.text == "--") - { - statusText.text = "倒計時 : " + gameTimeCountdownSecVal.ToString() + "s"; - StartCoroutine(GameTimeCountdown()); - } + statusText.text = "倒計時 : " + gameTimeCountdownSecVal.ToString() + "s"; + StartCoroutine(GameTimeCountdown()); } } } diff --git a/Assets/Scripts/Utils.meta b/Assets/Scripts/Utils.meta new file mode 100644 index 0000000..324e5a3 --- /dev/null +++ b/Assets/Scripts/Utils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0cf37a1ad53db44aac1eee1fffaf555 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Utils/GlobalData.cs b/Assets/Scripts/Utils/GlobalData.cs new file mode 100644 index 0000000..dc8be0a --- /dev/null +++ b/Assets/Scripts/Utils/GlobalData.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +public class GlobalData +{ + #region <目前沒用到> + /* + /// + /// 伺服器 IP + /// + public static string SERVER_IP + { + set { _SERVER_IP = value; } + get + { + return _SERVER_IP; + } + } + private static string _SERVER_IP = "127.0.0.1"; + /// + /// 伺服器 Port + /// + public const ushort _SERVER_PORT = 17777; + */ + #endregion + + /// + /// 小遊戲 - 對話的倒數時間 + /// + public const int GAME_TALK_COUNTDOWN_TIME = 120; +} diff --git a/Assets/Scripts/Utils/GlobalData.cs.meta b/Assets/Scripts/Utils/GlobalData.cs.meta new file mode 100644 index 0000000..3f3419b --- /dev/null +++ b/Assets/Scripts/Utils/GlobalData.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 14598982ddaf08a45802c011ef834d76 \ No newline at end of file