Petition-to-the-Gods-V3/Assets/Scripts/Server/ServerGameSticksPanel.cs
2025-11-19 08:05:11 +08:00

126 lines
2.9 KiB
C#

using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class ServerGameSticksPanel : MonoBehaviour
{
public static ServerGameSticksPanel Instance;
public GameObject introPanel;
public GameObject playPanel;
public GameObject checkPanel;
public VideoPlayer introVideoPlayer;
public RawImage introRawImage;
public TMP_Text playStatusText;
private int gameTimeCountdownSecVal = 60;
public void processStep(int step)
{
if (introPanel)
{
introPanel.SetActive(step == 1);
if (step == 1)
{
gameTimeCountdownSecVal = 60;
if (introVideoPlayer)
{
introVideoPlayer.Play();
}
}
}
if (playPanel)
{
playPanel.SetActive(step == 2);
if (step == 2)
{
StartCoroutine(GameTimeCountdown());
}
}
if (checkPanel)
{
checkPanel.SetActive(step == 3);
if (step == 3)
{
}
}
}
IEnumerator GameTimeCountdown()
{
yield return new WaitForSeconds(1f);
gameTimeCountdownSecVal--;
playStatusText.text = "倒計時 : <color=\"red\">" + gameTimeCountdownSecVal.ToString() + "</color>s";
if (gameTimeCountdownSecVal > 0)
{
StartCoroutine(GameTimeCountdown());
}
else
{
if (ServerWorkSceneController.Instance)
{
ServerWorkSceneController.Instance.processStep(17); // go to gameWaittingPanel
}
}
}
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);
}
private void Awake()
{
Instance = this;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
SetupIntroVideoPlayer();
init();
}
public void init()
{
processStep(1);
}
// Update is called once per frame
void Update()
{
}
}