Store WIP
This commit is contained in:
51
Assets/Scripts/MenuManager.cs
Normal file
51
Assets/Scripts/MenuManager.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
public class MenuManager : MonoBehaviour
|
||||
{
|
||||
public Text txtUsername;
|
||||
public Text txtMoney;
|
||||
|
||||
public Button playBtn;
|
||||
public Button storeBtn;
|
||||
public Button leaderboardBtn;
|
||||
public Leaderboard leaderboard;
|
||||
public Store store;
|
||||
public static MenuManager instance;
|
||||
void Start()
|
||||
{
|
||||
instance = this;
|
||||
if(!DataManager.LoggedIn){SceneManager.LoadScene(0); return;}
|
||||
Refresh();
|
||||
|
||||
playBtn.onClick.AddListener(OnPlay);
|
||||
storeBtn.onClick.AddListener(OnStoreBtn);
|
||||
leaderboardBtn.onClick.AddListener(OnLeaderboardBtn);
|
||||
}
|
||||
|
||||
void OnPlay(){
|
||||
SceneManager.LoadScene(2);
|
||||
}
|
||||
|
||||
void OnStoreBtn(){
|
||||
store.Show();
|
||||
}
|
||||
|
||||
void OnLeaderboardBtn(){
|
||||
leaderboard.Show();
|
||||
}
|
||||
|
||||
public static void Refresh(){
|
||||
if(instance != null){
|
||||
instance.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void refresh(){
|
||||
|
||||
txtUsername.text = txtUsername.text.Replace("{username}", DataManager.Username);
|
||||
txtMoney.text = "$" + DataManager.total.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user