83 lines
2.4 KiB
C#
83 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Google;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
public class MainMenu : MonoBehaviour
|
|
{
|
|
|
|
public GameObject MainMenuPanel;
|
|
public GameObject SettingsPanel;
|
|
public float transitionTime;
|
|
public LeanTweenType transitionEffect;
|
|
|
|
private Vector2 defaultCenter;
|
|
public Button copyBtn, muteBtn;
|
|
public Button signoutBtn;
|
|
public Sprite muteIcon, unmuteIcon;
|
|
|
|
|
|
public Text txtUserId;
|
|
|
|
void Awake(){
|
|
if(!DataManager.isLogged){
|
|
SceneManager.LoadScene(0);
|
|
return;
|
|
}
|
|
defaultCenter = MainMenuPanel.transform.position;
|
|
SettingsPanel.transform.position = MainMenuPanel.transform.position - new Vector3(3000,0);
|
|
SettingsPanel.SetActive(true);
|
|
|
|
muteBtn.onClick.AddListener(ToggleMute);
|
|
copyBtn.onClick.AddListener(CopyId);
|
|
signoutBtn.onClick.AddListener(SignOut);
|
|
}
|
|
public void Leave(){
|
|
Application.Quit();
|
|
}
|
|
|
|
void Start(){
|
|
Refresh();
|
|
// MessageBox.ShowMessage("Welcome to Infinite Golf 2D.\nThis is a slow paced 2d endless golf game, All the levels are proceduraly generated and you will be rewarded for putting the ball in every and each hole.\n\nGood Luck","Welcome");
|
|
}
|
|
|
|
|
|
void Refresh(){
|
|
txtUserId.text = DataManager.userData.id.ToString();
|
|
if(AudioManager.isMute){
|
|
muteBtn.transform.GetChild(0).GetComponent<Image>().sprite = muteIcon;
|
|
}else{
|
|
muteBtn.transform.GetChild(0).GetComponent<Image>().sprite = unmuteIcon;
|
|
}
|
|
}
|
|
|
|
public void SettingsPage(){
|
|
LeanTween.moveX(MainMenuPanel, 10000, transitionTime).setEase(transitionEffect);
|
|
LeanTween.moveX(SettingsPanel, defaultCenter.x, transitionTime).setEase(transitionEffect);
|
|
}
|
|
|
|
public void MainPage(){
|
|
LeanTween.moveX(MainMenuPanel, defaultCenter.x, transitionTime).setEase(transitionEffect);
|
|
LeanTween.moveX(SettingsPanel, -10000, transitionTime).setEase(transitionEffect);
|
|
}
|
|
|
|
public void CopyId(){
|
|
GUIUtility.systemCopyBuffer = DataManager.userData.id.ToString();
|
|
copyBtn.transform.Find("lbl").GetComponent<Text>().text = "Copied";
|
|
}
|
|
|
|
public void ToggleMute(){
|
|
AudioManager.ToggleMute();
|
|
Refresh();
|
|
}
|
|
|
|
|
|
void SignOut(){
|
|
|
|
|
|
DataManager.Signout();
|
|
SceneManager.LoadScene(0);
|
|
}
|
|
}
|