47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
public class MenuManager : MonoBehaviour
|
|
{
|
|
public Text txtUsername;
|
|
public Text txtBest;
|
|
public Text txtMoney;
|
|
|
|
public Button playBtn;
|
|
public Button leaderboardBtn;
|
|
public Leaderboard leaderboard;
|
|
public static MenuManager instance;
|
|
void Start()
|
|
{
|
|
instance = this;
|
|
if(!DataManager.LoggedIn){SceneManager.LoadScene(0); return;}
|
|
Refresh();
|
|
|
|
playBtn.onClick.AddListener(OnPlay);
|
|
leaderboardBtn.onClick.AddListener(OnLeaderboardBtn);
|
|
}
|
|
|
|
void OnPlay(){
|
|
SceneManager.LoadScene(2);
|
|
}
|
|
|
|
void OnLeaderboardBtn(){
|
|
leaderboard.Show();
|
|
}
|
|
|
|
public static void Refresh(){
|
|
if(instance != null){
|
|
instance.refresh();
|
|
}
|
|
}
|
|
|
|
void refresh(){
|
|
|
|
txtUsername.text = txtUsername.text.Replace("{username}", DataManager.Username);
|
|
txtBest.text = "Personal Best : " + (PlayerPrefs.HasKey("best") ? PlayerPrefs.GetInt("best") : 0) + " m";
|
|
txtMoney.text = "$"+ DataManager.Money;
|
|
}
|
|
}
|