public void SaveAllData() { if (_gameStatistics != null) { //Save total game stats. _gameStatistics.SaveToPlayerPrefs(); } //Set the version FileFetch.SetFloat("VERSION", FileVersion); //Save item card data. SaveItemCardData(); //Save the options data. Options.Save(); //Save some more of players data. FileFetch.SetInt("GEMBANK", _gemBank); //Save total XP earned. FileFetch.SetInt("TOTALXP", _totalXP); //Sync after we save. //SyncAllData(); Debug.Log(Application.persistentDataPath + "/PlayerPrefs.txt"); }
public void DeleteAllData() { //Delete from the file system. FileFetch.ClearAllKeys(); //Set the file version upon deleting. FileFetch.SetFloat("VERSION", FileVersion); //We have to delete the stats in memory. if (_gameStatistics) { DestroyObject(_gameStatistics.gameObject); } int index = 0; foreach (EntityFactory.CannonTypes type in _cannonSlots) { //Set to default cannons. ToyBox.GetPandora().AssignSlot(EntityFactory.CannonTypes.Zebra, index); index++; } LoadAllDataFromFileSystem(); //Go through each card and recalculate the trophies earned //Recalculate trophies. CalculateTrophiesEarned(); print("All Data Deleted :(((( "); }
void LoadSlots() { //Load cannon slot data. int index = 0; foreach (EntityFactory.CannonTypes type in _cannonSlots) { //Grab the name string slotname = "Cannon_Slot_" + index.ToString(); //if the key dont exist set to zebra!!!!! if (!FileFetch.HasKey(slotname)) { _cannonSlots[index] = EntityFactory.CannonTypes.Zebra; index++; continue; } //Set the int. _cannonSlots[index] = (EntityFactory.CannonTypes)FileFetch.FetchInt(slotname); index++; } }
public void SaveToPlayerPrefs() { //Write the header to see if this stats is in the player prefs. //FileFetch.SetString(name,name); IDictionary save = new Dictionary <string, int>(); //Write each data entry. foreach (DataEntry data in _statisticsEntries) { //data.WriteToPlayerPrefs(this.name); data.WriteToDictionary(save); } //Write the total time played. FileFetch.SetFloat(name + "_TotalTime", TimeAmount); //Write the score //FileFetch.SetInt(name + "_StatsScore", StatsScore); save.Add(name + "_StatsScore", StatsScore); //Save the multiplier as well.... just incase. //FileFetch.SetInt(name + "_Modifier", StatsValueModifier); save.Add(name + "_Modifier", StatsValueModifier); FileFetch.SetDictionary(name, save); // print("Data Write Function Complete: " + this.name); }
public void LoadCardItem() { //Debug.Log(this.name + "StartLoad"); //load all the Missions. // foreach(BaseMission m in Missions) // { // m.LoadMissionStatus(); // } // //Load other data. int unlockedBool = FileFetch.FetchInt(this.name + "_Unlocked"); if (unlockedBool == 1 || unlockedBool == 0) { _unlocked = false; } else { _unlocked = true; } // Debug.Log(this.name + "EndLoad"); }
void SaveControlButtons() { //Save the offset vectors. FileFetch.SetLocalFloat("OPTIONS_ShieldPosiiton_X", ShieldPosition.x); FileFetch.SetLocalFloat("OPTIONS_ShieldPosition_Y", ShieldPosition.y); FileFetch.SetLocalFloat("OPTIONS_ShootPosition_X", ShootPosition.x); FileFetch.SetLocalFloat("OPTIONS_ShootPosition_Y", ShootPosition.y); //Save the scale values. FileFetch.SetLocalFloat("OPTIONS_ShieldScale", ShieldScale.x); FileFetch.SetLocalFloat("OPTIONS_ShootScale", ShootScale.x); }
public void Load() { //If we dont have one of the keys we dont have both so set manually and return! if (!FileFetch.HasKey("OPTIONS_SFX")) { SoundFXLevel = 0.63f; MusicLevel = 1.0f; return; } SoundFXLevel = FileFetch.FetchFloat("OPTIONS_SFX"); MusicLevel = FileFetch.FetchFloat("OPTIONS_MUSIC"); }
//Returns false if entry is not found. public bool LoadFromPlayerPrefs() { //Check if we have somthing to load if (!FileFetch.HasKey(name)) { return(false); } //Here we create a ductionary to fill up from the iDictionary. Dictionary <string, int> load = new Dictionary <string, int>(); IDictionary dict = FileFetch.FetchDictonary(name); //Transfer the data. foreach (DictionaryEntry data in dict) { load.Add(data.Key as string, int.Parse(string.Format("{0}", data.Value))); } //Get the data from the files. foreach (DataEntry data in _statisticsEntries) { //data.ReadFromPlayerPrefs(this.name); data.LoadFromDictionary(load); } //Get the total time player. TimeAmount = FileFetch.FetchFloat(name + "_TotalTime"); //Write the score //StatsScore = FileFetch.FetchInt(name + "_StatsScore"); StatsScore = load[name + "_StatsScore"]; //Save the multiplier as well.... just incase. //StatsValueModifier = FileFetch.FetchInt(name + "_Modifier"); StatsValueModifier = load[name + "_Modifier"]; return(true); }
public void SaveCardItem(bool overrideDirty = false) { //If we arent dirty or dont have an override. then dont go through with saving. if (!IsDirty) { return; } Debug.Log(this.name + "StartSave"); //Save all the Missions. foreach (BaseMission m in Missions) { m.SaveMissionStatus(); } //Save other data. if (_itemStatistics == null) { Debug.LogWarning("No Stats for Card_" + this.Label); } else { _itemStatistics.SaveToPlayerPrefs(); } //Save if we are unlcoked or not. int unlockedBool = 1; if (Unlocked) { unlockedBool = 2; } //Save our unlock state. FileFetch.SetInt(this.name + "_Unlocked", unlockedBool); //no longer dirty. IsDirty = false; Debug.Log(this.name + "EndSave"); }
public void OnApplicationFocus() { //Lets try to sync when we jump into focus. FileFetch.Sync(); }
public void SyncAllData() { FileFetch.Sync(); }
public void LoadAllDataFromFileSystem() { if (FileFetch.FetchFloat("VERSION") < FileVersion) { FileFetch.ClearAllKeys(); } //Destroy the old if we have one if (_gameStatistics != null) { Destroy(_gameStatistics.gameObject); } //Instantuate the player statistics. _gameStatistics = Instantiate(BlankStatistics) as Statistics; _gameStatistics.transform.parent = transform; _gameStatistics.gameObject.name = "TotalGameStatistics"; _gameStatistics.ContainerLabel = "All Game Stats"; _gameStatistics.LoadFromPlayerPrefs(); DontDestroyOnLoad(_gameStatistics.gameObject); //Load the gem bank _gemBank = FileFetch.FetchInt("GEMBANK"); //Load the total xp _totalXP = FileFetch.FetchInt("TOTALXP"); //_totalXP = 0; //Set the total xp into the leveling system to calculate. if (!MyPTPLevel) { //Create the level object. _myLeveling = Instantiate(PTPLevelingPrefab) as PlayerLevelSystem; _myLeveling.transform.parent = transform; DontDestroyOnLoad(_myLeveling.gameObject); } TotalXP = _totalXP; foreach (BaseItemCard card in CardDeck) { //Only go through missions for dirty cards. card.LoadCardItem(); } //Load slots here //LoadSlots(); ClearGameSlots(); //Handle options and other data here. Options.Load(); //SocialCenter.Instance.LoadLeaderboard("Highscore_PPS"); }
public void ReadFromPlayerPrefs(string statsName) { EntryValue = FileFetch.FetchInt(statsName + "_EntryDataValue_" + DataLabel); EntryType = (Statistics.EntryTypes)FileFetch.FetchInt(statsName + "_EntryType_" + DataLabel); ValueData = FileFetch.FetchInt(statsName + "_EntryData_" + DataLabel); }
//Write to player prefs function public void WriteToPlayerPrefs(string statsName) { FileFetch.SetInt(statsName + "_EntryDataValue_" + DataLabel, EntryValue); FileFetch.SetInt(statsName + "_EntryType_" + DataLabel, (int)EntryType); FileFetch.SetInt(statsName + "_EntryData_" + DataLabel, ValueData); }
public void Save() { FileFetch.SetFloat("OPTIONS_SFX", SoundFXLevel); FileFetch.SetFloat("OPTIONS_MUSIC", MusicLevel); }