Score: Submit on GameOver

parent 967ec03e
...@@ -8,18 +8,17 @@ using Assets.Scripts.API; ...@@ -8,18 +8,17 @@ using Assets.Scripts.API;
public class GameOver : MonoBehaviour public class GameOver : MonoBehaviour
{ {
private float _timer = 0f; private float _timer = 0f;
private int score; private int score = 0;
private Player _player; private GameObject _player;
public InputField PlayerName; public InputField PlayerName;
public InputField TeamName; public InputField TeamName;
public Text Score; public Text Score;
public Button buttonSubmit;
public Button buttonPlay;
void Start() void Start()
{ {
_player = GameObject.FindWithTag("Player").GetComponent<Player>();
score = _player.Score;
Score.text = "You scored " + score;
} }
void Update () void Update ()
...@@ -27,6 +26,8 @@ public class GameOver : MonoBehaviour ...@@ -27,6 +26,8 @@ public class GameOver : MonoBehaviour
// _timer += Time.deltaTime; // _timer += Time.deltaTime;
// if (_timer > 4f) // if (_timer > 4f)
// SceneManager.LoadScene("Menu"); // SceneManager.LoadScene("Menu");
score = PlayerPrefs.GetInt("lastscore");
Score.text = "You scored " + score;
} }
public void OnButtonPlayClicked() public void OnButtonPlayClicked()
...@@ -40,7 +41,7 @@ public class GameOver : MonoBehaviour ...@@ -40,7 +41,7 @@ public class GameOver : MonoBehaviour
if (playerText == null || playerText.Length == 0) { if (playerText == null || playerText.Length == 0) {
playerText = "Random Randy"; playerText = "Random Randy";
} }
string teamText = PlayerName.text; string teamText = TeamName.text;
if (teamText == null || teamText.Length == 0) { if (teamText == null || teamText.Length == 0) {
teamText = null; teamText = null;
} }
......
...@@ -34,6 +34,7 @@ namespace Assets.Scripts ...@@ -34,6 +34,7 @@ namespace Assets.Scripts
{ {
if (PlayerPrefs.GetInt("highscore") < Score) if (PlayerPrefs.GetInt("highscore") < Score)
PlayerPrefs.SetInt("highscore", Score); PlayerPrefs.SetInt("highscore", Score);
PlayerPrefs.SetInt("lastscore", Score);
SceneManager.LoadScene("GameOver"); SceneManager.LoadScene("GameOver");
} }
......
Markdown is supported
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