/** * 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())]); }
/** * 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 } } }
/** * 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 } } } }