Score: Submit on GameOver

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