void OnGUI() { //button dimensions float buttonW = Screen.width / 2; float buttonH = Screen.height / 10; GUIStyle style = new GUIStyle(GUI.skin.button); style.fontSize = (int)(buttonH / 2.5f); GUIStyle labelStyle = new GUIStyle(GUI.skin.label); labelStyle.fontSize = (int)(buttonH / 2.5f); labelStyle.alignment = TextAnchor.UpperCenter; GUI.skin = skin; style.alignment = TextAnchor.UpperCenter; GUI.Box(backWindow, "Game Over!", style); //title the menu style.alignment = TextAnchor.MiddleCenter; GUI.Label(label, "Score: " + GlobalFlags.getScore(), labelStyle); // set the resume button and functionality float halfScreenW = (Screen.width / 2) - buttonW / 2; float halfScreenH = Screen.height / 2 - 80; /*if (GUI.Button(new Rect(halfScreenW,halfScreenH,buttonW,buttonH),"Resume")){ * paused = false; * GlobalFlags.setPaused(false); * }*/ //set the restart button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = backWindow.y + Screen.height / 5; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Restart", style)) { //GlobalFlags.canFire = true; Application.LoadLevel("game"); GlobalFlags.setPaused(false); } //set the back to menu button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = Screen.height / 2 + buttonH * 1.2f; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Back To Menu", style)) { //GlobalFlags.canFire = true; Application.LoadLevel("LevelSelectPreMenu"); GlobalFlags.setPaused(false); } }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { //if escape is pressed open/close the menu, if (paused) { //if open, then close the menu paused = false; GlobalFlags.setPaused(false); } else { //if closed, open the menu paused = true; GlobalFlags.setPaused(true); GlobalFlags.bandAidFixToDefeatAllOtherBandAidFixes = false; } } }
void OnGUI() { //button dimensions float buttonW = Screen.width / 4.8f;; float buttonH = Screen.height / 6; float halfScreenW = (Screen.width) - (buttonW * 1.1f); //float halfScreenH = Screen.height/13; float halfScreenH = buttonH / 3; GUIStyle style = new GUIStyle(GUI.skin.button); style.fontSize = (int)(buttonH / 3.5f); GUI.skin = skin; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "||", style)) { paused = true; GlobalFlags.setPaused(true); } if (paused) { //if paused build the menu buttonW = Screen.width / 2; buttonH = Screen.height / 10; style.alignment = TextAnchor.UpperCenter; GUI.Box(backWindow, "Pause Menu", style); //title the menu style.alignment = TextAnchor.MiddleCenter; // set the resume button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = Screen.height / 3; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Resume", style)) { paused = false; GlobalFlags.setPaused(false); GlobalFlags.bandAidFixToDefeatAllOtherBandAidFixes = true; } //set the restart button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = Screen.height / 3 + buttonH * 1.5f; if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Restart", style)) { Application.LoadLevel("game"); GlobalFlags.canFire = true; GlobalFlags.trianglesStatic = true; GlobalFlags.setPaused(false); GlobalFlags.updateControlPoints = true; } //set the back to menu button and functionality halfScreenW = (Screen.width / 2) - buttonW / 2; halfScreenH = Screen.height / 3 + buttonH * 3; if (!GlobalFlags.getRandLevel()) { if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Back To Menu", style)) { Application.LoadLevel("LevelSelectPreMenu"); GlobalFlags.setPaused(false); GlobalFlags.canFire = true; GlobalFlags.trianglesStatic = true; GlobalFlags.updateControlPoints = true; } } else { if (GUI.Button(new Rect(halfScreenW, halfScreenH, buttonW, buttonH), "Back To Menu", style)) { //GlobalFlags.canFire = true; GlobalFlags.setRandLevel(false); GlobalFlags.infiniteRandomMode = false; Application.LoadLevel("ModeSelectMenu"); GlobalFlags.setPaused(false); GlobalFlags.updateControlPoints = true; } } } }