public static void SavePlayer(PlayerDataCustomize data) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(FilePath, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }
public void LoadCustomization() { PlayerDataCustomize loadedDataCustomize = SaveLoadCustomize.LoadPlayer(); color_selected = loadedDataCustomize.selected_color; trail_selected = loadedDataCustomize.selected_trail; Player.GetComponent <Image>().color = Colors[color_selected].gameObject.GetComponent <Image>().color; Change_Trail(trail_selected); }
void Start() { PlayerDataCustomize loadedData = SaveLoadCustomize.LoadPlayer(); Trail_Change(loadedData.trail_selection); Hat_Change(loadedData.hat_selection); Body_Change(loadedData.body_selection); Legs_Change(loadedData.legs_selection); Hands_Change(loadedData.hands_selection); }
public void RESET_ALL() { PlayerDataCustomize SaveDataCustomize = new PlayerDataCustomize(); SaveDataCustomize.color_no = 0; SaveDataCustomize.selected_color = 0; SaveDataCustomize.trail_no = 0; SaveDataCustomize.selected_trail = 0; SaveLoadCustomize.SavePlayer(SaveDataCustomize); Player_Idle.GetComponent <Image>().color = Colors[0].gameObject.GetComponent <Image>().color; Change_Trail(0); PlayerDataLocked SaveDataLocked = new PlayerDataLocked(); SaveDataLocked.color_0_locked = false; SaveDataLocked.color_1_locked = true; SaveDataLocked.color_2_locked = true; SaveDataLocked.color_3_locked = true; SaveDataLocked.color_4_locked = true; SaveDataLocked.trail_0_locked = false; SaveDataLocked.trail_1_locked = true; SaveDataLocked.trail_2_locked = true; SaveLoadLocked.SavePlayer(SaveDataLocked); PlayerDataCoins SaveDataCoins = new PlayerDataCoins(); SaveDataCoins.coins = 0; SaveLoadCoins.SavePlayer(SaveDataCoins); PlayerDataHighscore SaveDataHighscore = new PlayerDataHighscore(); SaveDataHighscore.highscore = 0; SaveLoadHighscore.SavePlayer(SaveDataHighscore); PlayerDataVolumes SaveDataVolumes = new PlayerDataVolumes(); SaveDataVolumes.m_volume = 3; SaveDataVolumes.s_volume = 3; SaveLoadVolumes.SavePlayer(SaveDataVolumes); PlayerDataQuality SaveDataQuality = new PlayerDataQuality(); SaveDataQuality.quality_selection = 1; SaveLoadQuality.SavePlayer(SaveDataQuality); Load_Customization(); Load_PlayerCoins(); Load_Locked(); Load_Volumes(); Load_QualitySettings(); Load_Highscore(); }
public void Save_Customization() { PlayerDataCustomize SaveDataCustomize = new PlayerDataCustomize(); SaveDataCustomize.color_no = color_selection; SaveDataCustomize.selected_color = selected_color; SaveDataCustomize.trail_no = trail_selection; SaveDataCustomize.selected_trail = selected_trail; SaveLoadCustomize.SavePlayer(SaveDataCustomize); }
public void Load_Customization() { PlayerDataCustomize loadedDataCustomize = SaveLoadCustomize.LoadPlayer(); color_selection = loadedDataCustomize.color_no; selected_color = loadedDataCustomize.selected_color; trail_selection = loadedDataCustomize.trail_no; selected_trail = loadedDataCustomize.selected_trail; Selected_Color.gameObject.GetComponent <Image>().color = Colors[color_selection].gameObject.GetComponent <Image>().color; Player_Idle.GetComponent <Image>().color = Colors[selected_color].gameObject.GetComponent <Image>().color; Selected_Trail.gameObject.GetComponent <Image>().sprite = TrailsImg[trail_selection]; Change_Trail(selected_trail); }
public static PlayerDataCustomize LoadPlayer() { if (File.Exists(FilePath)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(FilePath, FileMode.Open); PlayerDataCustomize loadedData = formatter.Deserialize(stream) as PlayerDataCustomize; stream.Close(); return(loadedData); } else { SavePlayer(PlayerDataCustomize.DefaultValues); return(PlayerDataCustomize.DefaultValues); } }