Typing Game is not develop compilete.

This commit is contained in:
Project Unity 2025-11-18 07:48:42 +08:00
parent 97e6f2eb1e
commit cb2a80b552
10 changed files with 7462 additions and 2537 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,106 @@
using System.Collections;
using TMPro;
using UnityEngine;
public class ClientGameTypingSceneController : MonoBehaviour
{
public static ClientGameTypingSceneController Instance;
public GameObject introPanel;
public GameObject playPanel;
public GameObject stopPanel;
public GameObject finishPanel;
public TMP_Text playCountdownText;
public TMP_InputField playInputField;
private int playCountdownSecVal = 60;
private void Awake()
{
Instance = this;
}
public void init()
{
processStep(1);
}
IEnumerator StatusCountdown()
{
yield return new WaitForSeconds(1f);
playCountdownSecVal--;
playCountdownText.text = "®É¶¡­Ë¼Æ " + playCountdownSecVal.ToString() + "¬í";
if (playCountdownSecVal > 0)
{
StartCoroutine(StatusCountdown());
}
else
{
processStep(3);
}
}
IEnumerator NextStep(int step, int waitSec)
{
yield return new WaitForSeconds(waitSec);
processStep(step);
}
public void processStep(int step)
{
if (introPanel)
{
introPanel.SetActive(step == 1);
if (step == 1)
{
playCountdownSecVal = 10;
StartCoroutine(NextStep(2, 3));
}
}
if (playPanel)
{
playPanel.SetActive(step == 2);
if (step == 2)
{
StartCoroutine(StatusCountdown());
}
}
if (stopPanel)
{
stopPanel.SetActive(step == 3);
if (step == 3)
{
if (ClientMessageHandler.Instance)
{
ClientMessageHandler.Instance.SendMessageToServer("gameTypingResult", playInputField.text);
}
StartCoroutine(NextStep(4, 3));
}
}
if (finishPanel)
{
finishPanel.SetActive(step == 4);
}
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7553dda633295904ab8b192ea6bbee5d

View File

@ -182,6 +182,16 @@ public class NetworkMessageHandler : MonoBehaviour
} }
} }
break; break;
case "gameTypingResult":
{
ServerGameTypingPanel.result = msg.payload;
if (ServerGameTypingPanel.Instance)
{
ServerGameTypingPanel.Instance.OnReceivedResult();
}
}
break;
} }

View File

@ -0,0 +1,174 @@
using System;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class ServerGameTypingPanel : MonoBehaviour
{
public static ServerGameTypingPanel Instance;
public static string result;
public GameObject introPanel;
public GameObject playPanel;
public GameObject checkPanel;
public VideoPlayer introVideoPlayer;
public RawImage introRawImage;
public VideoPlayer playVideoPlayer;
public RawImage playRawImage;
public TMP_Text statusText;
public TMP_Text checkText;
public Button checkOkButton;
private int gameTimeCountdownSecVal = 10;
private void Awake()
{
Instance = this;
}
public void processStep(int step)
{
if (introPanel)
{
introPanel.SetActive(step == 1);
if (step == 1)
{
gameTimeCountdownSecVal = 10;
if (introVideoPlayer)
{
introVideoPlayer.Play();
}
}
}
if (playPanel)
{
playPanel.SetActive(step == 2);
if (step == 2)
{
if (playVideoPlayer)
{
playVideoPlayer.Play();
}
}
}
if (checkPanel)
{
checkPanel.SetActive(step == 3);
if (step == 3)
{
checkText.text = result;
StartCoroutine(GameTimeCountdown());
}
}
}
void SetupIntroVideoPlayer()
{
if (introVideoPlayer != null)
{
// 設置影片結束事件
introVideoPlayer.loopPointReached += OnIntroVideoFinished;
// 設置影片顯示
if (introVideoPlayer != null)
{
introVideoPlayer.targetTexture = null;
introVideoPlayer.renderMode = VideoRenderMode.RenderTexture;
RenderTexture rt = new RenderTexture(1920, 1080, 24);
introVideoPlayer.targetTexture = rt;
introRawImage.texture = rt;
}
}
}
void OnIntroVideoFinished(VideoPlayer vp)
{
Debug.Log("影片播放完成");
//StartCoroutine(LoadNextScene());
processStep(2);
}
void SetupPlayVideoPlayer()
{
if (introVideoPlayer != null)
{
// 設置影片結束事件
playVideoPlayer.loopPointReached += OnPlayVideoFinished;
// 設置影片顯示
if (playVideoPlayer != null)
{
playVideoPlayer.targetTexture = null;
playVideoPlayer.renderMode = VideoRenderMode.RenderTexture;
RenderTexture rt = new RenderTexture(1920, 1080, 24);
playVideoPlayer.targetTexture = rt;
playRawImage.texture = rt;
}
}
}
void OnPlayVideoFinished(VideoPlayer vp)
{
Debug.Log("影片播放完成");
//StartCoroutine(LoadNextScene());
OnReceivedResult();
}
public void OnReceivedResult()
{
if (!string.IsNullOrEmpty(result))
{
processStep(3);
}
}
IEnumerator GameTimeCountdown()
{
yield return new WaitForSeconds(1f);
gameTimeCountdownSecVal--;
statusText.text = "倒計時 : <color=\"red\">" + gameTimeCountdownSecVal.ToString() + "</color>s";
if (gameTimeCountdownSecVal > 0)
{
StartCoroutine(GameTimeCountdown());
}
else
{
if (ServerWorkSceneController.Instance)
{
ServerWorkSceneController.Instance.processStep(17); // go to gameWaittingPanel
}
}
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
checkOkButton.onClick.AddListener(checkOkButton_onClicked);
SetupIntroVideoPlayer();
SetupPlayVideoPlayer();
}
private void checkOkButton_onClicked()
{
ServerWorkSceneController.Instance.processStep(17); // go to gameWaittingPanel
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 584eac9123c931e45bc182bb3aaf4d37

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long