using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using System; public class Gamestate : MonoBehaviour { // Declare properties private static Gamestate instance; private string activeGame = "Count"; // Active level private string activeLevel = "1"; // Active level //private string name; // Characters name private int score; // Characters Experience Points private float scoreProz; //private Touch[] touchList; private bool calibrate = true; private int numberTrials = 4;//48 private int maxCount = 5; private int maxCorrect = 3; private bool intro = true; private bool tutorial = true; private bool music = true; private bool animPlaying = false; public struct PlayerData { public string ID; public string level; public int score; public string game; public string date; public string time; public int attempt_count; public int attempt_set; public int attempt_add; /*public int x, y; public Coords(int p1, int p2) { x = p1; y = p2; }*/ } private PlayerData pdata; // --------------------------------------------------------------------------------------------------- // gamestate() // --------------------------------------------------------------------------------------------------- // Creates an instance of gamestate as a gameobject if an instance does not exist // --------------------------------------------------------------------------------------------------- public static Gamestate Instance { get { if (instance == null) { instance = new GameObject("Gamestate").AddComponent(); } return instance; } } // Sets the instance to null when the application quits public void OnApplicationQuit() { instance = null; } /*public void createPlayerData() { pdata.ID = "Test"; pdata.game = "Count"; pdata.level = "1"; pdata.score = 0; pdata.date ="01011999"; pdata.time="00:00:00"; pdata.attempt_count=0; pdata.attempt_set=0; pdata.attempt_add=0; }*/ public void setPlayerData(PlayerData pd) { pdata.ID = pd.ID; pdata.attempt_add = pd.attempt_add; pdata.attempt_count = pd.attempt_count; pdata.attempt_set=pd.attempt_set; pdata.date=pd.date; pdata.game=pd.game; pdata.level=pd.level; pdata.score=pd.score; pdata.time=pd.time; } // --------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------- // startState() // --------------------------------------------------------------------------------------------------- // Creates a new game state // --------------------------------------------------------------------------------------------------- public void startState() { print("startState"); // Set default properties: name = "My Character"; score = 0; if (!calibrate) { // Load level 1 calibrate = true; SceneManager.LoadScene("Calibrate"); } else { startIntro(); //SceneManager.LoadScene(activeGame+"1"); } } public void startIntro() { print("startIntro"); // Set default properties: name = "My Character"; score = 0; if (intro) { // Load level 1 //intro = false; SceneManager.LoadScene("Intro"); } else { //if (tutorial) startTutorial(); //else startGame(); } } public void startGame() { Debug.Log("start activeGame: " + activeGame.ToString()); SceneManager.LoadScene(activeGame + "1"); } /*public void startTutorial() { Debug.Log("start activeGame: " + activeGame.ToString()); SceneManager.LoadScene("Tutorial"); }*/ public void startScoreScene() { SceneManager.LoadScene("ScoreScene"); } public void startOptions() { SceneManager.LoadScene("OptionScene"); } public void startEndScene() { SceneManager.LoadScene("EndScene"); } public void menuState() { print("menuState"); // Set default properties: SceneManager.LoadScene("GameStart"); //data.savePlayerInfo(); } public string getLevel() { return activeLevel; } public void setLevel(string newLevel) { // Set activeLevel to newLevel activeLevel = newLevel; pdata.level=newLevel; //data.setLevel(newLevel); } public void setIntro(bool value) { intro = value; } public void setTutorial(bool value) { tutorial = value; } public void setMusic(bool value) { music = value; } public bool getTutorial() { return tutorial; } public bool getIntro() { return intro; } public bool getMusic() { return music; } public string getGame() { return activeGame; } public void setGame(string newGame) { // Set activeLevel to newLevel activeGame = newGame; pdata.game = newGame; //data.setGame(newGame); } public void setID(string id) { pdata.ID=id; } public string getID() { return pdata.ID; } public void setGamePoints(int points) { score = points; scoreProz = numberTrials / points; //data.setPoints(points); } public int getGamePoints() { return score; } public float getGamePointsProz() { return scoreProz; } public int getNumberTrials() { return numberTrials; } public void setNumberTrials(int numTrials) { // Set activeLevel to newLevel numberTrials = numTrials; //data.setLevel(newLevel); } public int getMaxCount() { return maxCount; } public void setAnimPlaying(bool state) { this.animPlaying = state; } public bool getAnimPlaying() { return this.animPlaying; } public int getMaxCorrect() { return maxCorrect; } public PlayerData GetPlayerData() { return pdata; } public void setDate(string newDate) { pdata.date=pdata.date + " " + newDate; } public string getDate() { return pdata.level; } public void setPoints(int points) { pdata.score=points; } public int getPoints() { return pdata.score; } public void setAttemptCount(int count) { pdata.attempt_count=count; } public int getAttemptCount() { return pdata.attempt_count; } public void setAttemptSet(int count) { pdata.attempt_set=count; } public int getAttemptSet() { return pdata.attempt_set; } public void setAttemptAdd(int count) { pdata.attempt_add=count; } public int getAttemptAdd() { return pdata.attempt_add; } //public void addTrial(Trial t) { // data.tdata.addTrial(t); //} }