/** * Draws the background image for the mouth loading screen */ void OnGUI() { counter = GameObject.Find("MouthChooseBackground"); // find the reference to the mouth background choser level = counter.GetComponent <MouthLoadLevelCounter> (); // get the current level from the counter // draw the proper level load screen to take up the entiere screen GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgrounds [Mathf.Clamp(level.getLevel() - 1, 0, level.getMaxLevels())]); }
private int prevHighScore; //!< for high scores /** * Use this for initialization * Load level information and start calculating stats data */ void Start() { // pull up the level counter counter = GameObject.Find("MouthChooseBackground"); // find the reference to the MouthChooseBackground level = counter.GetComponent <MouthLoadLevelCounter> (); // get the MouthLoadLevelScript on the background chooser populateStats(); // look up the stats we are tracking from the data saved on disk calculateStars(); // calculate the # of stars earned based on the stats pulled up }
public bool end = false; //!< flag to indicate whether we are at the end of the script /** * Use this for initialization * Verifies the level was loaded correctly and if not reloads it. * Starts loading from script/debugger. */ void Start() { level = null; // set the MouthLoadLevelCounter to null to begin with // find the reference to the mouth debugger debugConfig = GameObject.Find("Debugger").GetComponent <EsophagusDebugConfig>(); if (debugConfig == null) // if we are starting the game directly we need to add debugger { debugConfig = gameObject.AddComponent <EsophagusDebugConfig>() as EsophagusDebugConfig; } // find the background chooser GameObject chooseBackground = GameObject.Find("MouthChooseBackground"); if (chooseBackground != null) // if we did find the background chooser, get the level from it { level = chooseBackground.GetComponent <MouthLoadLevelCounter>(); } else // in this case we started the game load game properly { // this will cause the mouth game to be properly loaded from level 1 PlayerPrefs.SetInt("DesiredMouthLevel", 1); PlayerPrefs.Save(); Application.LoadLevel("LoadLevelMouth"); } // we also need to find the references to the flaps GameObject flaps = GameObject.Find("Flaps"); // find the reference to the flaps flap = flaps.GetComponent <openFlap>(); // get the openFlap script from the flaps if (level != null) // guard for if level was null since this will still execute before the reloading from level 1 { // finally load the script loadScript = new LoadScriptMouth(); // create a new script loader waves = loadScript.loadMouthLevel(level.getLevel()); // load the proper script to the level and store data // begin parsing the data currentWave = 0; // reset the current wave counter to 0 waveDelay = waves[0].startDelay; // get the waveDelay for the current wave waveTime = waves[0].runTime; // get the waveTime for the current wave SpawnInterval = waves[0].foodSpawnInterval; // get the spawnInterval for the current wave speed = waves[0].foodSpeed; // get the foodSpped for the current wave m_TimeSinceLastSpawn = 0f; // reset the time since last spawn to 0 } }
/** * Function that cleans up destroying the food stuff and checks if the game is over. */ void OnEndPointCollision() { GameObject[] foodstuff = GameObject.FindGameObjectsWithTag("MouthFood"); // find all foodstuff on the game // check if there are any foodstuff left if (foodstuff.Length == 1 && foodSpawner.end) // if this is the last foodstuff, then we won { // handle win condition GameObject chooseBackground = GameObject.Find("MouthChooseBackground"); // find the background chooser for // the level selection texture if (chooseBackground != null) // if we found the background chooser get the level { level = chooseBackground.GetComponent <MouthLoadLevelCounter>(); level.nextLevel(); // increase the level counter to correctly load the next // level (if there is one) } //Application.LoadLevel("MouthStats"); // load the stats screen for the completed level Instantiate(endGameScript); } else // otherwise if there are more food stuff just destroy the current one that hit the end point { Destroy(this.gameObject); } }