public static void SaveSeenShardData(ReisenGameProgress gameProgress) { List <Shard> totalSeenShardData; ShardSaveData totalData = FetchSeenShardData(); if (totalData != null) { totalSeenShardData = totalData.shardData; } else { totalSeenShardData = new List <Shard>(); } foreach (Shard s in gameProgress.Player.ShardsAcquired) { if (!totalSeenShardData.Any(x => x.Id == s.Id)) { totalSeenShardData.Add(s); } } ShardSaveData data = new ShardSaveData(totalSeenShardData); // 2 string jsonSavePath = string.Format("{0}/{1}.json", Application.persistentDataPath, shardSaveDataName); Debug.Log(jsonSavePath); string jsonData = JsonUtility.ToJson(data, true); File.WriteAllText(jsonSavePath, jsonData); Debug.Log("Shard data Saved"); }
public GGJReisenSave(string saveName, ReisenGameProgress gameProgress) { this.saveName = saveName; this.saveTime = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); Debug.Log(saveTime); this.gameProgress = gameProgress; }
IEnumerator LoadGameSequence(string saveName) { yield return(TransitionManager.instance.screenFader.FadeOut()); loadedGameProgress = SaveManager.FetchGameProgress(saveName); SceneManager.LoadScene(loadedGameProgress.savePoint.sceneName); SceneManager.sceneLoaded += OnSceneLoaded; }
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 override void Init() { ReisenGameProgress gameProgress = ReisenGameManager.instance.gameProgress; List <KeyItem> inventoryKeyItems = gameProgress.Player.GetKeyItemsInInventory(); foreach (MenuUIElement oldElement in group.menuElements) { Destroy(oldElement.gameObject); } group.menuElements.Clear(); emptyText.gameObject.SetActive(inventoryKeyItems.Count == 0); for (int i = 0; i < inventoryKeyItems.Count; i++) { KeyItem item = inventoryKeyItems[i]; ItemUIElement element = Instantiate(ItemMenuElement).GetComponent <ItemUIElement>(); element.transform.SetParent(group.transform, false); element.transform.position = initialPosition.position + i * Vector3.down * spacing; element.parentMenu = this; element.parentGroup = group; element.pauseMenuUI = pauseMenuUI; element.parentMenuOnSelectMode = ParentMenuStatusPostSelect.none; element.itemData = item; //Initialize the appearance here element.InitAppearance(); group.menuElements.Add(element); } //if (group.menuElements.Count == 0) //{ // KeyItem fillerItem = new KeyItem("", "Gah where did all of my inventory go!"); // ItemUIElement element = Instantiate(ItemMenuElement).GetComponent<ItemUIElement>(); // element.transform.parent = group.transform; // element.transform.position = initialPosition.position; // element.parentMenu = this; // element.parentGroup = group; // element.pauseMenuUI = pauseMenuUI; // element.itemData = fillerItem; // group.menuElements.Add(element); //} base.Init(); }
IEnumerator LoadGameSequence(string saveName) { yield return(TransitionManager.instance.screenFader.FadeOut()); gameProgress = SaveManager.FetchGameProgress(saveName); SceneManager.LoadScene(gameProgress.savePoint.sceneName); spawnLocation = -1; gameProgress.savePoint.SpawnPlayer(RpgPlayer.instance.gameObject); CameraMan.instance.smoothMovement = false; yield return(TransitionManager.instance.screenFader.FadeIn()); CameraMan.instance.smoothMovement = true; RpgGameManager.instance.ResumeGameplay(); }
public override void Init() { List <Shard> totalShardData = SaveManager.FetchSeenShardData()?.shardData; List <Shard> shardsToDisplay; if (isPauseMenuVersion) { ReisenGameProgress gameProgress = ReisenGameManager.instance.gameProgress; shardsToDisplay = gameProgress.Player.ShardsAcquired; // debug things // new List<Shard>() { new Shard("0", 0, "titletesting", "why not"), new Shard("0", 0, "testing2", "why not2"), // new Shard("0", 0, "titletesting2", "why not3"), new Shard("0", 0, "testing2", "why not2"), // new Shard("0", 0, "titletesting3", "why not3"), new Shard("0", 0, "testing2", "why not2"), // new Shard("0", 0, "titletesting3", "why not3"), new Shard("0", 0, "testing2", "why not2") }; } else { shardsToDisplay = Shard.ShardDictionary.Select(x => x.Value).ToList(); } foreach (MenuUIElement oldElement in group.menuElements) { Destroy(oldElement.gameObject); } group.menuElements.Clear(); emptyText.gameObject.SetActive(shardsToDisplay.Count == 0); for (int i = 0; i < shardsToDisplay.Count; i++) { Shard shard = shardsToDisplay[i]; ShardMenuUIElement element = Instantiate(shardMenuElement).GetComponent <ShardMenuUIElement>(); element.transform.SetParent(group.transform, false); element.transform.position = initialPosition.position + ((i % cols) * Vector3.right * xspacing) + ((i / cols) * Vector3.down * yspacing); element.parentMenu = this; element.parentGroup = group; element.isPauseMenuVersion = isPauseMenuVersion; element.shardMenuUI = this; element.parentMenuOnSelectMode = ParentMenuStatusPostSelect.none; element.shardData = shard; element.ShardImage.sprite = shard.ShardValue == 2 ? element.doubleShardSprite : element.singleShardSprite; group.menuElements.Add(element); if (isPauseMenuVersion) { element.IsRevealed = true; } else { element.IsRevealed = totalShardData.Any(x => x.Id == shard.Id); } } if (completionProgress != null) { float totalShardCount; if (totalShardData.Count == 0) { totalShardCount = 0; } else { totalShardCount = totalShardData.Select(x => x.ShardValue).Aggregate((x, y) => x + y); } float displayShardCount = shardsToDisplay.Select(x => x.ShardValue).Aggregate((x, y) => x + y); completionProgress.text = ((int)(totalShardCount / displayShardCount * 100.0f)).ToString() + "%"; } base.Init(); }