// Use this for initialization
    protected override void Start()
    {
        base.Start();

                #if (UNITY_ANDROID || UNITY_IPHONE)
        ads = FindObjectOfType <AdsController> ();
        DontDestroyOnLoad(ads);
        ads.incrementTimesPlayed();


        if (ads.getTimesPlayed() % 3 == 0)
        {
            ads.showAd();
        }
                #endif

        { // Big initialization/autoconfig phase
            GameObject temp;

            temp = GameObject.FindGameObjectWithTag("RestartText");
            if (temp == null)
            {
                Debug.Log("No RestartText found in scene!");
            }
            else
            {
                restartText = temp.GetComponent <Text>();
            }

            temp = GameObject.FindGameObjectWithTag("loseText");
            if (temp == null)
            {
                Debug.Log("No loseText/gameOverText found in scene!");
            }
            else
            {
                gameOverText = temp.GetComponent <Text>();
            }
            temp = GameObject.FindGameObjectWithTag("TutorialText");
            if (temp == null)
            {
                Debug.Log("No TutorialText found in scene!");
            }
            else
            {
                tutorialText = temp.GetComponent <Text>();
            }

            temp = GameObject.FindGameObjectWithTag("ScoreText");
            if (temp == null)
            {
                Debug.Log("No ScoreText found in scene!");
            }
            else
            {
                scoreText = temp.GetComponent <Text>();
            }
        }

        for (int i = 0; i < 100; i++)
        {
            nutSpawn();
        }

        scoreText.text    = "";
        tutorialText.text = "";
        restartText.text  = "";
        gameOverText.text = "";

        canvasRect = canvas.GetComponent <RectTransform>();

        dogs = GameObject.FindGameObjectsWithTag("Dog");
        cars = GameObject.FindGameObjectsWithTag("Car");


        SquirrelController.restart();

        gameOver = false;
        atHome   = false;

        GameObject hometree = GameObject.FindGameObjectWithTag("HomeTree");
    }
Пример #2
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();

                #if (UNITY_ANDROID || UNITY_IPHONE)
        ads = FindObjectOfType <AdsController> ();
        DontDestroyOnLoad(ads);
        ads.incrementTimesPlayed();


        if (ads.getTimesPlayed() % 3 == 0)
        {
            ads.showAd();
        }
                #endif

        {                    // Big initialization/autoconfig phase
            GameObject temp; // temporary storing place for possibly null objects

            if ((beacon = FindObjectOfType <HomingBeaconController>()) == null)
            {
                Debug.Log("No HomingBeaconController found in scene!");
            }

            temp = GameObject.FindGameObjectWithTag("RestartText");
            if (temp == null)
            {
                Debug.Log("No RestartText found in scene!");
            }
            else
            {
                restartText = temp.GetComponent <Text>();
            }

            temp = GameObject.FindGameObjectWithTag("loseText");
            if (temp == null)
            {
                Debug.Log("No loseText/gameOverText found in scene!");
            }
            else
            {
                gameOverText = temp.GetComponent <Text>();
            }

            temp = GameObject.FindGameObjectWithTag("TutorialText");
            if (temp == null)
            {
                Debug.Log("No TutorialText found in scene!");
            }
            else
            {
                tutorialText = temp.GetComponent <Text>();
            }

            temp = GameObject.FindGameObjectWithTag("ScoreText");
            if (temp == null)
            {
                Debug.Log("No ScoreText found in scene!");
            }
            else
            {
                scoreText = temp.GetComponent <Text>();
            }
        }

        scoreTextField    = "";
        tutorialTextField = "";
        restartTextField  = "";
        gameOverTextField = "";

        dogs = GameObject.FindGameObjectsWithTag("Dog");
        cars = GameObject.FindGameObjectsWithTag("Car");


        SquirrelController.restart();

        gameOver = false;
        atHome   = false;

        // set up homing beacon
        GameObject hometree = GameObject.FindGameObjectWithTag("HomeTree");

        if (beacon != null)
        {
            beacon.setHometreeLocation(hometree.transform);
        }
    }