45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using Code.GameplayServices;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Code.UI
|
|
{
|
|
public class RestartPanel : MonoBehaviour
|
|
{
|
|
[SerializeField] private Button restartButton;
|
|
[SerializeField] private Button showScoresPanel;
|
|
[SerializeField] private ScoreTable scoreTable;
|
|
[SerializeField] private TMP_Text scoreText;
|
|
|
|
private void Awake()
|
|
{
|
|
restartButton.onClick.AddListener(RestartGame);
|
|
showScoresPanel.onClick.AddListener(PlayerScoreService.Instance.ShowScoreTable);
|
|
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
restartButton.onClick.RemoveListener(RestartGame);
|
|
showScoresPanel.onClick.RemoveListener(PlayerScoreService.Instance.ShowScoreTable);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
ShowScore();
|
|
}
|
|
|
|
private void ShowScore()
|
|
{
|
|
scoreText.text = PlayerScoreService.Instance.Score.ToString();
|
|
}
|
|
|
|
private void RestartGame()
|
|
{
|
|
GameplayManager.Instance.RestartGame();
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
} |