summaryrefslogtreecommitdiff
path: root/Assets/Scripts/GameProgressManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/GameProgressManager.cs')
-rw-r--r--Assets/Scripts/GameProgressManager.cs42
1 files changed, 41 insertions, 1 deletions
diff --git a/Assets/Scripts/GameProgressManager.cs b/Assets/Scripts/GameProgressManager.cs
index 463e2b3..f4d1645 100644
--- a/Assets/Scripts/GameProgressManager.cs
+++ b/Assets/Scripts/GameProgressManager.cs
@@ -1,12 +1,20 @@
+using System.Collections;
using Tag;
using UnityEngine;
[RequireComponent(typeof(SceneStatus))]
public class GameProgressManager : MonoBehaviour
{
+ public int time = 60;
+
public MaskAnswers player1;
public MaskAnswers player2;
-
+
+ public int questionMaxScore;
+ public int player1Score;
+ public int player2Score;
+
+ public QuestionPlayer questionPlayer;
public SceneStatus sceneStatus;
private void Awake()
@@ -31,5 +39,37 @@ public class GameProgressManager : MonoBehaviour
Debug.Log("开始游戏!");
player1.bindPlayer.GetComponent<PlayerMovement>().enabled = true;
player2.bindPlayer.GetComponent<PlayerMovement>().enabled = true;
+
+ // 记录最大分数
+ questionMaxScore = questionPlayer.currentQuestion.Need.Count;
+
+ StartCoroutine(GameTime());
+ }
+
+ private void OnGameEnd()
+ {
+ Debug.Log("游戏结束!");
+ }
+
+ IEnumerator GameTime()
+ {
+ while (true)
+ {
+ yield return new WaitForSeconds(0.2f);
+ UpdateScore();
+ yield return new WaitForSeconds(0.4f);
+ UpdateScore();
+ yield return new WaitForSeconds(0.2f);
+ time--;
+ if (time <= 0)
+ break;
+ }
+ OnGameEnd();
+ }
+
+ private void UpdateScore()
+ {
+ player1Score = QuestionVerifier.Verify(questionPlayer.currentQuestion, player1.CollectToAnswer());
+ player2Score = QuestionVerifier.Verify(questionPlayer.currentQuestion, player2.CollectToAnswer());
}
}