Saved player score with PlayerPrefs
This commit is contained in:
@@ -21,6 +21,8 @@ public class PlayerController : OrbitalPositionBehaviour
|
|||||||
protected override void OnStart()
|
protected override void OnStart()
|
||||||
{
|
{
|
||||||
s_Instance = this;
|
s_Instance = this;
|
||||||
|
s_HighScore = Mathf.Max(s_HighScore, PlayerPrefs.GetInt("HighScore", 0));
|
||||||
|
Debug.Log($"Loaded high score of [{s_HighScore}]");
|
||||||
|
|
||||||
GlobalOrbitalPositionManager.SetPlayer(m_OrbitalPosition);
|
GlobalOrbitalPositionManager.SetPlayer(m_OrbitalPosition);
|
||||||
|
|
||||||
@@ -33,6 +35,8 @@ public class PlayerController : OrbitalPositionBehaviour
|
|||||||
m_ScoreText.text = s_PlayerScore.ToString();
|
m_ScoreText.text = s_PlayerScore.ToString();
|
||||||
if (s_PlayerScore > s_HighScore)
|
if (s_PlayerScore > s_HighScore)
|
||||||
m_ScoreText.color = Color.yellow;
|
m_ScoreText.color = Color.yellow;
|
||||||
|
else
|
||||||
|
m_ScoreText.color = Color.white;
|
||||||
|
|
||||||
if (GlobalInput.IsScreenClicked && GlobalOrbitalPositionManager.AllowPlayerInput)
|
if (GlobalInput.IsScreenClicked && GlobalOrbitalPositionManager.AllowPlayerInput)
|
||||||
{
|
{
|
||||||
@@ -65,6 +69,7 @@ public class PlayerController : OrbitalPositionBehaviour
|
|||||||
m_Renderer.material.color = Color.green;
|
m_Renderer.material.color = Color.green;
|
||||||
|
|
||||||
s_HighScore = Math.Max(s_HighScore, s_PlayerScore);
|
s_HighScore = Math.Max(s_HighScore, s_PlayerScore);
|
||||||
|
PlayerPrefs.SetInt("HighScore", s_HighScore);
|
||||||
s_PlayerScore = 0;
|
s_PlayerScore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user