public static void SavePlayer(PlayerDataSettings data) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(FilePath, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }
public void SaveSettings() { // Save Settings PlayerDataSettings saveDataSettings = new PlayerDataSettings(); saveDataSettings.music_vol_selection = music_selection; saveDataSettings.effect_vol_selection = effect_selection; SaveLoadSettings.SavePlayer(saveDataSettings); }
void Start() { PlayerDataSettings loadedData = SaveLoadSettings.LoadPlayer(); music_selection = loadedData.music_vol_selection; effect_selection = loadedData.effect_vol_selection; Music_Box_Update(music_selection); Effect_Box_Update(effect_selection); }
public static PlayerDataSettings LoadPlayer() { if (File.Exists(FilePath)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(FilePath, FileMode.Open); PlayerDataSettings loadedData = formatter.Deserialize(stream) as PlayerDataSettings; stream.Close(); return(loadedData); } else { SavePlayer(PlayerDataSettings.DefaultValues); return(PlayerDataSettings.DefaultValues); } }
public void Set_GameSounds() { PlayerDataSettings loadedData = SaveLoadSettings.LoadPlayer(); int music_vol = loadedData.music_vol_selection; int effect_vol = loadedData.effect_vol_selection; if (music_vol == 0) { Game_Sound.volume = 0f; } else if (music_vol == 1) { Game_Sound.volume = 0.05f; } else if (music_vol == 2) { Game_Sound.volume = 0.10f; } else if (music_vol == 3) { Game_Sound.volume = 0.20f; } else if (music_vol == 4) { Game_Sound.volume = 0.30f; } else if (music_vol == 5) { Game_Sound.volume = 0.40f; } if (effect_vol == 0) { Mushroom_Sound.volume = 0f; Grass_Sound.volume = 0f; Break_Sound.volume = 0f; Ouch_Sound.volume = 0f; Blop_Sound.volume = 0f; Hit_Sound.volume = 0f; } else if (effect_vol == 1) { Mushroom_Sound.volume = 0.1f; Grass_Sound.volume = 0.02f; Break_Sound.volume = 0.05f; Ouch_Sound.volume = 0.2f; Blop_Sound.volume = 0.2f; Hit_Sound.volume = 0.2f; } else if (effect_vol == 2) { Mushroom_Sound.volume = 0.2f; Grass_Sound.volume = 0.04f; Break_Sound.volume = 0.1f; Ouch_Sound.volume = 0.4f; Blop_Sound.volume = 0.4f; Hit_Sound.volume = 0.4f; } else if (effect_vol == 3) { Mushroom_Sound.volume = 0.3f; Grass_Sound.volume = 0.06f; Break_Sound.volume = 0.15f; Ouch_Sound.volume = 0.6f; Blop_Sound.volume = 0.6f; Hit_Sound.volume = 0.6f; } else if (effect_vol == 4) { Mushroom_Sound.volume = 0.4f; Grass_Sound.volume = 0.08f; Break_Sound.volume = 0.22f; Ouch_Sound.volume = 0.8f; Blop_Sound.volume = 0.8f; Hit_Sound.volume = 0.8f; } else if (effect_vol == 5) { Mushroom_Sound.volume = 0.5f; Grass_Sound.volume = 0.1f; Break_Sound.volume = 0.3f; Ouch_Sound.volume = 1f; Blop_Sound.volume = 1f; Hit_Sound.volume = 1f; } }