public void ResetTheGameboard()
 {
     touchHandler.PauseTouch();
     checkForMatches.SetGameStarted(false);
     instantiator.SetSwappingJewels(true);
     turnTouchBackOn = true;
     shuffleFinished = false;
     tempJewelGrid   = new GameObject[9, 9];
     KeepBombsAndRocksTheSame();
     ShuffleRemainingJewels();
     instantiator.SetSwappingJewels(false);
 }
예제 #2
0
    public void AddOneToJewelCollectorOne(Vector3 collectorPosition)
    {
        if (jewelCollectorOneNumerator == jewelCollectorOneCap)
        {
            jewelCollectorOneFinished = true;
            return;
        }
        jewelCollectorOneNumerator++;
        string jewelCollectionNumeratorString = jewelCollectorOneNumerator.ToString();

        if (jewelCollectorOneNumerator <= jewelCollectorOneDenominator)
        {
            if (jewelCollectionNumeratorString.Length > 1)
            {
                Destroy(jewelCollectorOneNumbers[0]);
                jewelCollectorOneNumbers[0] = (GameObject)Instantiate(GetGameObjectFromNumber(jewelCollectorOneNumerator / 10), collectorPosition + firstNumberOffset, Quaternion.identity);
            }
            Destroy(jewelCollectorOneNumbers[1]);
            jewelCollectorOneNumbers[1] = (GameObject)Instantiate(GetGameObjectFromNumber(jewelCollectorOneNumerator % 10), collectorPosition + secondNumberOffset, Quaternion.identity);
            if (!jewelCollectorOneFinished && jewelCollectorOneNumerator == jewelCollectorOneDenominator)
            {
                jewelCollectorOneFinished = true;
                jewelCollectorsFinishedNumber++;
                if (jewelCollectorsFinishedNumber == 6)
                {
                    touchHandler.PauseTouch();
                    movementChecker.SetCollectingDone();
                }
                GameObject temp = GameObject.Find("Jewel Collector One");
                temp.transform.DetachChildren();
                Destroy(temp);
                temp      = (GameObject)Instantiate(finishedJewelCollector, collectorPosition, Quaternion.identity);
                temp.name = "Jewel Collector One";
            }
        }
    }
    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);
        }
    }