Commit be9f996b authored by Marcel Kuehn's avatar Marcel Kuehn
Browse files

Challenegr Mode nun gespeichert in safeLoad

parent af35d702
......@@ -3,16 +3,23 @@ using UnityEngine;
public class ChallagerController : MonoBehaviour {
private PlayerActor pa;
public float waitTime;
[SerializeField] private float waitTime;
private readonly Queue<Vector3> oldPosition = new Queue<Vector3>();
private readonly Queue<Quaternion> oldRotation = new Queue<Quaternion>();
[SerializeField] private Collider2D col;
[SerializeField] private Animator ani;
private void Start() {
pa=FindObjectOfType<PlayerActor>();
waitTime = 2.0f;
col.enabled = false;
ani.enabled = false;
}
private void FixedUpdate() {
......@@ -20,8 +27,13 @@ public class ChallagerController : MonoBehaviour {
oldPosition.Enqueue(pa.transform.position);
oldRotation.Enqueue(pa.transform.rotation);
transform.position = oldPosition.Dequeue();
transform.rotation = oldRotation.Dequeue();
col.enabled = true;
ani.enabled = true;
}
else {
waitTime -= Time.deltaTime;
......
......@@ -26,8 +26,9 @@ public class GameManager : SingletonBehaviour<GameManager> {
LastLevel = SceneManager.sceneCountInBuildSettings - 1;
if (LoadSave.DoesSaveFileExist) {
LoadSave.Load(out currentLevel, out int tmp);
LoadSave.Load(out currentLevel, out int tmp, out bool tmpCh);
HighestLevel = tmp;
IsChallengerModeEnabled = tmpCh;
}
}
......@@ -77,7 +78,8 @@ public class GameManager : SingletonBehaviour<GameManager> {
}
int tmp = HighestLevel;
LoadSave.Save(currentLevel, tmp);
bool tmpCh = IsChallengerModeEnabled;
LoadSave.Save(currentLevel, tmp, tmpCh);
LoadLevel(currentLevel);
}
......@@ -132,6 +134,7 @@ public class GameManager : SingletonBehaviour<GameManager> {
currentLevel = 1;
HighestLevel = 1;
int highestLevel = HighestLevel;
LoadSave.Save(currentLevel, highestLevel);
bool challengerEnabled = IsChallengerModeEnabled;
LoadSave.Save(currentLevel, highestLevel, challengerEnabled);
}
}
......@@ -10,12 +10,15 @@ public static class LoadSave {
private struct SaveData {
public int currentLevelSafe;
public int highestLevelSafe;
public bool challangerIsOnSafe;
}
public static void Save(int currentLevel, int highestLevel) {
public static void Save(int currentLevel, int highestLevel, bool isChallengerOn) {
SaveData data = new SaveData {
currentLevelSafe = currentLevel,
highestLevelSafe = highestLevel
highestLevelSafe = highestLevel,
challangerIsOnSafe = isChallengerOn
};
StreamWriter sw = new StreamWriter(SaveFile);
......@@ -23,11 +26,12 @@ public static class LoadSave {
sw.Close();
}
public static void Load(out int currentLevel, out int highestLevel) {
public static void Load(out int currentLevel, out int highestLevel, out bool isChallengerOn) {
StreamReader sr = new StreamReader(SaveFile);
SaveData save = JsonUtility.FromJson<SaveData>(sr.ReadToEnd());
sr.Close();
currentLevel = save.currentLevelSafe;
highestLevel = save.highestLevelSafe;
isChallengerOn = save.challangerIsOnSafe;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment