mirror of
https://github.com/Fluffy-Bean/Again.git
synced 2025-07-01 05:26:16 +00:00
Fixed score reset and highscore check
This commit is contained in:
parent
1a641f3c6f
commit
ed68280480
4 changed files with 21 additions and 8 deletions
|
@ -10,7 +10,6 @@ public class endTrigger : MonoBehaviour
|
||||||
if (other.gameObject.CompareTag("Player"))
|
if (other.gameObject.CompareTag("Player"))
|
||||||
{
|
{
|
||||||
SceneManager.LoadScene("end");
|
SceneManager.LoadScene("end");
|
||||||
SceneManager.UnloadSceneAsync("game");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,16 @@ using TMPro;
|
||||||
public class highScoreCheck : MonoBehaviour
|
public class highScoreCheck : MonoBehaviour
|
||||||
{
|
{
|
||||||
TextMeshProUGUI textBox;
|
TextMeshProUGUI textBox;
|
||||||
public float highScore = 0;
|
public float lowestTime;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
highScore = PlayerPrefs.GetFloat("highScore");
|
|
||||||
if (highScore > PlayerPrefs.GetFloat("timeScore"))
|
if (PlayerPrefs.GetFloat("lowestTime") > PlayerPrefs.GetFloat("timeScore"))
|
||||||
{
|
{
|
||||||
PlayerPrefs.SetFloat("highScore",PlayerPrefs.GetFloat("timeScore"));
|
PlayerPrefs.SetFloat("lowestTime",PlayerPrefs.GetFloat("timeScore"));
|
||||||
highScore = PlayerPrefs.GetFloat("timeScore");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textBox = GetComponent<TextMeshProUGUI>();
|
textBox = GetComponent<TextMeshProUGUI>();
|
||||||
textBox.SetText("Shortest Time: {0}s", highScore);
|
textBox.SetText("Shortest Time: {0}s", PlayerPrefs.GetFloat("lowestTime"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ public class levelLoader : MonoBehaviour
|
||||||
{
|
{
|
||||||
public void NextLevel()
|
public void NextLevel()
|
||||||
{
|
{
|
||||||
|
if (SceneManager.GetActiveScene().name == "menu")
|
||||||
|
{
|
||||||
|
PlayerPrefs.SetFloat("lowestTime",9999f);
|
||||||
|
}
|
||||||
SceneManager.LoadScene("game");
|
SceneManager.LoadScene("game");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
scoreReset.cs
Normal file
12
scoreReset.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
public class scoreReset : MonoBehaviour
|
||||||
|
{
|
||||||
|
public void SendBack()
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene("menu");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue