Files
TalesOfNovariel/Assets/Scripts/Menu/UIHandlerMenu.cs

94 lines
3.5 KiB
C#

using Assets.Scripts.Classes;
using Assets.Scripts.Player;
using Assets.Scripts.Races;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;
namespace Assets.Scripts.Menu
{
public class UIHandlerMenu : MonoBehaviour
{
public GameObject mainMenu;
public GameObject options;
public GameObject characterCreation;
// Start is called before the first frame update
void Start()
{
FileHandler.loadOptions(false);
options.transform.localScale = new Vector3(0, 0, 0);
characterCreation.transform.localScale = new Vector3(0, 0, 0);
SteamWorksHandler.getFirstPlayAchievement();
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public void startGame(SceneHandler sceneHandler)
{
int cityAmount = GameObject.Find("dropSize").GetComponent<Dropdown>().value * 5 + 5;
PlayerPrefs.SetInt("cityAmount", cityAmount);
PlayerPrefs.SetInt("class", GameObject.Find("dropClass").GetComponent<Dropdown>().value);
PlayerPrefs.SetInt("race", GameObject.Find("dropRace").GetComponent<Dropdown>().value);
PlayerPrefs.SetString("playername", GameObject.Find("inName").GetComponent<InputField>().text);
PlayerPrefs.SetInt("difficulty", GameObject.Find("dropDifficulty").GetComponent<Dropdown>().value);
PlayerPrefs.SetInt("isLoad", 0);
sceneHandler.openGameScene();
}
public void openCharacterCreation()
{
options.transform.localScale = new Vector3(0, 0, 0);
characterCreation.transform.localScale = new Vector3(1, 1, 1);
EventSystem.current.SetSelectedGameObject(GameObject.Find("inName"));
}
public void closeCharacterCreation()
{
options.transform.localScale = new Vector3(0, 0, 0);
characterCreation.transform.localScale = new Vector3(0, 0, 0);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public void openOptions()
{
options.transform.localScale = new Vector3(1, 1, 1);
characterCreation.transform.localScale = new Vector3(0, 0, 0);
FileHandler.loadOptionDisplay();
}
public void closeOptions()
{
options.transform.localScale = new Vector3(0, 0, 0);
characterCreation.transform.localScale = new Vector3(0, 0, 0);
EventSystem.current.SetSelectedGameObject(GameObject.Find("btnStart"));
}
public void loadGame(SceneHandler sceneHandler)
{
PlayerPrefs.SetInt("isLoad", 1);
sceneHandler.openGameScene();
}
public bool isCharacterCreation()
{
return characterCreation.activeSelf;
}
public void switchLanguage()
{
GameObject language = GameObject.Find("dropLanguage");
switch (language.GetComponent<Dropdown>().value)
{
case 0:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("de");
break;
case 1:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("en");
break;
}
}
}
}