Exemplo n.º 1
0
    /**
     * Chooses and draws the correct loading screen image
     */
    void OnGUI()
    {
        counter = GameObject.Find("ChooseBackground");                                  // find a reference to the background chooser
        level   = counter.GetComponent <SmallIntestineLoadLevelCounter> ();             // to get a reference to the script on the background chooser

        // draw the loading screen texture across the entire screen
        GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgrounds [Mathf.Clamp(level.getLevel(), 0, level.getMaxLevels())]);
    }
Exemplo n.º 2
0
    int prevHighScore;                                                  //!< for high scores

    /**
     * Use this for initialization
     * Find the correct level and start calculating stats
     */
    void Start()
    {
        // pull up the level
        counter = GameObject.Find("ChooseBackground");                      // get the reference to the background chooser
        level   = counter.GetComponent <SmallIntestineLoadLevelCounter> (); // get the script on the background chooser

        populateStats();                                                    // get the stats from player prefs and store them
        calculateStars();                                                   // calculate the stars based on the stats
    }
Exemplo n.º 3
0
    /**
     * Handles drawing of game over popup menu
     */
    void OnGUI()
    {
        float scale       = 234f / 489f;
        float buttonWidth = Screen.width * 0.1591796875f;


        // draw the game over popup box in the middle of the screen
        GUI.DrawTexture(new Rect(Screen.width * 0.26953125f,
                                 Screen.height * 0.18359375f,
                                 Screen.width * 0.4609375f,
                                 Screen.height * 0.6328125f), gameOverPopup);

        // draw restart button
        if (GUI.Button(new Rect(Screen.width * 0.3251953125f,
                                Screen.height * 0.66666666666f,
                                buttonWidth,
                                buttonWidth * scale), "", restart))
        {
            // if restart is pressed
            Time.timeScale = 1;                                                                 // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground");         // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();

            // restart from the correct level
            if (level.getLevel() % 2 == 0)
            {
                Application.LoadLevel("SmallIntestineEven");
            }
            else
            {
                Application.LoadLevel("SmallIntestineOdd");
            }
        }

        // draw main menu button
        if (GUI.Button(new Rect(Screen.width * 0.5166015625f,
                                Screen.height * 0.66666666666f,
                                buttonWidth,
                                buttonWidth * scale), "", mainMenu))
        {
            // if main menu is selected
            Time.timeScale = 1;                                                         // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground"); // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
            level.resetLevel();                                                         // reset the small intestine current level to 1 for next time
            Application.LoadLevel("MainMenu");                                          // load the main menu
        }
    }
Exemplo n.º 4
0
    /**
     * Handles drawing of game over popup menu
     */
    void OnGUI()
    {
        // draw the game over popup box in the middle of the screen
        GUI.DrawTexture(new Rect(Screen.width * 0.3193359375f,
                                 Screen.height * 0.28515625f,
                                 Screen.width * 0.3603515625f,
                                 Screen.height * 0.248697917f), gameOverPopup);

        // draw restart button
        if (GUI.Button(new Rect(Screen.width * 0.41015625f,
                                Screen.height * 0.41927083f,
                                Screen.width * 0.0654296875f,
                                Screen.height * 0.06640625f), "", restart))
        {
            // if restart is pressed
            Time.timeScale = 1;                                                                 // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground");         // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();

            // restart from the correct level
            if (level.getLevel() % 2 == 0)
            {
                Application.LoadLevel("SmallIntestineEven");
            }
            else
            {
                Application.LoadLevel("SmallIntestineOdd");
            }
        }

        // draw main menu button
        if (GUI.Button(new Rect(Screen.width * 0.53125f,
                                Screen.height * 0.41927083f,
                                Screen.width * 0.0654296875f,
                                Screen.height * 0.06640625f), "", mainMenu))
        {
            // if main menu is selected
            Time.timeScale = 1;                                                         // unpause the game
            GameObject chooseBackground          = GameObject.Find("ChooseBackground"); // find the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
            level.resetLevel();                                                         // reset the small intestine current level to 1 for next time
            Application.LoadLevel("MainMenu");                                          // load the main menu
        }
    }
    // 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();
    }
Exemplo n.º 6
0
    /**
     * Draws the return button and handles drawing the Quit game pop up if necessary
     */

    void OnGUI()
    {
        // this just handles the menu button in the corner
        if (Time.timeScale != 0)                // don't draw the main menu button if timescale is 0 because this means there is some
        // other user control option up such as game over
        {
            if (GUI.Button(new Rect(Screen.width * x,  //.79f,
                                    Screen.height * y, //0.01822916f,
                                    Screen.width * .09f,
                                    Screen.height * .06f), "", mainMenuStyle))
            {
                if (scence == "Mouth")
                {
                    fp.setPaused();
                }
                Time.timeScale = 0;                             // pause the game
                confirmUp      = true;                          // throw flag
            }
        }

        // if the menu button has been pressed
        if (confirmUp)                          // confirm the user wants to exit to the main menu
        {
            GUI.depth--;

            // draw gui texture that holds box with buttons
            GUI.DrawTexture(new Rect(Screen.width * 0.3193359375f,
                                     Screen.height * 0.28515625f,
                                     Screen.width * 0.3603515625f,
                                     Screen.height * 0.248697917f), confirmPopup);

            // draw "skip game" button
            if (GUI.Button(new Rect(Screen.width * 0.3903f,
                                    Screen.height * 0.41927083f,
                                    Screen.width * 0.1025f,
                                    Screen.height * 0.06640625f), "", confirmYes))
            {
                // if the "skip game" button was pressed
                Time.timeScale = 1;                                                     // unpause the game
                if (level == "SmallIntestineLevel1")
                {
                    GameObject chooseBackground            = GameObject.Find("ChooseBackground");               // find the background chooser
                    SmallIntestineLoadLevelCounter SIlevel = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
                    SIlevel.nextLevel();
                    if (SIlevel.getLevel() <= SIlevel.getMaxLevels())
                    {
                        Application.LoadLevel("LoadLevelSmallIntestine");
                    }
                    else
                    {
                        Application.LoadLevel("SmallIntestineEndStoryboard");
                    }
                }
                else
                {
                    Application.LoadLevel(level);                       // return to the main menu
                }
            }

            // draw "keep going" button
            if (GUI.Button(new Rect(Screen.width * 0.51125f,
                                    Screen.height * 0.41927083f,
                                    Screen.width * 0.1025f,
                                    Screen.height * 0.06640625f), "", confirmNo))
            {
                // if the "keep going" button was pressed
                Time.timeScale = 1;                                                     // unpause the game
                if (scence == "Mouth")
                {
                    fp.setPaused();
                }
                confirmUp = false;                                                      // unflag the confirm up variable
            }
        }
    }
Exemplo n.º 7
0
    /**
     * Handles updating all aspects of the game managed here every frame.
     * Sends updated information to the various UI element scripts.
     */
    void Update()
    {
        // check if the game is over
        // if it is just exit because we don't need to go through the rest of the stuff in update
        if (m_IsGameOver)
        {
            return;
        }

        // next check if the user has any health yet because if they don't, the game is over
        if (health <= 0)
        {
            Instantiate(GameOverScript);        // if there is no health start the game over script
            m_IsGameOver = true;                // set the flag in this script to indicate the game is over
        }

        // determine if the game is over because the user won the game
        // we do so by looking for any remaining food blobs alive on the screen and also checking to make sure the
        // script we are reading from is over
        if ((Application.loadedLevelName != "SmallIntestineTutorial" &&
             GameObject.FindWithTag("foodBlobParent") == null && spawnScript.end) ||
            (Application.loadedLevelName == "SmallIntestineTutorial" &&
             GameObject.FindWithTag("foodBlobParentTutorial") == null && spawnScript.end))
        {
            // if the game was over because we won, we need to go to the next level
            // find the background chooser
            GameObject chooseBackground = GameObject.Find("ChooseBackground");
            // get the load level script from the background chooser
            SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();

            level.nextLevel();                          // increase the level count on the load level script

            if (Application.loadedLevelName != "SmallIntestineTutorial")
            {
                Application.LoadLevel("SmallIntestineStats");                   // load the si stats screen
                //SIbps.end();
            }
            else
            {
                Application.LoadLevel("LoadLevelSmallIntestine");                       // otherwise load the next level
            }
        }

        // delay for setting sell to false to allow for race conditions due to order of execution issues
        if (setTowerMenuIsUpFalse)
        {
            elapsedTime += Time.deltaTime;                      // count the time elapsed since last update
            if (elapsedTime > maxElapsedTime)                   // if the elapsed time is greater than the max time we change the isTowerMenuUp variable
            {
                isTowerMenuUp         = false;                  // set isTowerMenuUp to false
                setTowerMenuIsUpFalse = false;                  // change the value of the flag to change isTowerMenuUp to false since it is now changed
                elapsedTime           = 0f;                     // reset the timer for next time
            }
        }

        // draw nutrients text
        nutrientsText.updateText(nutrients);

        // choose face to draw
        if (health > .8 * MAX_HEALTH)
        {
            drawHealthFace.setFace(0);
        }
        else if (health > .6 * MAX_HEALTH)
        {
            drawHealthFace.setFace(1);
        }
        else if (health > .4 * MAX_HEALTH)
        {
            drawHealthFace.setFace(2);
        }
        else if (health > .2 * MAX_HEALTH)
        {
            drawHealthFace.setFace(3);
        }
        else
        {
            drawHealthFace.setFace(4);
        }

        // for drawing the health bar
        drawHealthBar.setPercent(((float)health / (float)MAX_HEALTH));
    }
Exemplo n.º 8
0
    private bool confirmUp;             //!< flag whether or not the confirm box should be shown

    /**
     * Draws the return button plus the associated pop up box
     */
    void OnGUI()
    {
        GUI.depth = GUI.depth - 100;

        // this just handles the menu button in the corner
        if (Time.timeScale != 0)
        {
            if (GUI.Button(new Rect(Screen.width * .89f,
                                    Screen.height * 0.01822916f,
                                    Screen.width * .09f,
                                    Screen.height * .06f), "", mainMenuStyle))
            {
                Time.timeScale = 0;                             // pause the game
                confirmUp      = true;                          // throw flag
            }
        }

        // if the menu button has been pressed
        if (confirmUp)
        {
            GUI.depth--;

            // draw gui texture that holds box with buttons
            GUI.DrawTexture(new Rect(Screen.width * 0.3193359375f,
                                     Screen.height * 0.28515625f,
                                     Screen.width * 0.3603515625f,
                                     Screen.height * 0.248697917f), confirmPopup);

            // draw yes button
            if (GUI.Button(new Rect(Screen.width * 0.41015625f,
                                    Screen.height * 0.41927083f,
                                    Screen.width * 0.0654296875f,
                                    Screen.height * 0.06640625f), "", confirmYes))
            {
                // if the "yes" button was pressed
                Time.timeScale = 1;                                             // unpause the game
                GameObject chooseBackground = GameObject.Find("ChooseBackground");

                // reset the level for the si game for next time it is loaded
                if (chooseBackground != null)
                {
                    SmallIntestineLoadLevelCounter level = chooseBackground.GetComponent <SmallIntestineLoadLevelCounter>();
                    level.resetLevel();
                }

                // load the main menu
                Application.LoadLevel("MainMenu");
            }

            // draw no button
            if (GUI.Button(new Rect(Screen.width * 0.53125f,
                                    Screen.height * 0.41927083f,
                                    Screen.width * 0.0654296875f,
                                    Screen.height * 0.06640625f), "", confirmNo))
            {
                // if the "no" button was pressed
                Time.timeScale = 1;                                     // unpause the game
                confirmUp      = false;                                 // throw the flag to indicate not to show the confirm box anymore
            }
        }
    }
Exemplo n.º 9
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>();
        }
    }