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().value * 5 + 5; PlayerPrefs.SetInt("cityAmount", cityAmount); PlayerPrefs.SetInt("class", GameObject.Find("dropClass").GetComponent().value); PlayerPrefs.SetInt("race", GameObject.Find("dropRace").GetComponent().value); PlayerPrefs.SetString("playername", GameObject.Find("inName").GetComponent().text); PlayerPrefs.SetInt("difficulty", GameObject.Find("dropDifficulty").GetComponent().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(); EventSystem.current.SetSelectedGameObject(GameObject.Find("btnAudio")); showOptionView("audio"); } 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 string saveVideoSettings() { GameObject resolution = GameObject.Find("dropResolution"); GameObject mode = GameObject.Find("dropMode"); string result = ""; switch (resolution.GetComponent().value) { case 0: Screen.SetResolution(800, 600, Screen.fullScreenMode); break; case 1: Screen.SetResolution(1280, 800, Screen.fullScreenMode); break; case 2: Screen.SetResolution(1920, 1080, Screen.fullScreenMode); break; } switch (mode.GetComponent().value) { case 0: if (Screen.fullScreenMode != FullScreenMode.Windowed) { Screen.fullScreenMode = FullScreenMode.Windowed; } break; case 1: if (Screen.fullScreenMode != FullScreenMode.ExclusiveFullScreen) { Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen; } break; case 2: if (Screen.fullScreenMode != FullScreenMode.FullScreenWindow) { Screen.fullScreenMode = FullScreenMode.FullScreenWindow; } break; } result = result + "Resolution:" + resolution.GetComponent().value + "\r\n"; result = result + "Mode:" + mode.GetComponent().value; return result; } public string saveLanguage() { GameObject language = GameObject.Find("dropLanguage"); string result = ""; switch (language.GetComponent().value) { case 0: result = "de"; break; case 1: result = "en"; break; } result = "Language:" + result; return result; } public string saveAudioSettings() { string result = ""; float music = GameObject.Find("slideMusic").GetComponent().value; float effects = GameObject.Find("slideEffects").GetComponent().value; result = result + "Music:" + music + "\r\n"; result = result + "Effects:" + effects; return result; } public void loadGame(SceneHandler sceneHandler) { PlayerPrefs.SetInt("isLoad", 1); sceneHandler.openGameScene(); } public bool isCharacterCreation() { return characterCreation.activeSelf; } public void showOptionView(string key) { GameObject optionContent = GameObject.Find("pnlContent"); for (int i = 0; i < optionContent.transform.childCount; i++) { if (optionContent.transform.GetChild(i).name.ToLower().Contains(key)) { optionContent.transform.GetChild(i).transform.localScale = new Vector3(1, 1, 1); } else { optionContent.transform.GetChild(i).transform.localScale = new Vector3(0, 0, 0); } } } public void switchLanguage() { GameObject language = GameObject.Find("dropLanguage"); switch (language.GetComponent().value) { case 0: LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("de"); break; case 1: LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale("en"); break; } } } }