public static GGJReisenSave FetchSaveData(string saveName) { // 1 string jsonSavePath = string.Format("{0}/{1}.json", Application.persistentDataPath, saveName); if (File.Exists(jsonSavePath)) { GGJReisenSave save = JsonUtility.FromJson <GGJReisenSave>(File.ReadAllText(jsonSavePath)); return(save); } else { return(null); } }
public static void SaveGame(string saveName, ReisenGameProgress gameProgress) { // 1 GGJReisenSave save = new GGJReisenSave(saveName, gameProgress); // 2 string jsonSavePath = string.Format("{0}/{1}.json", Application.persistentDataPath, saveName); Debug.Log(jsonSavePath); string jsonData = JsonUtility.ToJson(save, true); File.WriteAllText(jsonSavePath, jsonData); Debug.Log("Game Saved"); }
public static ReisenGameProgress FetchGameProgress(string saveName) { // 1 string jsonSavePath = string.Format("{0}/{1}.json", Application.persistentDataPath, saveName); if (File.Exists(jsonSavePath)) { GGJReisenSave save = JsonUtility.FromJson <GGJReisenSave>(File.ReadAllText(jsonSavePath)); Debug.Log("Game Loaded"); return(save.gameProgress); } else { throw new Exception("save not found"); } }
public override void Init() { for (int i = 0; i < SaveManager.saveNames.Count; i++) { string saveName = SaveManager.saveNames[i]; SavePanelUI panel = savePanels[i]; panel.fileName = saveName; GGJReisenSave saveData = SaveManager.FetchSaveData(saveName); if (saveData != null) { panel.InitializeSavePanel(saveData); } else { panel.InitializeSavePanel(); } } UpdateOption(); }
public void InitializeSavePanel(GGJReisenSave save) { locationText.text = save.gameProgress.savePoint.locationName; shardCountText.text = "Shards: " + save.gameProgress.Player.ShardsAcquired.Count.ToString(); saveTimeText.text = save.saveTime; }
public void InitializeTitleMenu() { group.menuElements.Clear(); bool hasSaveData = false; foreach (string saveName in SaveManager.saveNames) { GGJReisenSave saveData = SaveManager.FetchSaveData(saveName); hasSaveData |= saveData != null; } bool hasShardData = false; ShardSaveData shardData = SaveManager.FetchSeenShardData(); hasShardData = hasShardData || (shardData != null); newGameElement.gameObject.SetActive(true); optionsElement.gameObject.SetActive(true); galleryElement.gameObject.SetActive(true); continueGameElement.gameObject.SetActive(hasSaveData); viewShardsElement.gameObject.SetActive(hasShardData); clearShardDataElement.gameObject.SetActive(hasShardData); int activeMenuElement = 0; if (hasSaveData) { AddMenuElement(continueGameElement, activeMenuElement); activeMenuElement++; UnityEngine.EventSystems.EventSystem.current.firstSelectedGameObject = continueGameElement.gameObject; } AddMenuElement(newGameElement, activeMenuElement); activeMenuElement++; if (hasShardData) { AddMenuElement(viewShardsElement, activeMenuElement); activeMenuElement++; AddMenuElement(clearShardDataElement, activeMenuElement); activeMenuElement++; } AddMenuElement(optionsElement, activeMenuElement); activeMenuElement++; AddMenuElement(galleryElement, activeMenuElement); activeMenuElement++; //setting navigation if (!hasSaveData || !hasShardData) { Navigation newGameNav = new Navigation(); newGameNav.mode = Navigation.Mode.Explicit; Navigation optionsNav = new Navigation(); optionsNav.mode = Navigation.Mode.Explicit; Navigation galleryNav = new Navigation(); galleryNav.mode = Navigation.Mode.Explicit; if (!hasSaveData) { newGameNav.selectOnUp = galleryElement.GetComponent<Button>(); optionsNav.selectOnDown = galleryElement.GetComponent<Button>(); galleryNav.selectOnDown = newGameElement.GetComponent<Button>(); } else { newGameNav.selectOnUp = continueGameElement.GetComponent<Button>(); optionsNav.selectOnDown = galleryElement.GetComponent<Button>(); galleryNav.selectOnDown = continueGameElement.GetComponent<Button>(); } if (!hasShardData) { newGameNav.selectOnDown = optionsElement.GetComponent<Button>(); optionsNav.selectOnUp = newGameElement.GetComponent<Button>(); galleryNav.selectOnUp = optionsElement.GetComponent<Button>(); } else { newGameNav.selectOnDown = viewShardsElement.GetComponent<Button>(); optionsNav.selectOnUp = clearShardDataElement.GetComponent<Button>(); galleryNav.selectOnUp = optionsElement.GetComponent<Button>(); } newGameElement.GetComponent<Button>().navigation = newGameNav; optionsElement.GetComponent<Button>().navigation = optionsNav; galleryElement.GetComponent<Button>().navigation = galleryNav; } //dumb hacks we don't really care about groups anymore lol //group.menuElements.Clear(); //group.FocusElement(group.currentMenuElementIndex); }