public void SaveShapes() { PlayerDataController.data.savedShapes = new List <MyTuples>(); foreach (var shape in GameManager.instance.currentShapes) { Shape shapeData = shape.GetComponent <Shape>(); PlayerDataController.data.savedShapes.Add(new MyTuples(shapeData.id, shapeData.spawnIndex)); } PlayerDataController.SaveData("savedShapes", FlatHelper.ToJson <MyTuples>(PlayerDataController.data.savedShapes)); }
public void SaveBlockStatusChange(CellManager placement, bool placed) { MyTuples myTuple = PlayerDataController.data.uncompletedLevel.GetTuple(placement.index.x, placement.index.y); if (myTuple.isFull != placed) { myTuple.isFull = placed; PlayerDataController.SaveData("uncompletedLevel", FlatHelper.ToJson <MyTuples>(PlayerDataController.data.uncompletedLevel)); } }
public static void ResetLevelData() { Debug.Log("Level Data Is Resetted"); foreach (var cellData in data.uncompletedLevel) { cellData.isFull = false; } Player.main.goldAccuiredThisLevel = 0; SaveData("uncompletedLevel", FlatHelper.ToJson <MyTuples>(data.uncompletedLevel)); SaveData("isLevelCompleted", false); SaveData("animalProgress", FlatHelper.ToJson <int>(LevelManager.instance.activeLevelData.missionLenghts)); SaveData("levelModIndex", (int)LevelManager.instance.activeLevelData.startingMode); SaveData("levelPartTheme", (int)LevelManager.instance.activeLevelData.partTheme); SaveData("goldAccuiredThisLevel", Player.main.goldAccuiredThisLevel); }
public static bool SetDefaultDataForFirstTime(string jsonFile) { isInStart = false; Timer.Reset(); data = FlatHelper.FromJson <PlayerDataModel>(jsonFile); if (!HasKey("isRefreshDataEveryLaunch") || GetData <int>("isRefreshDataEveryLaunch") == 1) { Clear(); foreach (var property in typeof(PlayerDataModel).GetFields()) { if (property.GetValue(data).GetType() == typeof(List <VideoAdsDataModel>)) { jsonData = FlatHelper.ToJson <VideoAdsDataModel>(property.GetValue(data)); SaveData(property.Name, jsonData); } else if (property.GetValue(data).GetType() == typeof(List <ThemesDataModel>)) { jsonData = FlatHelper.ToJson <ThemesDataModel>(property.GetValue(data)); SaveData(property.Name, jsonData); } else if (property.GetValue(data).GetType() == typeof(List <MyTuples>)) { jsonData = FlatHelper.ToJson <MyTuples>(property.GetValue(data)); SaveData(property.Name, jsonData); } else { SaveData(property.Name, property.GetValue(data)); } } isInStart = true; return(true); } else { RefreshModel(); isInStart = true; return(false); } }
public static void ChangeValueInList(string listName, string key, object value) { VideoAdsDataModel dataModel1; ThemesDataModel dataModel2; int count; if (listName == "videoAds") { for (int i = 0; i < data.videoAds.Count; i++) { dataModel1 = data.videoAds[i]; if (dataModel1.name == key) { dataModel1.reward = (int)value; } } } else if (listName == "theme1" || listName == "theme2") { count = listName == "theme1" ? data.theme1.Count : data.theme2.Count; for (int i = 0; i < count; i++) { dataModel2 = listName == "theme1" ? data.theme1[i] : data.theme2[i]; if (dataModel2.name == key) { dataModel2.state = (bool)value; } } } if (listName == "videoAds") { jsonData = FlatHelper.ToJson <VideoAdsDataModel>(data.videoAds); } else if (listName == "theme1" || listName == "theme2") { jsonData = FlatHelper.ToJson <ThemesDataModel>((listName == "theme1" ? data.theme1 : data.theme2)); } SaveData(listName, jsonData); }