InstructionsHomeButtonHandler.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using UnityEngine;
  2. using System.Collections;
  3. public class InstructionsHomeButtonHandler : MonoBehaviour {
  4. private NGUIMenuScript hNGUIMenuScript;
  5. private InGameScriptCS hInGameScriptCS;
  6. public UISprite Backgroung;
  7. public static bool FirstPlay
  8. {
  9. get
  10. {
  11. if (GameObject.Find("InfinitelyTraining"))
  12. {
  13. return true;
  14. }
  15. if (!PlayerPrefs.HasKey("FirstPlay"))
  16. {
  17. return false;
  18. }
  19. return PlayerPrefs.GetInt("FirstPlay", 1) == 1;
  20. }
  21. set
  22. {
  23. PlayerPrefs.SetInt("FirstPlay",value?1:0);
  24. PlayerPrefs.Save();
  25. }
  26. }
  27. void Start()
  28. {
  29. hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
  30. hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
  31. }
  32. void Update()
  33. {
  34. Backgroung.gameObject.SetActive(!FirstPlay);
  35. }
  36. void OnClick()
  37. {
  38. //hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenu);//show the main menu
  39. //NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu
  40. if (!FirstPlay)
  41. {
  42. hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenuNew);//show the main menu
  43. NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu
  44. Debug.LogWarning("HERE");
  45. }
  46. else
  47. {
  48. Debug.LogWarning("HERE");
  49. FirstPlay = false;
  50. hInGameScriptCS.launchGame(); //start the gameplay
  51. hNGUIMenuScript.NGUIMenuScriptEnabled(false);//turn off the NGUI Menu Script (to improve performance)
  52. NGUITools.SetActive(this.transform.parent.gameObject, false);//close/ disable the current menu
  53. }
  54. }
  55. }