HomeButtonHandler.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * FUNCTION: Handle what the back button will do on each menu.
  3. * USED BY: This script is a part of the Back button component located in
  4. * each menu.
  5. * */
  6. using UnityEngine;
  7. using System.Collections;
  8. public class HomeButtonHandler : MonoBehaviour {
  9. private NGUIMenuScript hNGUIMenuScript;
  10. private InGameScriptCS hInGameScriptCS;
  11. void Start ()
  12. {
  13. hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
  14. hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
  15. }
  16. void OnClick()
  17. {
  18. if (hNGUIMenuScript.getCurrentMenu() == NGUIMenuScript.NGUIMenus.GameOver)//if this is GameOver menu
  19. hInGameScriptCS.procesClicksDeathMenu(MenuScriptCS.GameOverMenuEvents.Back);
  20. else if (hNGUIMenuScript.getCurrentMenu() == NGUIMenuScript.NGUIMenus.PauseMenu)//if this is Pause menu
  21. hInGameScriptCS.processClicksPauseMenu(MenuScriptCS.PauseMenuEvents.MainMenu);
  22. else if (hNGUIMenuScript.getCurrentMenu() == NGUIMenuScript.NGUIMenus.ShopCostumes//if Shop Costumes menu is active
  23. || hNGUIMenuScript.getCurrentMenu() == NGUIMenuScript.NGUIMenus.ShopIAPs//if Shop IAPs menu is active
  24. || hNGUIMenuScript.getCurrentMenu() == NGUIMenuScript.NGUIMenus.ShopPowerups//if Shop Powerups menu is active
  25. || hNGUIMenuScript.getCurrentMenu() == NGUIMenuScript.NGUIMenus.ShopUtilities)//if Shop Utilities menu is active
  26. {
  27. hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.ShopHome);//show the Shop Home menu
  28. NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu
  29. }
  30. else
  31. {
  32. hNGUIMenuScript.ShowMenu(NGUIMenuScript.NGUIMenus.MainMenuNew);//show the main menu
  33. NGUITools.SetActive(this.transform.parent.gameObject, false);//hide the current menu
  34. }//end of else
  35. } //end of OnClick function
  36. }