// Update is called once per frame void Update() { //if currently pointing to RESUME if (currPointing == currOption_Pause.RESUME) { //if press up or down if (XCI.GetButtonDown(XboxButton.DPadUp, controller) || XCI.GetButtonDown(XboxButton.DPadDown, controller)) { //change currPointing to MAIN MENU currPointing = currOption_Pause.MAINMENU; //Unhighlight RESUME sprite resumeSprite.sprite = resumeSpriteList[0]; //highlight QUIT MAIN MENU mainMenuSprite.sprite = mainMenuSpriteList[1]; //Display current status in console Debug.Log("Moving away from Resume"); } //if press A, resume the game if (XCI.GetButtonDown(XboxButton.A)) { gameManager.SwitchGameState(GameStateID.InGameMuilti); } } //if currently pointing to MAIN MENU else if (currPointing == currOption_Pause.MAINMENU) { //if press up or down if (XCI.GetButtonDown(XboxButton.DPadUp, controller) || XCI.GetButtonDown(XboxButton.DPadDown, controller)) { //change currPointing to RESUME currPointing = currOption_Pause.RESUME; //highlight RESUME sprite resumeSprite.sprite = resumeSpriteList[1]; //Unhighlight QUIT MAIN MENU mainMenuSprite.sprite = mainMenuSpriteList[0]; //Display current status in console Debug.Log("Moving away from Main Menu"); } //if press A, go back to Main Manu (reload the entire scene) if (XCI.GetButtonDown(XboxButton.A)) { SceneManager.LoadScene("CrusHour_Multiplayer"); } } }
// Use this for initialization void Start() { //get game manager gameManager = GameObject.Find("GameManager").GetComponent <GameStateManagerScript>(); //Arrays for storing Resources sprites resumeSpriteList = Resources.LoadAll <Sprite>("PauseResumeSprites"); mainMenuSpriteList = Resources.LoadAll <Sprite>("PauseMainMenuSprites"); //assign Resume sprite resumeSprite = gameObject.transform.Find("resume").GetComponent <Image>(); //assign Main Menu sprite mainMenuSprite = gameObject.transform.Find("mainMenu").GetComponent <Image>(); //initialize which sprite to assign to each option (1 = highlighted sprite, 0 = not highlighted sprite) resumeSprite.sprite = resumeSpriteList[1]; mainMenuSprite.sprite = mainMenuSpriteList[0]; //set current pointing to RESUME currPointing = currOption_Pause.RESUME; }
//Vector3 controllerMovement; // Use this for initialization void Awake() { //Load all UI Objects in Scene loadUIObjects(); GM = GameObject.Find("GameManager").GetComponent <Manager>(); //------ Load Main Menu Sprites from Resource ------// startSpriteList_MainMenu = Resources.LoadAll <Sprite>("StartSprites_MainMenu"); exitSpriteList_MainMenu = Resources.LoadAll <Sprite>("ExitSprites_MainMenu"); //------ Load Pause Sprites from Resource ------// resumeSpriteList_Pause = Resources.LoadAll <Sprite>("ResumeSprites_Pause"); mainMenuSpriteList_Pause = Resources.LoadAll <Sprite>("MainMenuSprites_Pause"); exitSpriteList_Pause = Resources.LoadAll <Sprite>("ExitSprites_Pause"); //------ Load Next Sprites from Resource ------// nextSpriteList_Next = Resources.LoadAll <Sprite>("NextSprites_Next"); mainMenuSpriteList_Next = Resources.LoadAll <Sprite>("MainMenuSprites_Next"); exitSpriteList_Next = Resources.LoadAll <Sprite>("ExitSprites_Next"); //------ Setup Main Menu's buttons' references ------// startSprite_MainMenu = GameObject.Find("StartButton_Main").GetComponent <Image>(); exitSprite_MainMenu = GameObject.Find("ExitButton_Main").GetComponent <Image>(); //initialize which sprite to assign to each option(1 = highlighted sprite, 0 = not highlighted sprite) startSprite_MainMenu.sprite = startSpriteList_MainMenu[1]; exitSprite_MainMenu.sprite = exitSpriteList_MainMenu[0]; //------ Setup Pause's buttons' reference ------// resumeSprite_Pause = GameObject.Find("ResumeButton_Pause").GetComponent <Image>(); mainMenuSprite_Pause = GameObject.Find("MainMenuButton_Pause").GetComponent <Image>(); exitSprite_Pause = GameObject.Find("ExitButton_Pause").GetComponent <Image>(); //initialize which sprite to assign to each option (1 = highlighted sprite, 0 = not highlighted sprite) resumeSprite_Pause.sprite = resumeSpriteList_Pause[1]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0]; exitSprite_Pause.sprite = exitSpriteList_Pause[0]; //------ Setup Players' scores' reference ------// player1ScoreText = GameObject.Find("Player1Score").GetComponent <Text>(); player2ScoreText = GameObject.Find("Player2Score").GetComponent <Text>(); player1Score = 0; player2Score = 0; //------ Setup Next's buttons' reference ------// nextSprite_Next = GameObject.Find("NextButton_Next").GetComponent <Image>(); mainMenuSprite_Next = GameObject.Find("MainMenuButton_Next").GetComponent <Image>(); exitSprite_Next = GameObject.Find("ExitButton_Next").GetComponent <Image>(); //initialize which sprite to assign to each option (1 = highlighted sprite, 0 = not highlighted sprite) nextSprite_Next.sprite = nextSpriteList_Next[1]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0]; exitSprite_Next.sprite = exitSpriteList_Next[0]; //set current pointing in Main Menu to START currPointing_MainMenu = currOption_MainMenu.START; //set current pointing in Pause to RESUME currPointing_Pause = currOption_Pause.RESUME; ////set current pointing in Pause to NEXT currPointing_Next = currOption_Next.NEXT; //------ All UI Elements Loaded, turn off IngameUI and PauseUI ------// uiObjects[0].SetActive(true); //main menu uiObjects[1].SetActive(false); //ingame uiObjects[2].SetActive(false); //pause uiObjects[3].SetActive(false); //next }
// Update is called once per frame void Update() { if (uiObjects[0].activeInHierarchy) //if currently at MAIN MENU State { Time.timeScale = 0; if (currPointing_MainMenu == currOption_MainMenu.START) { if (XCI.GetButtonDown(XboxButton.DPadUp, controller) || XCI.GetButtonDown(XboxButton.DPadDown, controller)) { startSprite_MainMenu.sprite = startSpriteList_MainMenu[0]; exitSprite_MainMenu.sprite = exitSpriteList_MainMenu[1]; currPointing_MainMenu = currOption_MainMenu.EXIT; } if (XCI.GetButtonDown(XboxButton.B, controller)) { switchGameState(gameState.INGAME); } } else if (currPointing_MainMenu == currOption_MainMenu.EXIT) { if (XCI.GetButtonDown(XboxButton.DPadUp, controller) || XCI.GetButtonDown(XboxButton.DPadDown, controller)) { startSprite_MainMenu.sprite = startSpriteList_MainMenu[1]; exitSprite_MainMenu.sprite = exitSpriteList_MainMenu[0]; currPointing_MainMenu = currOption_MainMenu.START; } if (XCI.GetButtonDown(XboxButton.B, controller)) { Application.Quit(); } } } if (uiObjects[1].activeInHierarchy) //if currently at INGAME State { Time.timeScale = 1; player1ScoreText.text = player1Score.ToString(); player2ScoreText.text = player2Score.ToString(); if (XCI.GetButtonDown(XboxButton.Start, controller)) { switchGameState(gameState.PAUSE); } } if (uiObjects[2].activeInHierarchy) //if currently at PAUSE State { Time.timeScale = 0; if (currPointing_Pause == currOption_Pause.RESUME) { if (XCI.GetButtonDown(XboxButton.B, controller)) { switchGameState(gameState.INGAME); } if (XCI.GetButtonDown(XboxButton.DPadUp, controller)) { currPointing_Pause = currOption_Pause.EXIT; resumeSprite_Pause.sprite = resumeSpriteList_Pause[0]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0]; exitSprite_Pause.sprite = exitSpriteList_Pause[1]; } if (XCI.GetButtonDown(XboxButton.DPadDown, controller)) { currPointing_Pause = currOption_Pause.MAIN; resumeSprite_Pause.sprite = resumeSpriteList_Pause[0]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[1]; exitSprite_Pause.sprite = exitSpriteList_Pause[0]; } } else if (currPointing_Pause == currOption_Pause.MAIN) { if (XCI.GetButtonDown(XboxButton.B, controller)) { switchGameState(gameState.MAIN); } if (XCI.GetButtonDown(XboxButton.DPadUp, controller)) { currPointing_Pause = currOption_Pause.RESUME; resumeSprite_Pause.sprite = resumeSpriteList_Pause[1]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0]; exitSprite_Pause.sprite = exitSpriteList_Pause[0]; } if (XCI.GetButtonDown(XboxButton.DPadDown, controller)) { currPointing_Pause = currOption_Pause.EXIT; resumeSprite_Pause.sprite = resumeSpriteList_Pause[0]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0]; exitSprite_Pause.sprite = exitSpriteList_Pause[1]; } } else if (currPointing_Pause == currOption_Pause.EXIT) { if (XCI.GetButtonDown(XboxButton.B, controller)) { Application.Quit(); } if (XCI.GetButtonDown(XboxButton.DPadUp, controller)) { currPointing_Pause = currOption_Pause.MAIN; resumeSprite_Pause.sprite = resumeSpriteList_Pause[0]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[1]; exitSprite_Pause.sprite = exitSpriteList_Pause[0]; } if (XCI.GetButtonDown(XboxButton.DPadDown, controller)) { currPointing_Pause = currOption_Pause.RESUME; resumeSprite_Pause.sprite = resumeSpriteList_Pause[1]; mainMenuSprite_Pause.sprite = mainMenuSpriteList_Pause[0]; exitSprite_Pause.sprite = exitSpriteList_Pause[0]; } } } if (uiObjects[3].activeInHierarchy) //if currently at In NEXT State { Time.timeScale = 0; if (currPointing_Next == currOption_Next.NEXT) { if (XCI.GetButtonDown(XboxButton.B, controller)) { switchGameState(gameState.INGAME); GM.refreshStage(); } if (XCI.GetButtonDown(XboxButton.DPadUp, controller)) { currPointing_Next = currOption_Next.EXIT; nextSprite_Next.sprite = nextSpriteList_Next[0]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0]; exitSprite_Next.sprite = exitSpriteList_Next[1]; } if (XCI.GetButtonDown(XboxButton.DPadDown, controller)) { currPointing_Next = currOption_Next.MAIN; nextSprite_Next.sprite = nextSpriteList_Next[0]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[1]; exitSprite_Next.sprite = exitSpriteList_Next[0]; } } else if (currPointing_Next == currOption_Next.MAIN) { if (XCI.GetButtonDown(XboxButton.B, controller)) { switchGameState(gameState.MAIN); } if (XCI.GetButtonDown(XboxButton.DPadUp, controller)) { currPointing_Next = currOption_Next.NEXT; nextSprite_Next.sprite = nextSpriteList_Next[1]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0]; exitSprite_Next.sprite = exitSpriteList_Next[0]; } if (XCI.GetButtonDown(XboxButton.DPadDown, controller)) { currPointing_Next = currOption_Next.EXIT; nextSprite_Next.sprite = nextSpriteList_Next[0]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0]; exitSprite_Next.sprite = exitSpriteList_Next[1]; } } else if (currPointing_Next == currOption_Next.EXIT) { if (XCI.GetButtonDown(XboxButton.B, controller)) { Application.Quit(); } if (XCI.GetButtonDown(XboxButton.DPadUp, controller)) { currPointing_Next = currOption_Next.MAIN; nextSprite_Next.sprite = nextSpriteList_Next[0]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[1]; exitSprite_Next.sprite = exitSpriteList_Next[0]; } if (XCI.GetButtonDown(XboxButton.DPadDown, controller)) { currPointing_Next = currOption_Next.NEXT; nextSprite_Next.sprite = nextSpriteList_Next[1]; mainMenuSprite_Next.sprite = mainMenuSpriteList_Next[0]; exitSprite_Next.sprite = exitSpriteList_Next[0]; } } } }