TapToPlayHandler.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * FUNCTION: Handles what happens when the Tap to play button is tapped.
  3. * The button is located in the Main Menu.
  4. * */
  5. using UnityEngine;
  6. using System.Collections;
  7. public class TapToPlayHandler : MonoBehaviour {
  8. private InGameScriptCS hInGameScriptCS;
  9. private NGUIMenuScript hNGUIMenuScript;
  10. void Start()
  11. {
  12. hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
  13. hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
  14. }
  15. void OnClick()
  16. {
  17. //Debug.Log("OnClck");
  18. if (!ConnectivityPollManager.HasInternet)
  19. {
  20. LoginManager.Instance.WrongConnectMessages.Show();
  21. //FacebookDialogManager.Instance.ShowAppropriateDialog();
  22. hNGUIMenuScript.CloseMenu(NGUIMenuScript.NGUIMenus.MainMenuNew);
  23. return;
  24. }
  25. /*if (!FacebookHelper.Instance.IsLoggedIn() && ConnectivityPollManager.HasInternet)
  26. {
  27. hNGUIMenuScript.CloseMenu(NGUIMenuScript.NGUIMenus.MainMenu);
  28. hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.LoginFacebook);
  29. return;
  30. }*/
  31. if (!InstructionsHomeButtonHandler.FirstPlay)
  32. {
  33. hInGameScriptCS.launchGame(); //start the gameplay
  34. //hNGUIMenuScript.NGUIMenuScriptEnabled(false);//turn off the NGUI Menu Script (to improve performance)
  35. }
  36. else
  37. {
  38. hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.InstructionsMenu);
  39. }
  40. if (UISendGreetings.Visible)
  41. {
  42. return;
  43. }
  44. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.RaceStart);
  45. NGUITools.SetActive(this.transform.parent.gameObject, false);//close/ disable the current menu
  46. }
  47. }