//THIS IS USED TO HELP SET SPINNERS.... public void SaveToVar(SettingsNames names, int val) { if (GameMan.GetSettings() == null) { GameMan.MenuMan.LoadSettings(); } if (GameMan.GetSettings() != null) { D_Settings Settings = GameMan.GetSettings(); switch (names) { case SettingsNames.GFX_FULLSCREEN: Settings.Graphics.FullScreen = (FullScreenMode)val; break; case SettingsNames.GFX_RES: Resolution res = Screen.resolutions[val]; Settings.Graphics.Res.width = res.width; Settings.Graphics.Res.height = res.height; Settings.Graphics.Res.refresh = res.refreshRate; break; default: Debug.LogWarning(names.ToString() + " is not supported by floats"); break; } } else { Debug.LogWarning("THERE ARE NO SETTINGS ATTACHED TO THIS GAME MANAGER"); } }
private void Awake() { ///THIS IS EXTREMELY IMPORTANT TO HAVE! ///What it does is tells the game to not remove itself from any scenes ///Though if it finds another game manager it is fully able to destroy that game manager. DontDestroyOnLoad(this.gameObject); if (FindObjectsOfType <GameManager>().Length != 1) { Destroy(this.gameObject); } ScreenTransition = GetComponentInChildren <Animator>(); Settings = GetComponent <D_Settings>(); //Set up the other Managers MenuMan = GetComponent <MenuManager>(); if (MenuMan != null) { MenuMan.Setup(this); } else { Debug.LogError("Menu Management is not present on GameManager"); } StageMan = GetComponent <StageManager>(); if (StageMan != null) { StageMan.Setup(this); } else { Debug.LogError("Stage Management is not present on GameManager"); } StatMan = GetComponent <StatsManager>(); if (StatMan != null) { StatMan.Setup(this); } else { Debug.LogError("Stat Management is not present on the GameManager"); } SaveFileObj = GetComponent <D_SaveFile>(); //SaveFile = SaveSystem.LoadFile(SaveFile.FileNumber); Application.targetFrameRate = 60; if (MyGameState == GameState.GAMEPLAY) { LightenScreen(); StatMan.SwitchUI(true); } }
public static void SaveSettings(D_Settings settings) { D_Settings SavedSettings = settings; string path = Application.persistentDataPath + "/settings.json"; Debug.Log(path); string Output = JsonUtility.ToJson(SavedSettings, true); System.IO.File.WriteAllText(path, Output); /* * D_Settings SavedSettings = new D_Settings(settings); * string path = Application.persistentDataPath + "/settings.json"; * JsonUtility.ToJson(SavedSettings,true); */ //FileStream stream = new FileStream(path, FileMode.OpenOrCreate); // }
public void PlayEffect(AudioClip audio) { if (Settings == null) { Settings = FindObjectOfType <D_Settings>(); } if (Settings != null) { if (Emitter == null) { Emitter = GetComponent <AudioSource>(); } if (Emitter != null) { switch (Type) { case AudioType.OneShot: //Will Be used mostly to tie Audio with Animations //Up to 12 Oneshots per Emitter Emitter.loop = false; Emitter.PlayOneShot(audio, Settings.Audio.Master * Settings.Audio.Effects); break; case AudioType.Looping: //If it's Looping then it'll set it to loop and play it Emitter.loop = true; if (!Emitter.isPlaying) { Emitter.Play(); } break; default: break; } } else { Debug.LogWarning(name + " | This Audio Manager Has no Emitter"); } } else { Debug.LogWarning("There is no Audio Settings attached to this area"); } }
public static void LoadSettings(D_Settings settings) { //string path = Application.persistentDataPath + "/settings.json"; //FileStream stream = new FileStream(path, FileMode.Open); //stream.Close(); string path = Application.persistentDataPath + "/settings.json"; if (System.IO.File.Exists(path)) { string input = System.IO.File.ReadAllText(path); //string path = //string Input = JsonUtility.ToJson(); JsonUtility.FromJsonOverwrite(input, settings); } else { Debug.Log("Settings Not Found: Making New Settings"); SaveSettings(settings); } }
//This is used to help set Sliders public void SaveToVar(SettingsNames names, float val) { if (GameMan.GetSettings() == null) { GameMan.MenuMan.LoadSettings(); } if (GameMan.GetSettings() != null) { D_Settings Settings = GameMan.GetSettings(); switch (names) { case SettingsNames.AUD_MASTER: Settings.Audio.Master = val; break; case SettingsNames.AUD_MUSIC: Settings.Audio.Music = val; break; case SettingsNames.AUD_EFFECTS: Settings.Audio.Effects = val; break; case SettingsNames.AUD_VOICE: Settings.Audio.Voice = val; break; case SettingsNames.GP_TIMESCALE: Settings.Gameplay.TimeScale = val; break; default: Debug.LogWarning(names.ToString() + " is not supported by floats"); break; } } else { Debug.LogWarning("THERE ARE NO SETTINGS ATTACHED TO THIS GAME MANAGER"); } }
//So we want to set the slider public void SetSliderValue(Slider ValTarget) { float AccelRate = 1f; float Normalized = ValTarget.normalizedValue; if (GameMan.GetSettings() != null) { D_Settings Settings = GameMan.GetSettings(); switch (Settings.MenuSliderAccel) { case 1: //100 Steps ValTarget.maxValue = 100 / 1; //Apply the slip Value cause we let go and are normaling based off 100 //So if we're moving left if (Mathf.Sign(PreviousValue - Normalized) < 0) { //And our previous direction was Left if (Mathf.Sign(SlipValue) > 0) { SlipValue = -SlipValue; } //Do Nothing //If our previous Direction was right else { } } //So if we're moving right else if (Mathf.Sign(PreviousValue - Normalized) > 0) { //And our previous direction was Left if (Mathf.Sign(SlipValue) > 0) { } //If our Direction was right... else { SlipValue = -SlipValue; } //Do nothing... } Normalized += SlipValue / 100; SlipValue = 0; break; case 5: //50 Steps -> Advancing by 2 ValTarget.maxValue = 100 / 2; SlipValue = 1 * Mathf.Sign(PreviousValue - Normalized); break; case 8: //25 Steps -> Advancing by 5 ValTarget.maxValue = 100 / 4; SlipValue = 4 * Mathf.Sign(PreviousValue - Normalized); break; case 12: //10 Steps -> Advancing by 10 ValTarget.maxValue = 100 / 10; SlipValue = 9 * Mathf.Sign(PreviousValue - Normalized); break; default: break; } //-1 | -1 means Holding Left 1 | 1 means right or tapping //Debug.Log(Mathf.Sign(PreviousValue - Normalized) + "|"+ SlipValue + "|" + Mathf.Sign(SlipValue)); //SO if our current value is greater than the previous value.... Then we need to add... //If we're lower than the previous value then we need to add //Debug.Log(Normalized - PreviousValue); Settings.MenuSliderAccel += AccelRate; SliderVal = Normalized; ValTarget.normalizedValue = Normalized; //ValTarget.value += (1*Mathf.Sign(GlobalVar.MenuSliderAccel) + GlobalVar.MenuSliderAccel)/ValTarget.maxValue; //Debug.Log((1 * Mathf.Sign(GlobalVar.MenuSliderAccel) + GlobalVar.MenuSliderAccel) / ValTarget.maxValue); //Debug.Log(GlobalVar.MenuSliderAccel); PreviousValue = Normalized; } else { Debug.LogWarning("THERE ARE NO SETTINGS ATTACHED TO THIS GAME MANAGER"); } }
public D_Settings(D_Settings settings) { this.settings = settings; }