// Use this for initialization
    void Start()
    {
        GameObject counter = GameObject.Find("ChooseBackground");

        level    = counter.GetComponent <SmallIntestineLoadLevelCounter> ();
        levelnum = level.getTutorialNum();


        if (levelnum == 0)
        {
            PlayerPrefs.SetInt("SITowerPlaceTutorial", 1);
            PlayerPrefs.SetInt("SIGlowTutorial", 0);
            PlayerPrefs.SetInt("SIUpdateTutorial", 0);
            PlayerPrefs.SetInt("SINutrientsTutorial", 1);
            PlayerPrefs.SetInt("SISpeedTutorial", 1);
            PlayerPrefs.SetInt("SIFatsTutorial", 0);
        }

        if (levelnum == 1)
        {
            PlayerPrefs.SetInt("SITowerPlaceTutorial", 0);
            PlayerPrefs.SetInt("SIGlowTutorial", 0);
            PlayerPrefs.SetInt("SIUpdateTutorial", 0);
            PlayerPrefs.SetInt("SINutrientsTutorial", 0);
            PlayerPrefs.SetInt("SISpeedTutorial", 0);
            PlayerPrefs.SetInt("SIFatsTutorial", 1);
        }

        if (levelnum == 2)
        {
            PlayerPrefs.SetInt("SITowerPlaceTutorial", 1);
            PlayerPrefs.SetInt("SIGlowTutorial", 0);
            PlayerPrefs.SetInt("SIUpdateTutorial", 1);
            PlayerPrefs.SetInt("SINutrientsTutorial", 0);
            PlayerPrefs.SetInt("SISpeedTutorial", 0);
            PlayerPrefs.SetInt("SIFatsTutorial", 0);
        }



        PlayerPrefs.Save();
    }
Пример #2
0
    public bool end = false;                          //!< to remember if we are done reading new waves from a script

    /**
     * Use this for initialization
     * Check if game was loaded properly. If not reload.
     * Start spawning waves.
     */
    void Start()
    {
        level = null;                                             // initially set the reference to null

        GameObject counter = GameObject.Find("ChooseBackground"); // try to find an instance of the background chooser

        if (counter != null)                                      // if the counter is not null we can continue as normal with initialization
        {
            // if the counter was there we can just get the level
            level = counter.GetComponent <SmallIntestineLoadLevelCounter> ();
        }
        else           // if we start the level from the game itself just start at level 0, 1, or 2 appropriately
        {
            // this part should only happen if we start the game from the wrong scene in the unity editor
            // if the counter wasn't there reload properly
            // this will reload the entire game from the level it was supposed to be loaded from
            if (Application.loadedLevelName == "SmallIntestineTutorial")
            {
                // if we load directly from the tutorial scene, then reload the si game from level 0
                PlayerPrefs.SetInt("DesiredSILevel", 0);
                PlayerPrefs.Save();
                Application.LoadLevel("LoadLevelSmallIntestine");
            }
            else if (Application.loadedLevelName == "SmallIntestineOdd")
            {
                // if we load directly from the si odd scene, then reload the si game from level 1
                PlayerPrefs.SetInt("DesiredSILevel", 1);
                PlayerPrefs.Save();
                Application.LoadLevel("LoadLevelSmallIntestine");
            }
            else if (Application.loadedLevelName == "SmallIntestineEven")
            {
                // if we load directly from the si even scene, then reload the game from level 2
                PlayerPrefs.SetInt("DesiredSILevel", 2);
                PlayerPrefs.Save();
                Application.LoadLevel("LoadLevelSmallIntestine");;
            }
        }

        // load in the script info
        if (counter != null)            // guard check to prevent this code from executing before the game is reloaded
        {
            // start loading in the script
            loadScript = new LoadScript();                                                                      // create a new script loader

            //if (!level.getTutorial ()) {									//if not tutorial

            waves = loadScript.loadIntestineLevel(level.getLevel(), level.isTutorial(), level.getTutorialNum()); // get the waves for the correct script

            currentWave = 0;                                                                                     // set the current wave index to 0

            waveDelay       = waves[0].startDelay;                                                               // get the start delay from the first parsed wave
            waveTime        = waves[0].runTime;                                                                  // get the run time from the first parsed wave
            SpawnInterval   = waves[0].nutrientSpawnInterval;                                                    // get the nutrient spawn interval from the first parsed wave
            speed           = waves[0].nutrientSpeed;                                                            // get the nutrient speed from the first parsed wave
            availableColors = waves[0].colors;                                                                   // get the colors for the first parsed wave
            minNutrients    = waves[0].minBlobs;                                                                 // get the min blobs for the first parsed wave
            maxNutrients    = waves[0].maxBlobs;                                                                 // get the max blobs for the first parsed wave

            m_TimeSinceLastSpawn = 0f;                                                                           // start the timesincelastspawn variable to 0
        }

        // we don't use debug config in the tutorial level so check that we aren't in the tutorial level before
        // we look for a reference to the debugger to get the debug script
        if (Application.loadedLevelName != "SmallIntestineTutorial")
        {
            debugConfig = ((GameObject)GameObject.Find("Debug Config")).GetComponent <DebugConfig>();
        }
    }