using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public enum SGameState { Uninitialized, Playing, Win, Lose } public class SimonSaysGameManager : MonoBehaviour { public int currentPuzzle = 1; public SimonSaysPuzzle[] shapePuzzles = null; public Button startPuzzleButton; public SGameState gameState = SGameState.Uninitialized; private void Start() { for (int i = 0; i < shapePuzzles.Length; i++) { SimonSaysPuzzle puzzle = shapePuzzles[i]; if (i == currentPuzzle) { puzzle.gameObject.SetActive(true); continue; } puzzle.gameObject.SetActive(false); } startPuzzleButton.onClick.AddListener(ButtonClicked); } private void ButtonClicked() { if (currentPuzzle > shapePuzzles.Length) return; shapePuzzles[currentPuzzle].StartPuzzle(); gameState = SGameState.Playing; shapePuzzles[currentPuzzle].completeScreen.SetActive(false); shapePuzzles[currentPuzzle].failedScreen.SetActive(false); } public void PuzzleCompleted() { shapePuzzles[currentPuzzle].gameObject.SetActive(false); gameState = SGameState.Win; // currentPuzzle++; // if (currentPuzzle < shapePuzzles.Length) // { // shapePuzzles[currentPuzzle].gameObject.SetActive(true); // startPuzzleButton.gameObject.SetActive(true); // print("Puzzle advanced!"); // } // else // { // print("No more puzzles!"); // } } }