123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using UnityEngine;
- using System.Collections;
- public class InstructionsHomeButtonHandler : MonoBehaviour {
- private NGUIMenuScript hNGUIMenuScript;
- private InGameScriptCS hInGameScriptCS;
- public UISprite Backgroung;
- public static bool FirstPlay
- {
- get
- {
- if (GameObject.Find("InfinitelyTraining"))
- {
- return true;
- }
- if (!PlayerPrefs.HasKey("FirstPlay"))
- {
- return false;
- }
- return PlayerPrefs.GetInt("FirstPlay", 1) == 1;
- }
- set
- {
- PlayerPrefs.SetInt("FirstPlay",value?1:0);
- PlayerPrefs.Save();
- }
- }
- void Start()
- {
- hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
- hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
- }
- void Update()
- {
- Backgroung.gameObject.SetActive(!FirstPlay);
- }
- void OnClick()
- {
- //hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenu);//show the main menu
- //NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu
- if (!FirstPlay)
- {
- hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenuNew);//show the main menu
- NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu
- Debug.LogWarning("HERE");
- }
- else
- {
- Debug.LogWarning("HERE");
- FirstPlay = false;
- hInGameScriptCS.launchGame(); //start the gameplay
- hNGUIMenuScript.NGUIMenuScriptEnabled(false);//turn off the NGUI Menu Script (to improve performance)
- NGUITools.SetActive(this.transform.parent.gameObject, false);//close/ disable the current menu
- }
- }
- }
|