resolved issues and added minigames to list
This commit is contained in:
@@ -7,7 +7,7 @@ using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public enum GameState
|
||||
public enum MinigameState
|
||||
{
|
||||
Idle,
|
||||
ShowingSequance,
|
||||
@@ -27,7 +27,7 @@ public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
public TMP_Text statusText;
|
||||
public GameObject startButton;
|
||||
private int playerStep = 0;
|
||||
private GameState state = GameState.Idle;
|
||||
private MinigameState state = MinigameState.Idle;
|
||||
private List<int> sequence = new List<int>();
|
||||
|
||||
public string TaskID { get; set; }
|
||||
@@ -54,7 +54,7 @@ public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
IEnumerator PlaySequence()
|
||||
{
|
||||
|
||||
SetState(GameState.ShowingSequance);
|
||||
SetState(MinigameState.ShowingSequance);
|
||||
yield return new WaitForSeconds(delayBeforeSequence);
|
||||
|
||||
for (int i = 0; i < sequence.Count; i++)
|
||||
@@ -67,12 +67,12 @@ public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
}
|
||||
|
||||
playerStep = 0;
|
||||
SetState(GameState.PlayerTurn);
|
||||
SetState(MinigameState.PlayerTurn);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
SetState(GameState.Idle);
|
||||
SetState(MinigameState.Idle);
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
@@ -83,34 +83,34 @@ public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
StartCoroutine(PlaySequence());
|
||||
}
|
||||
|
||||
void SetState(GameState newState)
|
||||
void SetState(MinigameState newState)
|
||||
{
|
||||
state = newState;
|
||||
|
||||
switch (newState)
|
||||
{
|
||||
case GameState.Idle:
|
||||
case MinigameState.Idle:
|
||||
statusText.text = "Get Ready!";
|
||||
break;
|
||||
case GameState.ShowingSequance:
|
||||
case MinigameState.ShowingSequance:
|
||||
statusText.text = "Watch the sequence";
|
||||
break;
|
||||
case GameState.PlayerTurn:
|
||||
case MinigameState.PlayerTurn:
|
||||
statusText.text = "Your turn!";
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
case MinigameState.GameOver:
|
||||
statusText.text = "Gameover";
|
||||
break;
|
||||
case GameState.MinigameWon:
|
||||
case MinigameState.MinigameWon:
|
||||
statusText.text = "Task Completed";
|
||||
break;
|
||||
}
|
||||
|
||||
startButton.SetActive(state == GameState.Idle || state == GameState.GameOver);
|
||||
startButton.SetActive(state == MinigameState.Idle || state == MinigameState.GameOver);
|
||||
}
|
||||
public void OnButtonClicked(int buttonIndex)
|
||||
{
|
||||
if (state != GameState.PlayerTurn) return;
|
||||
if (state != MinigameState.PlayerTurn) return;
|
||||
if (buttonIndex == sequence[playerStep])
|
||||
{
|
||||
playerStep++;
|
||||
@@ -118,7 +118,7 @@ public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
{
|
||||
if (round >= winRound)
|
||||
{
|
||||
SetState(GameState.MinigameWon);
|
||||
SetState(MinigameState.MinigameWon);
|
||||
Complete();
|
||||
}
|
||||
else
|
||||
@@ -132,7 +132,7 @@ public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState(GameState.GameOver);
|
||||
SetState(MinigameState.GameOver);
|
||||
Debug.Log("GameOver");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user