add GlobalData

fix Q10
This commit is contained in:
chiyu.lin 2025-11-18 16:14:50 +08:00
parent 7ef751b275
commit 8d08a63c70
6 changed files with 48 additions and 11 deletions

1
.gitignore vendored
View File

@ -98,3 +98,4 @@ InitTestScene*.unity*
# Auto-generated scenes by play mode tests
/[Aa]ssets/[Ii]nit[Tt]est[Ss]cene*.unity*
.idea/

View File

@ -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;
}
}

View File

@ -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 = "倒計時 : <color=\"red\">" + gameTimeCountdownSecVal.ToString() + "</color>s";
StartCoroutine(GameTimeCountdown());
}
statusText.text = "倒計時 : <color=\"red\">" + gameTimeCountdownSecVal.ToString() + "</color>s";
StartCoroutine(GameTimeCountdown());
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0cf37a1ad53db44aac1eee1fffaf555
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
using UnityEngine;
public class GlobalData
{
#region <>
/*
///<summary>
/// 伺服器 IP
///</summary>
public static string SERVER_IP
{
set { _SERVER_IP = value; }
get
{
return _SERVER_IP;
}
}
private static string _SERVER_IP = "127.0.0.1";
///<summary>
/// 伺服器 Port
///</summary>
public const ushort _SERVER_PORT = 17777;
*/
#endregion
/// <summary>
/// 小遊戲 - 對話的倒數時間
/// </summary>
public const int GAME_TALK_COUNTDOWN_TIME = 120;
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 14598982ddaf08a45802c011ef834d76