private static IBData LoadIBData(DateTime date, int index) { string saveKey = SaveKeys.IBEntry(CustomDate.FromDateTime(date), index); string saveDataString = SaveStorage.GetString(saveKey); return(JsonUtility.FromJson <IBData>(saveDataString)); }
public static void SaveSettings() { //SavableSettings sets = new SavableSettings(); //List<FieldInfo> savableprops = typeof(SavableSettings).GetFields().ToList(); //PropertyInfo[] settingsprops = typeof(InputMap).GetProperties(); //int i = 0; ////sets,settingsprops[i].GetValue(this,null),null //foreach (var propertyInfo in savableprops) //{ // propertyInfo.SetValue(sets, settingsprops[i].GetValue(null, null)); // i++; //} SaveKeys save = new SaveKeys(); save.keys = new List <string>(KeyBinds.Keys); save.values = new List <KeyCode>(KeyBinds.Values); //Dictionary<string, KeyCode> Kb = new Dictionary<string, KeyCode>(KeyBinds); //save.binds = KeyBinds; string Json = JsonUtility.ToJson(save, true); //string codesJson = JsonUtility.ToJson(keyCodes, true); string path = Application.persistentDataPath; path = Application.dataPath + "/bin"; if (!File.Exists(path)) { Directory.CreateDirectory(path); } File.WriteAllText(path + "/settings" + ".json", Json); }
private void StartLevel(LevelData ld) { if (ld == null) // Safety check. { Debug.LogError("Can't load the requested level! Can't find its LevelData."); if (CurrLevel == null) // If there's no currentLevel, yikes! Default us to something. { ld = dataManager.GetLevelData(0, 0); } else { return; } // If there IS a currentLevel, then don't leave it. } // Reset some values DestroyCurrentLevel(); // Instantiate the Level from the provided LevelData! CurrLevel = Instantiate(ResourcesHandler.Instance.Level).GetComponent <Level>(); CurrLevel.Initialize(this, MainCanvas.Canvas.transform, rt_boardArea, ld); SaveStorage.SetInt(SaveKeys.LastPlayedLevelInPack(currAddress.pack), currAddress.level); SaveStorage.SetString(SaveKeys.LastPlayedLevelAddress, currAddress.ToString()); ExpandLevelHierarchy(); // Dispatch event! GameManagers.Instance.EventManager.OnStartLevel(CurrLevel); }
//private void UpdateIsOpen() { // bool isOpen = // SetIsOpen(isOpen); //} private void SetIsOpen(bool _isOpen) { isOpen = _isOpen; SaveStorage.SetBool(SaveKeys.IsProgressGateOpen(MyRoom, myIndex), isOpen); UpdateIsReadyToOpen(); UpdateOpennessVisuals(); }
private void StartPack(int packIndex) { int levelIndex = SaveStorage.GetInt(SaveKeys.LastPlayedLevelInPack(packIndex)); levelIndex = 0;//QQQ StartLevel(new LevelAddress(packIndex, levelIndex)); }
private void SaveAndAffiliateAudioFile() { // First, delete the old clip. dm.DeleteTermAudio0(currTerm); AudioClip clip = clipPlayer.GetClip(); clip = AudioEditor.GetTrailingSilenceTrimmed(clip); Guid newGuid = Guid.NewGuid(); // Assign it to the Term! currTerm.audio0Guid = newGuid.ToString(); dm.SaveStudySetLibrary(); // Save audio file. string filePath = SaveKeys.TermAudioClip0(currTerm.audio0Guid); SavWav.Save(filePath, clip); //EncodeMP3.ConvertAndWrite(clip, filePath, 128); Debug.Log("SAVED audio. Length: " + clip.length); // Set this as the current clip! UpdateVisualsForClip(clip); GameManagers.Instance.EventManager.OnAnySetContentsChanged(); }
public void StartGameAtRoom(RoomData rd, PlayerData playerData) { // Wipe everything totally clean. DestroyPlayer(); DestroyRoom(); dm.currRoomData = rd; // Make Room and Player! CurrRoom = Instantiate(ResourcesHandler.Instance.Room).GetComponent <Room>(); CurrRoom.Initialize(this, tf_world, rd); MakePlayer(playerData); // Tell the RoomData it's on! rd.OnPlayerEnterMe(); // Reset things! dm.ResetRoomEnterValues(); // Save what's up! SaveStorage.SetInt(SaveKeys.LastPlayedWorldIndex, rd.WorldIndex); SaveStorage.SetString(SaveKeys.LastPlayedRoomKey(rd.WorldIndex), rd.RoomKey); SaveStorage.SetFloat(SaveKeys.MapEditor_CameraPosX, rd.PosGlobal.x); SaveStorage.SetFloat(SaveKeys.MapEditor_CameraPosY, rd.PosGlobal.y); //// Use this opportunity to call SAVE with SaveStorage, yo! (This causes a brief stutter, so I'm opting to call it when the game is already loading.) //SaveStorage.Save(); // Dispatch the post-function event! eventManager.OnStartRoom(CurrRoom); }
public void ReloadStudySetLibrary() { string libSaveKey = SaveKeys.StudySetLibrary(SettingsManager.Instance.CurrForeignCode); //// QQQ if we can't find the correct key, use the OLD one. Should just be for ONE push to my phone. //if (SettingsManager.Instance.CurrForeignCode=="da" && !SaveStorage.HasKey(libSaveKey)) { // if (SaveStorage.HasKey("StudySetLibrary")) { // libSaveKey = "StudySetLibrary"; // } //} // NO save data?! Ok, default to Quizlet hardcoded ones! :) if (!SaveStorage.HasKey(libSaveKey)) { //ReplaceAllStudySetsWithPremadeHardcodedOnes(); library = new StudySetLibrary(); } // Otherwise, YES load what's been saved! else { string jsonString = SaveStorage.GetString(libSaveKey); library = JsonUtility.FromJson <StudySetLibrary>(jsonString); // Convert the unpacked term list to our efficient dictionary. library.RemakeTermsDictionaryFromList(); // Reaffiliate all terms with their sets. foreach (StudySet set in library.GetMainAndBenchedSetsList()) { set.SetMyLibraryAndGiveMyTermsRefToMe(library); } } // Hardcoded. Set some properties manually. //library.setToughies.isRemixSet = true; //library.setSourdough.isRemixSet = true; //library.setAced.canIncludeMeInRemixes = false; //library.setInQueue.canIncludeMeInRemixes = false; //library.setShelved.canIncludeMeInRemixes = false; //library.setToValidate.canIncludeMeInRemixes = false; //library.setWantRecording.canIncludeMeInRemixes = false; //foreach (StudySet set in library.sets) { // set.canIncludeMeInRemixes = true; //} // DEBUG. Print any terms that don't belong to the set they're in. foreach (StudySet set in library.sets) { for (int i = set.allTermGs.Count - 1; i >= 0; --i) { string termG = set.allTermGs[i]; Term term = library.GetTerm(termG); if (term.mySet != set) { AppDebugLog.LogError("MISMATCH BETWEEN SETS: " + set.name + ", " + term.MySetName() + ", " + term.native); set.RemoveTerm(termG); // Remove it from this set! ONLY trust the Term's set. } } } }
public void SaveStudySetLibrary() { string jsonString = JsonUtility.ToJson(library); string libSaveKey = SaveKeys.StudySetLibrary(SettingsManager.Instance.CurrForeignCode); SaveStorage.SetString(libSaveKey, jsonString); Debug.Log("SAVED STUDYSET LIBRARY: " + jsonString); }
public void OnPlayerExitMyRoom() { // Save when the Player EXITS this Room. if (doSaveIsUnlocked) { SaveStorage.SetBool(SaveKeys.IsGateUnlocked(myRoom, channelID), IsUnlocked); } }
// ---------------------------------------------------------------- // Events // ---------------------------------------------------------------- override public void GetEaten() { base.GetEaten(); // Save the value! SaveStorage.SetBool(SaveKeys.DidEatGem(MyRoom, myIndex), true); // Particle bursttt ps_collectedBurst.Emit(16); }
// ---------------------------------------------------------------- // Doers // ---------------------------------------------------------------- public void SetDidCompleteLevel(bool _didCompleteLevel) { if (DidCompleteLevel != _didCompleteLevel) { DidCompleteLevel = _didCompleteLevel; SaveStorage.SetBool(SaveKeys.DidCompleteLevel(myAddress), DidCompleteLevel); } }
public void OnPlayerEnterMe() { // First time in room?? Update hasPlayerBeenHere!! if (!HasPlayerBeenHere) { HasPlayerBeenHere = true; SaveStorage.SetBool(SaveKeys.HasPlayerBeenInRoom(this), HasPlayerBeenHere); } }
// ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public LevelData(LevelAddress myAddress, LevelDataXML ldxml) { // Basic properties this.myAddress = myAddress; boardData = new BoardData(ldxml); startingZoom = ldxml.zoom; // LOAD up stats! DidCompleteLevel = SaveStorage.GetBool(SaveKeys.DidCompleteLevel(myAddress)); }
// ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public GateChannel(Room myRoom, int channelID) { this.myRoom = myRoom; this.channelID = channelID; this.doSaveIsUnlocked = channelID < 3; // Hacky: We don't wanna save gate-unlockedness for Channels 3 and up. if (doSaveIsUnlocked) { IsUnlocked = SaveStorage.GetBool(SaveKeys.IsGateUnlocked(myRoom, channelID)); } }
// ================================================================ // Initialize // ================================================================ public RoomData(WorldData _worldData, string _key) { MyWorldData = _worldData; MyAddress = new RoomAddress(MyWorldData.worldIndex, -1, _key); IsSecret = false; HasPlayerBeenHere = SaveStorage.GetBool(SaveKeys.HasPlayerBeenInRoom(this), false); // Initialize all my PropData lists. ClearAllPropDataLists(); Openings = new List <RoomOpening>(); }
override public void GetEaten() { base.GetEaten(); // Save the value! SaveStorage.SetBool(SaveKeys.DidEatSnack(MyRoom, myIndex), true); // Particle bursttt and visuals sr_aura.enabled = false; ps_collectedBurst.Emit(4); // Tell my WorldData! MyRoom.MyWorldData.OnPlayerEatSnack(MyRoom); }
// ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public void Initialize(Room _myRoom, ProgressGateData data, int myIndex) { this.myIndex = myIndex; base.BaseGroundInitialize(_myRoom, data); numSnacksReq = data.numSnacksReq; UpdateText(); // Load openness! isOpen = SaveStorage.GetBool(SaveKeys.IsProgressGateOpen(MyRoom, myIndex)); UpdateIsReadyToOpen(); UpdateOpennessVisuals(); }
public void Initialize(Room _myRoom, SnackData data, int myIndex) { base.InitializeAsProp(_myRoom, data); this.myIndex = myIndex; this.playerType = PlayerTypeHelper.TypeFromString(data.playerType); // Load wasEverEaten! wasEverEaten = SaveStorage.GetBool(SaveKeys.DidEatSnack(MyRoom, myIndex)); isEaten = wasEverEaten; UpdatePresence(); }
private void SwapPlayerType(Player player) { PlayerTypes playerNewType = CharTypeInMe; PlayerTypes myNewType = player.PlayerType(); // Set Player's type! MyRoom.GameController.SetPlayerType(playerNewType); // Set/save my type! SetCharTypeInMe(myNewType); SaveStorage.SetString(SaveKeys.CharBarrelTypeInMe(MyRoom.MyRoomData, myIndex), myNewType.ToString()); // Reset timeWhenCanSensePlayer! timeWhenCanSensePlayer = Time.time + 0.1f; }
public static void LoadDefaults() { string Json = File.ReadAllText(Application.dataPath + "/bin/defaults.json"); SaveKeys saved = JsonUtility.FromJson <SaveKeys>(Json); int i = 0; KeyBinds.Clear(); foreach (var key in saved.keys) { KeyBinds.Add(key, saved.values[i]); i++; } }
public void SetClustIndex(int clustIndex) { this.MyAddress = new RoomAddress(WorldIndex, clustIndex); this.IsUnlocked = SaveStorage.GetBool(SaveKeys.ClustIsUnlocked(MyAddress), false); if (GameProperties.IsFirstCluster(MyAddress)) { this.IsUnlocked = true; } // First cluster is ALWAYS unlocked. //this.IsUnlocked = true; // TEMP!! ALL clusters start unlocked!! Test! // Set NumSnacksReq NumSnacksReq = GameProperties.ClustNumSnacksReq(MyAddress); // NOTE: Doesn't seem as if we need to update Rooms, so I'm not doing that. }
// ---------------------------------------------------------------- // Audio Save/Load // ---------------------------------------------------------------- void LoadClipForCurrTerm() { string clipPath = SaveKeys.TermAudioClip0(currTerm.audio0Guid); bool isClipFile = File.Exists(clipPath); if (isClipFile) { clipPlayer.LoadClipFromPath(clipPath, false); } else { UpdateVisualsForNoClip(); } }
//private Rect MyRect { // get { // return new Rect(sr_body.transform.localPosition, sr_body.size); // } //} // ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public void Initialize(Room _myRoom, VeilData data, int myIndex) { base.InitializeAsProp(_myRoom, data); this.myIndex = myIndex; Size = data.size; // Color me right-o. sr_body.color = Colors.GroundBaseColor(WorldIndex); // Start opaque. bool isUnveiled = SaveStorage.GetBool(SaveKeys.IsVeilUnveiled(MyRoom.MyRoomData, myIndex), false); SetIsUnveiled(isUnveiled, false); }
// ---------------------------------------------------------------- // Start // ---------------------------------------------------------------- public void Initialize(Room _myRoom, CharBarrelData data, int myIndex) { base.InitializeAsProp(_myRoom, data); timeWhenCanSensePlayer = Time.time; this.otherCharName = data.otherCharName; this.myIndex = myIndex; // Load what character's in me! string savedCharType = SaveStorage.GetString(SaveKeys.CharBarrelTypeInMe(MyRoom.MyRoomData, myIndex), otherCharName); SetCharTypeInMe(PlayerTypeHelper.TypeFromString(savedCharType)); }
// ---------------------------------------------------------------- // Audio // ---------------------------------------------------------------- public void DeleteTermAudio0(Term term) { // No audio? Get outta here. if (!term.HasAudio0()) //string.IsNullOrEmpty(term.audio0Guid) { return; } // Delete the actual file! string clipPath = SaveKeys.TermAudioClip0(term.audio0Guid); File.Delete(clipPath); // Null out the Term's guid, and save our library! term.audio0Guid = ""; SaveStudySetLibrary(); }
public void PlayTermClip(Term term) { // NOTE: For now, just load the clip EVERY time for safety. We want it definitely trimmed/normalized. //// Is it a new clip? Load a new clip! //if (currClipGuid != term.audio0Guid) { currClipGuid = term.audio0Guid; string clipPath = SaveKeys.TermAudioClip0(term.audio0Guid); LoadClipFromPath(clipPath, true); //} //// Otherwise, play what's loaded; it's already the correct clip. //else { // Play(); //} }
static public void OpenGameplayScene(RoomClusterData clust) { // Default to the first Room in the cluster. RoomData room = clust.rooms[0]; // Did we last play this cluster? Start in the last room we were in! string lastPlayedRoomKey = SaveStorage.GetString(SaveKeys.LastPlayedRoomKey(clust.WorldIndex)); for (int i = 0; i < clust.rooms.Count; i++) { if (lastPlayedRoomKey == clust.rooms[i].RoomKey) { room = clust.rooms[i]; break; } } OpenGameplayScene(room); }
[SerializeField] private int type = 0; // 0 is action, 1 is puzzle. // ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public void Initialize(Room _myRoom, GemData data, int myIndex) { base.InitializeAsProp(_myRoom, data); this.myIndex = myIndex; this.type = data.type; // Load wasEverEaten! wasEverEaten = SaveStorage.GetBool(SaveKeys.DidEatGem(MyRoom, myIndex)); // Set wasEverEaten visuals. if (wasEverEaten) { sr_body.color = new Color(0.2f, 0.2f, 0.2f, 0.25f); } // Apply type visuals. sr_body.sprite = ResourcesHandler.Instance.GetGemSprite(type); }
public void Refresh(RoomData rd) { // Clear totals. ZeroCounts(); // Recalculate totals! for (int i = 0; i < rd.snackDatas.Count; i++) { PlayerTypes playerType = PlayerTypeHelper.TypeFromString(rd.snackDatas[i].playerType); total[playerType]++; Total_All++; //total[PlayerTypes.Every] ++; if (SaveStorage.GetBool(SaveKeys.DidEatSnack(rd, i))) { eaten[playerType]++; Eaten_All++; } } }