/** * Handles drawing of the stats onto the stats screen plus all associated images */ void OnGUI() { // Draw the number of stars text GUIStyle starStyle = new GUIStyle(); // create style for the text to draw # stars starStyle.font = (Font)Resources.Load("Fonts/JandaManateeSolid"); // set font type starStyle.normal.textColor = Color.yellow; // set font color starStyle.fontSize = (int)(34f / 597f * Screen.height); // set the size relative to screen size // draw the text representation of the number of stars earned in the specified location GUI.Label(new Rect((290f / 1024f) * Screen.width, (138f / 768f) * Screen.height, (100f / 1024f) * Screen.width, (100f / 768f) * Screen.height), "" + numStars, starStyle); // draw the actual stars if (numStars == 1) { GUI.DrawTexture(new Rect((48f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((142f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); GUI.DrawTexture(new Rect((236f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); GUI.DrawTexture(new Rect((330f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); GUI.DrawTexture(new Rect((424f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); } else if (numStars == 2) { GUI.DrawTexture(new Rect((48f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((142f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((236f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); GUI.DrawTexture(new Rect((330f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); GUI.DrawTexture(new Rect((424f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); } else if (numStars == 3) { GUI.DrawTexture(new Rect((48f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((142f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((236f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((330f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); GUI.DrawTexture(new Rect((424f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); } else if (numStars == 4) { GUI.DrawTexture(new Rect((48f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((142f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((236f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((330f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((424f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), emptyStar); } else if (numStars == 5) { GUI.DrawTexture(new Rect((48f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((142f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((236f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((330f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); GUI.DrawTexture(new Rect((424f / 1024f) * Screen.width, (236f / 768f) * Screen.height, (74f / 1024f) * Screen.width, (74f / 768f) * Screen.height), filledStar); } // Draw the stats text GUIStyle statsStyle = new GUIStyle(); // create a style for the text statsStyle.font = (Font)Resources.Load("Fonts/JandaManateeSolid"); // set the font face statsStyle.normal.textColor = Color.yellow; // set the font color statsStyle.fontSize = (int)(20f / 597f * Screen.height); // set the font size relative to screen size // create a label to display the row headers for each stat type GUI.Label(new Rect((600f / 1024f) * Screen.width, (90f / 768f) * Screen.height, (((961f - 27f) - 600f) / 1024f) * Screen.width, ((520f - 90f) / 768f) * Screen.height), "Nutrients Earned:\n" + "Nutrients Spent:\n" + "Food Lost:\n" + "Towers Placed:\n" + "Towers Sold:\n" + "Towers Upgraded:\n" + "Enzymes Released:\n" + "\n" + //TODO: move this somewhere? "\n" + //TODO: move this somehwere? " High Score:", //TODO: move this somewhere? statsStyle); // create another label beside it to print out the actual stat numbers // because we are not using a fixed width font we use two labels so the columns will be perfectly lined up GUI.Label(new Rect((820f / 1024f) * Screen.width, (90f / 768f) * Screen.height, (((961f - 27f) - 600f) / 1024f) * Screen.width, ((520f - 90f) / 768f) * Screen.height), "" + nutrientsEarned + "\n" + "" + nutrientsSpent + "\n" + "" + foodLost + "\n" + "" + towersPlaced + "\n" + "" + towersSold + "\n" + "" + towersUpgraded + "\n" + "" + enzymesFired + "\n" + "\n" + //TODO: move this somewhere? "\n" + //TODO: move this somewhere? "" + prevHighScore, //TODO: move this somewhere? statsStyle); // draw the button for next level if (GUI.Button(new Rect((635f / 1024f) * Screen.width, (535f / 768f) * Screen.height, ((905f - 635f) / 1024f) * Screen.width, ((665f - 535f) / 768f) * Screen.height), "", nextLevelButton)) { // make sure we don't show the load screen after it's over if (level.getLevel() > level.getMaxLevels()) // check if we've played all the levels { //Application.LoadLevel("LargeIntestineStoryBoard"); // if we have load the end screen Application.LoadLevel("SmallIntestineEndStoryboard"); } else { if (level.isTutorial()) { Application.LoadLevel("SmallIntestineTutorial"); } else { Application.LoadLevel("LoadLevelSmallIntestine"); // otherwise load the next level } } } }
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>(); } }