Skip to content
Snippets Groups Projects
Commit f849b60f authored by Karlsen Adiyasa Bachtiar's avatar Karlsen Adiyasa Bachtiar
Browse files

stop score when gameover, fix save path

parent 6204563c
Branches
No related merge requests found
...@@ -16,9 +16,9 @@ public static class DataManager ...@@ -16,9 +16,9 @@ public static class DataManager
BinaryFormatter formatter = new BinaryFormatter(); BinaryFormatter formatter = new BinaryFormatter();
if (GAMEMODE == "ZEN") { if (GAMEMODE == "ZEN") {
path = Application.persistentDataPath + "/zen/" + unixTime + ".fun"; path = Application.persistentDataPath + "/zen_" + unixTime;
} else { } else {
path = Application.persistentDataPath + "/waves/" + unixTime + ".fun"; path = Application.persistentDataPath + "/wave_" + unixTime;
} }
FileStream stream = new FileStream(path, FileMode.Create); FileStream stream = new FileStream(path, FileMode.Create);
...@@ -26,6 +26,7 @@ public static class DataManager ...@@ -26,6 +26,7 @@ public static class DataManager
formatter.Serialize(stream, data); formatter.Serialize(stream, data);
stream.Close(); stream.Close();
Debug.Log(path);
} }
public static PlayerData LoadPlayer(string GAMEMODE) { public static PlayerData LoadPlayer(string GAMEMODE) {
...@@ -35,9 +36,9 @@ public static class DataManager ...@@ -35,9 +36,9 @@ public static class DataManager
string unixTime = ((DateTimeOffset)timestamp).ToUnixTimeSeconds().ToString(); string unixTime = ((DateTimeOffset)timestamp).ToUnixTimeSeconds().ToString();
if (GAMEMODE == "ZEN") { if (GAMEMODE == "ZEN") {
path = Application.persistentDataPath + "/zen/" + unixTime + ".fun"; path = Application.persistentDataPath + "/zen_" + unixTime;
} else { } else {
path = Application.persistentDataPath + "/waves/" + unixTime + ".fun"; path = Application.persistentDataPath + "/wave_" + unixTime;
} }
if (File.Exists(path)) { if (File.Exists(path)) {
......
...@@ -26,6 +26,7 @@ public class GameOverManager : MonoBehaviour ...@@ -26,6 +26,7 @@ public class GameOverManager : MonoBehaviour
{ {
anim.SetBool("GameOver", true); anim.SetBool("GameOver", true);
isGameOver = true; isGameOver = true;
ScoreManager.isScoreOver = true;
if (!isSaved) { if (!isSaved) {
DataManager.SaveData("dummy1", ScoreManager.finalScore, "ZEN"); DataManager.SaveData("dummy1", ScoreManager.finalScore, "ZEN");
......
...@@ -8,6 +8,7 @@ public class ScoreManager : MonoBehaviour ...@@ -8,6 +8,7 @@ public class ScoreManager : MonoBehaviour
public static float score; public static float score;
public static int finalScore; public static int finalScore;
int multiplier = 1; int multiplier = 1;
public static bool isScoreOver = false;
Text text; Text text;
...@@ -21,9 +22,14 @@ public class ScoreManager : MonoBehaviour ...@@ -21,9 +22,14 @@ public class ScoreManager : MonoBehaviour
void Update () void Update ()
{ {
score += Time.deltaTime * multiplier; if (!isScoreOver) {
finalScore = (int) score; score += Time.deltaTime * multiplier;
text.text = "Score: " + String.Format("{0:0}",score); finalScore = (int) score;
text.text = "Score: " + String.Format("{0:0}",score);
} else {
text.text = "Score: " + String.Format("{0:0}",score);
}
} }
......
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