using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class MainMenu : MonoBehaviour { public Text[] txtStats; public GameObject LinkPanel; public InputField FHIdInput; public void OnPlay(){ LoadingScreen.LoadLevel("Game"); } public void OnQuit(){ Application.Quit(); } void Start() { if(!DataManager.isLogged){Application.LoadLevel(0);} foreach(Text txtStat in txtStats){ txtStat.text = txtStat.text.Replace("{score}",DataManager.userData.score).Replace("{top_score}",DataManager.userData.top_score).Replace("{play_time}",Helpers.SecondsToTime(int.Parse(DataManager.userData.play_time),showSeconds:false)).Replace("{asteroids}",DataManager.userData.asteroids).Replace("{near_miss}",DataManager.userData.near_miss).Replace("{total_games}",DataManager.userData.total_games); } } public void OnLinkPanelOpen(){ if(DataManager.userData.faucet_id > 0){ MessageBox.ShowMessage("This account has already linked to FH ID: " + DataManager.userData.faucet_id,"Already Linked"); return; }else{ LinkPanel.SetActive(true); } } public async void OnLink(){ if(FHIdInput.text.Length <=0){ MessageBox.ShowMessage("Please enter the FH ID to Link","Invalid"); return; } int fhid =-1; try{ fhid = int.Parse(FHIdInput.text); }catch{ MessageBox.ShowMessage("Please enter a valid number","Invalid Number"); return; } if(fhid < 0){return;} LinkPanel.SetActive(false); int result = await DataManager.LinkFH(fhid.ToString()); if(result==0)MessageBox.ShowMessage( "This account has been successfully linked to FH ID " + DataManager.userData.faucet_id,"Success"); } public void OnSignout(){ DataManager.Signout(); LoadingScreen.LoadLevel("Login"); } }