private void CheckTouch3(Vector3 pos) { Vector3 wp = Camera.main.ScreenToWorldPoint(pos); Vector2 touchPos = new Vector2(wp.x, wp.y); hit3 = Physics2D.OverlapPoint(touchPos); if (hit3 != null && hit3.gameObject.tag == "Pause Button") { if (!buttonClickUp) { soundHandler.PlayButtonClickUp(); } else { buttonClickUp = false; } touchHandler.PauseTouch(); Time.timeScale = 0; if (buttonHandler.GetD() == null) { buttonHandler.SetD((GameObject)Instantiate(letterD, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .01f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetD().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetE() == null) { buttonHandler.SetE((GameObject)Instantiate(letterE, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .02f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetE().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetS() == null) { buttonHandler.SetS((GameObject)Instantiate(letterS, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .03f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetS().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetU() == null) { buttonHandler.SetU((GameObject)Instantiate(letterU, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .04f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetU().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetA() == null) { buttonHandler.SetA((GameObject)Instantiate(letterA, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .05f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetA().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetP() == null) { buttonHandler.SetP((GameObject)Instantiate(letterP, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .05f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetP().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (GameObject.Find("Paused Shade(Clone)") == null) { instantiatedPausedShade = (GameObject)Instantiate(pausedShade); } else { instantiatedPausedShade = GameObject.Find("Paused Shade(Clone)"); } shadeHandler = instantiatedPausedShade.GetComponent <PausedShadeHandler> (); shadeHandler.MakeVisible(); Instantiate(playButton, gameObject.transform.position, Quaternion.identity); if (buttonHandler.GetMusicButton() == null) { if (GameObject.Find("Game Manager").GetComponent <GameManagerScript> ().GetMusicState()) { buttonHandler.SetMusicButton((GameObject)Instantiate(musicButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .01f), Quaternion.identity)); } else { buttonHandler.SetMusicButton((GameObject)Instantiate(musicOffButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .01f), Quaternion.identity)); } } else if (buttonHandler.GetMusicButton() != null) { MusicButtonHandler musicButtonHandler = buttonHandler.GetMusicButton().GetComponent <MusicButtonHandler> (); musicButtonHandler.LeaveHome(); } if (buttonHandler.GetSoundButton() == null) { if (GameObject.Find("Game Manager").GetComponent <GameManagerScript> ().GetSoundState()) { buttonHandler.SetSoundButton((GameObject)Instantiate(soundButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .02f), Quaternion.identity)); } else { buttonHandler.SetSoundButton((GameObject)Instantiate(soundOffButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .02f), Quaternion.identity)); } } else if (buttonHandler.GetSoundButton() != null) { SoundButtonHandler soundButtonHandler = buttonHandler.GetSoundButton().GetComponent <SoundButtonHandler> (); soundButtonHandler.LeaveHome(); } // if (buttonHandler.GetRestartButton () == null) // buttonHandler.SetRestartButton ((GameObject)Instantiate (restartButton, new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .03f), Quaternion.identity)); // else if (buttonHandler.GetRestartButton () != null) { // RestartButtonHandler restartButtonHandler = buttonHandler.GetRestartButton ().GetComponent<RestartButtonHandler> (); // restartButtonHandler.LeaveHome (); // } if (buttonHandler.GetQuitButton() == null) { buttonHandler.SetQuitButton((GameObject)Instantiate(quitButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .04f), Quaternion.identity)); } else if (buttonHandler.GetQuitButton() != null) { QuitButtonHandler quitButtonHandler = buttonHandler.GetQuitButton().GetComponent <QuitButtonHandler> (); quitButtonHandler.LeaveHome(); } if (buttonHandler.GetBuyCoinsButton() == null) { buttonHandler.SetBuyCoinsButton((GameObject)Instantiate(buyCoinsButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .04f), Quaternion.identity)); } else if (buttonHandler.GetBuyCoinsButton() != null) { //Debug.Log ("Ordering buyCoinsButton to leave home"); BuyCoinsButtonHandler buyCoinsButtonHandler = buttonHandler.GetBuyCoinsButton().GetComponent <BuyCoinsButtonHandler> (); buyCoinsButtonHandler.LeaveHome(); } Destroy(gameObject); } }
public void PauseGameRemotely() { touchHandler.PauseTouch(); Time.timeScale = 0; if (buttonHandler.GetD() == null) { buttonHandler.SetD((GameObject)Instantiate(letterD, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .01f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetD().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetE() == null) { buttonHandler.SetE((GameObject)Instantiate(letterE, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .02f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetE().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetS() == null) { buttonHandler.SetS((GameObject)Instantiate(letterS, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .03f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetS().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetU() == null) { buttonHandler.SetU((GameObject)Instantiate(letterU, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .04f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetU().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetA() == null) { buttonHandler.SetA((GameObject)Instantiate(letterA, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .05f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetA().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (buttonHandler.GetP() == null) { buttonHandler.SetP((GameObject)Instantiate(letterP, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .05f), Quaternion.identity)); } pausedWordHandler = buttonHandler.GetP().GetComponent <PausedWordHandler> (); pausedWordHandler.LeaveHome(); if (GameObject.Find("Paused Shade(Clone)") == null) { instantiatedPausedShade = (GameObject)Instantiate(pausedShade); } else { instantiatedPausedShade = GameObject.Find("Paused Shade(Clone)"); } shadeHandler = instantiatedPausedShade.GetComponent <PausedShadeHandler> (); shadeHandler.MakeVisible(); Instantiate(playButton, gameObject.transform.position, Quaternion.identity); if (buttonHandler.GetMusicButton() == null) { if (GameObject.Find("Game Manager").GetComponent <GameManagerScript> ().GetMusicState()) { buttonHandler.SetMusicButton((GameObject)Instantiate(musicButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .01f), Quaternion.identity)); } else { buttonHandler.SetMusicButton((GameObject)Instantiate(musicOffButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .01f), Quaternion.identity)); } } else if (buttonHandler.GetMusicButton() != null) { MusicButtonHandler musicButtonHandler = buttonHandler.GetMusicButton().GetComponent <MusicButtonHandler> (); musicButtonHandler.LeaveHome(); } if (buttonHandler.GetSoundButton() == null) { if (GameObject.Find("Game Manager").GetComponent <GameManagerScript> ().GetSoundState()) { buttonHandler.SetSoundButton((GameObject)Instantiate(soundButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .02f), Quaternion.identity)); } else { buttonHandler.SetSoundButton((GameObject)Instantiate(soundOffButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .02f), Quaternion.identity)); } } else if (buttonHandler.GetSoundButton() != null) { SoundButtonHandler soundButtonHandler = buttonHandler.GetSoundButton().GetComponent <SoundButtonHandler> (); soundButtonHandler.LeaveHome(); } // if (buttonHandler.GetRestartButton () == null) // buttonHandler.SetRestartButton ((GameObject)Instantiate (restartButton, new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .03f), Quaternion.identity)); // else if (buttonHandler.GetRestartButton () != null) { // RestartButtonHandler restartButtonHandler = buttonHandler.GetRestartButton ().GetComponent<RestartButtonHandler> (); // restartButtonHandler.LeaveHome (); // } if (buttonHandler.GetQuitButton() == null) { buttonHandler.SetQuitButton((GameObject)Instantiate(quitButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .04f), Quaternion.identity)); } else if (buttonHandler.GetQuitButton() != null) { QuitButtonHandler quitButtonHandler = buttonHandler.GetQuitButton().GetComponent <QuitButtonHandler> (); quitButtonHandler.LeaveHome(); } if (buttonHandler.GetBuyCoinsButton() == null) { buttonHandler.SetBuyCoinsButton((GameObject)Instantiate(buyCoinsButton, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z + .04f), Quaternion.identity)); } else if (buttonHandler.GetBuyCoinsButton() != null) { //Debug.Log ("Ordering buyCoinsButton to leave home"); BuyCoinsButtonHandler buyCoinsButtonHandler = buttonHandler.GetBuyCoinsButton().GetComponent <BuyCoinsButtonHandler> (); buyCoinsButtonHandler.LeaveHome(); } Destroy(gameObject); }
public void GoHome() { if (GameObject.Find("Quit Button(Clone)") != null) { GameObject.Find("Quit Button(Clone)").GetComponent <QuitButtonHandler> ().DestroyTempPressedButton(); } if (GameObject.Find("Sound Off Button(Clone)") != null) { GameObject.Find("Sound Off Button(Clone)").GetComponent <SoundButtonHandler> ().DestroyTempPressedButton(); } if (GameObject.Find("Music Off Button(Clone)") != null) { GameObject.Find("Music Off Button(Clone)").GetComponent <MusicButtonHandler> ().DestroyTempPressedButton(); } if (GameObject.Find("Sound On Button(Clone)") != null) { GameObject.Find("Sound On Button(Clone)").GetComponent <SoundButtonHandler> ().DestroyTempPressedButton(); } if (GameObject.Find("Music On Button(Clone)") != null) { GameObject.Find("Music On Button(Clone)").GetComponent <MusicButtonHandler> ().DestroyTempPressedButton(); } if (buttonHandler.GetRestartFirstR() != null) { buttonHandler.GetRestartFirstR().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartE() != null) { buttonHandler.GetRestartE().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartS() != null) { buttonHandler.GetRestartS().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartFirstT() != null) { buttonHandler.GetRestartFirstT().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartA() != null) { buttonHandler.GetRestartA().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartSecondR() != null) { buttonHandler.GetRestartSecondR().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartSecondT() != null) { buttonHandler.GetRestartSecondT().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartConfirmationButton() != null) { buttonHandler.GetRestartConfirmationButton().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetRestartCancelButton() != null) { buttonHandler.GetRestartCancelButton().GetComponent <RestartWordHandler> ().GoHome(); } if (buttonHandler.GetQuitQ() != null) { buttonHandler.GetQuitQ().GetComponent <QuitWordHandler> ().GoHome(); } if (buttonHandler.GetQuitU() != null) { buttonHandler.GetQuitU().GetComponent <QuitWordHandler> ().GoHome(); } if (buttonHandler.GetQuitI() != null) { buttonHandler.GetQuitI().GetComponent <QuitWordHandler> ().GoHome(); } if (buttonHandler.GetQuitT() != null) { buttonHandler.GetQuitT().GetComponent <QuitWordHandler> ().GoHome(); } if (buttonHandler.GetQuitConformationButton() != null) { buttonHandler.GetQuitConformationButton().GetComponent <QuitWordHandler> ().GoHome(); } if (buttonHandler.GetQuitCancelButton() != null) { buttonHandler.GetQuitCancelButton().GetComponent <QuitWordHandler> ().GoHome(); } if (buttonHandler.GetQuitCancelButton() != null || buttonHandler.GetQuitConformationButton() != null || buttonHandler.GetQuitQ() != null || buttonHandler.GetQuitU() != null || buttonHandler.GetQuitI() != null || buttonHandler.GetQuitT() != null || buttonHandler.GetRestartCancelButton() != null || buttonHandler.GetRestartConfirmationButton() != null || buttonHandler.GetRestartFirstR() != null || buttonHandler.GetRestartE() != null || buttonHandler.GetRestartS() != null || buttonHandler.GetRestartFirstT() != null || buttonHandler.GetRestartA() != null || buttonHandler.GetRestartSecondR() != null || buttonHandler.GetRestartSecondT() != null) { waitingForQuitDestruction = true; return; } instantiatedPausedShade = GameObject.Find("Paused Shade(Clone)"); if (instantiatedPausedShade == null) { instantiatedPausedShade = (GameObject)Instantiate(pausedSlide); } shadeHandler = instantiatedPausedShade.GetComponent <PausedShadeHandler> (); shadeHandler.MakeInvisible(); if (buttonHandler.GetP() != null) { buttonHandler.GetP().GetComponent <PausedWordHandler> ().GoHome(); } if (buttonHandler.GetA() != null) { buttonHandler.GetA().GetComponent <PausedWordHandler> ().GoHome(); } if (buttonHandler.GetU() != null) { buttonHandler.GetU().GetComponent <PausedWordHandler> ().GoHome(); } if (buttonHandler.GetS() != null) { buttonHandler.GetS().GetComponent <PausedWordHandler> ().GoHome(); } if (buttonHandler.GetE() != null) { buttonHandler.GetE().GetComponent <PausedWordHandler> ().GoHome(); } if (buttonHandler.GetD() != null) { buttonHandler.GetD().GetComponent <PausedWordHandler> ().GoHome(); } if (buttonHandler.GetMusicButton() != null) { musicButtonHandler = buttonHandler.GetMusicButton().GetComponent <MusicButtonHandler> (); musicButtonHandler.ReturnHome(); } if (buttonHandler.GetSoundButton() != null) { soundButtonHandler = buttonHandler.GetSoundButton().GetComponent <SoundButtonHandler> (); soundButtonHandler.ReturnHome(); } // restartButtonHandler = buttonHandler.GetRestartButton ().GetComponent<RestartButtonHandler> (); // restartButtonHandler.ReturnHome (); if (buttonHandler.GetQuitButton() != null) { quitButtonHandler = buttonHandler.GetQuitButton().GetComponent <QuitButtonHandler> (); quitButtonHandler.ReturnHome(); } if (buttonHandler.GetBuyCoinsButton() != null) { buyCoinsButtonHandler = buttonHandler.GetBuyCoinsButton().GetComponent <BuyCoinsButtonHandler> (); buyCoinsButtonHandler.ReturnHome(); } touchHandler.UnpauseTouch(); Time.timeScale = 1; GameObject instantiatedPauseButton = (GameObject)Instantiate(pauseButton, gameObject.transform.position, Quaternion.identity); if (instantiateShade) { instantiatedPauseButton.GetComponent <PauseButtonHandler> ().SetTouchOn(false); instantiatedPauseButton.GetComponent <PauseButtonHandler> ().InstantiateShade(); } if (tempPressedPlayButton != null) { Destroy(tempPressedPlayButton); } Destroy(gameObject); }