改為CustomerReportSystem開啟時更新數值
同步遊戲3的報表
This commit is contained in:
chiyulin0314 2025-11-20 05:17:04 +08:00
parent 40e56630e6
commit 40ce37edff
6 changed files with 22 additions and 103 deletions

View File

@ -47,7 +47,7 @@ public class IncenseGameManager : MonoBehaviour
private bool gameActive = true;
private int gameOverCountdownVal; // ✅ 新增:當前倒計時數值
void Start()
void OnEnable()
{
InitializeGame();
}

View File

@ -8,113 +8,29 @@ 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 CustomerReportSystem customReportScript;
private void Awake()
{
Instance = this;
customReportScript = gameObject.GetComponentInChildren<CustomerReportSystem>(includeInactive: true);
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
SetupIntroVideoPlayer();
init();
customReportScript.OnCustomerReportConfirmed = OnCustomerReportConfirmed;
}
public void init()
private void OnCustomerReportConfirmed(int[] values)
{
processStep(1);
if (values.Length < 3) { return; }
if (ServerWorkTopRightScore.Instance == null) { return; }
GlobalData.VIRTUE_SCORE = values[0];
GlobalData.KARMA_SCORE = values[1];
GlobalData.SINCERITY_SCORE = values[2];
ServerWorkTopRightScore.Instance.UpdateScoreVals();
}
// Update is called once per frame

View File

@ -217,9 +217,6 @@ public class ServerGameTalkingPanel : MonoBehaviour
{
playChatText.text = "";
statusText.text = "倒計時 : <color=\"red\">" + gameTimeCountdownSecVal.ToString() + "</color>s";
//打開時更新數值
int[] scores = { GlobalData.VIRTUE_SCORE, GlobalData.KARMA_SCORE, GlobalData.SINCERITY_SCORE };
customReportScript.SetAllCustomerValues(scores);
StartCoroutine(GameTimeCountdown());
}
}

View File

@ -65,9 +65,6 @@ public class ServerGameTypingPanel : MonoBehaviour
if (step == 3)
{
checkText.text = result;
//打開時更新數值
int[] scores = { GlobalData.VIRTUE_SCORE, GlobalData.KARMA_SCORE, GlobalData.SINCERITY_SCORE };
customReportScript.SetAllCustomerValues(scores);
StartCoroutine(GameTimeCountdown());
}
}

View File

@ -30,6 +30,7 @@ public class ServerWorkSceneController : MonoBehaviour
void Awake()
{
Instance = this;
gameSticksPanel.GetOrAddComponent<ServerGameSticksPanel>();
}
private void OnEnable()
{

View File

@ -1,3 +1,4 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
@ -63,6 +64,13 @@ public class CustomerReportSystem : MonoBehaviour
InitializeCustomerReport();
}
private void OnEnable()
{
//打開時更新數值
int[] scores = { GlobalData.VIRTUE_SCORE, GlobalData.KARMA_SCORE, GlobalData.SINCERITY_SCORE };
SetAllCustomerValues(scores);
}
private void Start()
{
SetupEventListeners();