LearnWithTouch/Assets/scripts/Options.cs

121 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Options : MonoBehaviour
{
public Button Back;
public Toggle Intro;
public Toggle Tutorial;
public InputField NumberTrials;
public Toggle Music;
//public AudioSource audio;
//private string selectedGame;
//private List<string> games = new List<string>() { "Count", "Set", "Add" };
//private int selectedLevel;
//private List<string> levels = new List<string>() { "1", "2", "3" };
public void Start()
{
Debug.Log("options started...");
NumberTrials.characterLimit = 2;
NumberTrials.contentType = InputField.ContentType.IntegerNumber;
Debug.Log("Tutorial is "+Tutorial.isOn.ToString());
Debug.Log("Intro is "+Intro.isOn.ToString());
Debug.Log("Music is "+Music.isOn.ToString());
Tutorial.isOn = Gamestate.Instance.getTutorial();
Intro.isOn = Gamestate.Instance.getIntro();
Music.isOn = Gamestate.Instance.getMusic();
NumberTrials.text = Gamestate.Instance.getNumberTrials().ToString();
}
public void OnEditEnded() {
int num = Int32.Parse(NumberTrials.text);
if (num > 48) {
num = 48;
NumberTrials.text = "48";
}
Gamestate.Instance.setNumberTrials(num);
}
public void ToggleTutorial_Changed()
{
//Debug.Log("index: "+ index.ToString());
//Tutorial.isOn = index;//Gamestate.Instance.getTutorial();
//Debug.Log("Tutorial: " + Tutorial.isOn.ToString());
if (Tutorial.isOn)
{
Gamestate.Instance.setTutorial(true);
Debug.Log("Tutorial is : "+Gamestate.Instance.getTutorial().ToString());
//value = false;
}
else
{
Gamestate.Instance.setTutorial(false);
Debug.Log("Tutorial is : "+Gamestate.Instance.getTutorial().ToString());
//value = true;
}
//startGame();
}
public void ToggleIntro_Changed()
{
//Debug.Log("Intro: " + Intro.isOn.ToString());
if (Tutorial.isOn)
{
Gamestate.Instance.setIntro(true);
Debug.Log("Intro is "+Gamestate.Instance.getIntro().ToString());
//value = false;
}
else
{
Gamestate.Instance.setIntro(false);
Debug.Log("Intro is "+Gamestate.Instance.getIntro().ToString());
//value = true;
}
//startGame();
}
public void ToggleMusic_Changed()
{
if (Music.isOn)
{
Gamestate.Instance.setMusic(true);
Debug.Log("Music is true!");
//value = false;
}
else
{
Gamestate.Instance.setMusic(false);
Debug.Log("Music is false!");
//value = true;
}
//startGame();
}
public void back()
{
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.menuState();
}
}