LearnWithTouch/Assets/scripts/GameSelect.cs

137 lines
3.9 KiB
C#
Raw Normal View History

2019-07-01 14:33:21 +02:00
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameSelect : MonoBehaviour
{
public Button StartCount;
public Button StartSet;
public Button StartAdd;
public Button Options;
public Toggle Level1;
public Toggle Level2;
public Toggle Level3;
public new 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" };
void Start()
{
//Camera.main.aspect = 1536f / 2048f;
//PopulateCountingDropdown();
//PopulateSetDropdown();
//PopulateAddDropdown();
//Dropdown_Counting.itemText.text = Gamestate.Instance.getLevel();
//Dropdown_Set.itemText.text = Gamestate.Instance.getLevel();
//Dropdown_Add.itemText.text = Gamestate.Instance.getLevel();
if (Gamestate.Instance.getMusic()) audio.Play();
else
{
audio.Stop();
}
if (Gamestate.Instance.getLevel() == "1")
{
Level1.isOn = true;
Level2.isOn = false;
Level3.isOn = false;
}
else if (Gamestate.Instance.getLevel() == "2")
{
Level2.isOn = true;
Level1.isOn = false;
Level3.isOn = false;
}
else if (Gamestate.Instance.getLevel() == "3")
{
Level3.isOn = true;
Level2.isOn = false;
Level1.isOn = false;
}
Debug.Log("GameSelect: intro " + Gamestate.Instance.getIntro());
Debug.Log("GameSelect: Tutorial " + Gamestate.Instance.getTutorial());
}
public void ToggleLevel1_Changed(int index)
{
if (Level1.isOn) Gamestate.Instance.setLevel("1");
else Gamestate.Instance.setLevel(" ");//startGame()
}
public void ToggleLevel2_Changed(int index)
{
if (Level2.isOn) Gamestate.Instance.setLevel("2");
else Gamestate.Instance.setLevel(" ");//startGame()
}
public void ToggleLevel3_Changed(int index)
{
if (Level3.isOn) Gamestate.Instance.setLevel("3");
else Gamestate.Instance.setLevel(" ");//startGame()
}
public void startCountGame()
{
print("Starting game");
if (Gamestate.Instance.getLevel()!= " ") {
Gamestate.Instance.setGame("Count");
Gamestate.Instance.setLevel(Gamestate.Instance.getLevel());
Gamestate.Instance.setAttemptCount(Gamestate.Instance.getAttemptCount()+1);
audio.Stop();
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
public void startSetGame()
{
if (Gamestate.Instance.getLevel()!= " ") {
audio.Stop();
//print("Starting game");
Gamestate.Instance.setGame("Set");
Gamestate.Instance.setLevel(Gamestate.Instance.getLevel());
Gamestate.Instance.setAttemptSet(Gamestate.Instance.getAttemptSet()+1);
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
public void startAddGame()
{
if (Gamestate.Instance.getLevel()!= " ") {
audio.Stop();
//print("Starting game");
Gamestate.Instance.setGame("Add");
Gamestate.Instance.setLevel(Gamestate.Instance.getLevel());
Gamestate.Instance.setAttemptAdd(Gamestate.Instance.getAttemptAdd()+1);
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startState();
}
}
public void startOptions()
{
//if (Gamestate.Instance.getLevel()!= " ") {
//audio.Stop();
//print("Starting game");
DontDestroyOnLoad(Gamestate.Instance);
Gamestate.Instance.startOptions();
//}
}
}