Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
some changes
  • Loading branch information
atlasapplications committed Apr 26, 2023
1 parent 48c51cd commit 502ddaf
Show file tree
Hide file tree
Showing 11 changed files with 630 additions and 131 deletions.
6 changes: 4 additions & 2 deletions Assets/Scripts/GameSave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
using UnityEngine;
using Newtonsoft.Json;
using System.IO;
using System.Collections.Generic;

public class GameSave
{
public bool[] LevelsUnlocked { get; set; } = new bool[] { };
public Dictionary<string, bool> LevelsUnlocked { get; set; } = new Dictionary<string, bool>();
//public bool[] LevelsUnlocked { get; set; } = new bool[] { };

private const string SAVE_PATH = "save.json";
public GameSave() { }
Expand Down Expand Up @@ -53,7 +55,7 @@ public static bool SaveGameSave(GameSave gameSave)
}
private static string CreatePath()
{
string path = string.Format("{0}{1}", Application.dataPath, SAVE_PATH);
string path = string.Format("{0}/{1}", Application.dataPath, SAVE_PATH);
Debug.Log("Path created: " + path); // DEBUG
return path;
}
Expand Down
4 changes: 3 additions & 1 deletion Assets/Scripts/Interactables/LevelCompleteTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ private void GoBackToOverworld()
if (!hasLoaded)
{
hasLoaded = true;
int nextLevelId = levelId + 1;


try
{
LevelManager.Instance.UnlockedLevels[levelId + 1] = true;
//LevelManager.Instance.GameSave.LevelsUnlocked[levelId + 1] = true;
}
catch (IndexOutOfRangeException ex)
{
Expand Down
7 changes: 0 additions & 7 deletions Assets/Scripts/LevelManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ public GameSave GameSave
{
get => gameSave;
}
public List<bool> UnlockedLevels
{
get => unlockedLevels;
}

private static LevelManager instance;
private GameSave gameSave;
private List<bool> unlockedLevels;

private void Awake()
{
Expand All @@ -46,14 +41,12 @@ private void Awake()
DontDestroyOnLoad(gameObject);

gameSave = GameSave.LoadGameSave();
unlockedLevels = gameSave.LevelsUnlocked.ToList();

Scene activeScene = SceneManager.GetActiveScene();
Debug.Log($"Welcome to {activeScene.name}!");
}
private void OnDestroy()
{
gameSave.LevelsUnlocked = unlockedLevels.ToArray();
GameSave.SaveGameSave(gameSave);
}
}
1 change: 0 additions & 1 deletion Assets/Scripts/Movement/PlayerMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ void Update()
UpdateJumpSound();

bool checkOnGround = OnGround();
Debug.Log("Is on ground: " + checkOnGround);

if (OnGround())
{
Expand Down
Loading

0 comments on commit 502ddaf

Please sign in to comment.