void OnGUI() { GUI.skin = skin; GUI.Box(new Rect(10, 10, 180, 90), ""); bool avoidObstacles = true; // Default if (gameMaster != null) { avoidObstacles = gameMaster.FlyDemoObstacleAvoidance; } if (GUI.Button(new Rect(20, 20, 160, 30), "Avoid obstacles: " + (avoidObstacles? "On" : "Off"))) { if (gameMaster != null) { gameMaster.FlyDemoObstacleAvoidance = !gameMaster.FlyDemoObstacleAvoidance; } UpdateFlies(); } if (GUI.Button(new Rect(20, 60, 160, 30), "Restart demo")) { UnPause(); Application.LoadLevel(Application.loadedLevel); } // Draw the pause menu if (isPaused) { int menuWidth = 300; int menuHeight = 220; // Center the menu on the screen. GUI.BeginGroup(new Rect(Screen.width / 2 - menuWidth / 2, Screen.height / 2 - menuHeight / 2, menuWidth, menuHeight)); GUI.Box(new Rect(0, 0, menuWidth, menuHeight), ""); GUI.Label(new Rect(79, 30, 100, 30), "Game Paused", pauseText); // Draw the button which will take the player back to the main menu. // And handle the situation in which it is pressed. if (GUI.Button(new Rect(100, 70, 100, 30), "Main Menu")) { UnPause(); AStarTargeter.ClearGrids(); Application.LoadLevel("Menu"); } if (GUI.Button(new Rect(100, 110, 100, 30), "Resume")) { UnPause(); } if (GUI.Button(new Rect(100, 150, 100, 30), "Exit Game")) { AppHelper.Quit(); } GUI.EndGroup(); } }
void OnGUI() { GUI.skin = skin; GUI.Box(new Rect(10, 10, 100, 140), ""); int health = PlayerInfo.GetMainFrogHealth(); for (int i = 0; i < health; i++) { GUI.DrawTexture(new Rect(20 + (heartSize + heartSeparation) * i, 20, heartSize, heartSize), heartTex, ScaleMode.ScaleToFit, true, 0.0f); } // This could probably be made better by using GUI groups. GUI.DrawTexture(new Rect(20, 45, heartSize, heartSize), waterTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(20, 70, heartSize, heartSize), Fly, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(20, 95, heartSize, heartSize), eggTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(20, 120, heartSize, heartSize), snakeTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(50 - 2, 45 + 3, PlayerInfo.GetMainFrogWaterLevel() / 2.0f, 14), waterMeterTex, ScaleMode.StretchToFill, true, 0.0f); GUI.Label(new Rect(40, 70, 120, 20), ": " + PlayerInfo.GetMainFrogScore() + "/" + PlayerInfo.GetRequiredFlies()); GUI.Label(new Rect(40, 95, 120, 20), ": " + PlayerInfo.GetEggsDestroyed()); GUI.Label(new Rect(40, 120, 120, 20), ": " + PlayerInfo.GetSnakesDrowned()); // Draw the pause menu if (isPaused) { int menuWidth = 300; int menuHeight = 220; // Center the menu on the screen. GUI.BeginGroup(new Rect(Screen.width / 2 - menuWidth / 2, Screen.height / 2 - menuHeight / 2, menuWidth, menuHeight)); GUI.Box(new Rect(0, 0, menuWidth, menuHeight), ""); GUI.Label(new Rect(79, 30, 100, 30), "Game Paused", pauseText); // Draw the button which will take the player back to the main menu. // And handle the situation in which it is pressed. if (GUI.Button(new Rect(100, 70, 100, 30), "Main Menu")) { UnPause(); AStarTargeter.ClearGrids(); Application.LoadLevel("Menu"); } if (GUI.Button(new Rect(100, 110, 100, 30), "Resume")) { UnPause(); } if (GUI.Button(new Rect(100, 150, 100, 30), "Exit Game")) { AppHelper.Quit(); } GUI.EndGroup(); } }
void OnGUI() { GUI.skin = skin; GUI.Box(new Rect(10, 10, 100, 120), ""); //int health = PlayerInfo.GetMainFrogHealth(); // This could probably be made better by using GUI groups. GUI.DrawTexture(new Rect(20, 20, heartSize, heartSize), flyTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(20, 45, heartSize, heartSize), eggTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(20, 70, heartSize, heartSize), snakeTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.DrawTexture(new Rect(20, 95, heartSize, heartSize), scoreTex, ScaleMode.ScaleToFit, true, 0.0f); GUI.Label(new Rect(40, 20, 120, 20), ": " + FlyPlayerInfo.NumFlies); GUI.Label(new Rect(40, 45, 120, 20), ": " + FlyPlayerInfo.SelectedFliesResource1); GUI.Label(new Rect(40, 70, 120, 20), ": " + FlyPlayerInfo.SelectedFliesResource2); GUI.Label(new Rect(40, 95, 120, 20), ": " + FlyPlayerInfo.PlayerScore); // Draw the pause menu if (isPaused) { int menuWidth = 300; int menuHeight = 220; // Center the menu on the screen. GUI.BeginGroup(new Rect(Screen.width / 2 - menuWidth / 2, Screen.height / 2 - menuHeight / 2, menuWidth, menuHeight)); GUI.Box(new Rect(0, 0, menuWidth, menuHeight), ""); GUI.Label(new Rect(79, 30, 100, 30), "Game Paused", pauseText); // Draw the button which will take the player back to the main menu. // And handle the situation in which it is pressed. if (GUI.Button(new Rect(100, 70, 100, 30), "Main Menu")) { UnPause(); AStarTargeter.ClearGrids(); FlyPlayerInfo.SetNewGame(); Application.LoadLevel("MenuA2"); } if (GUI.Button(new Rect(100, 110, 100, 30), "Resume")) { UnPause(); } if (GUI.Button(new Rect(100, 150, 100, 30), "Exit Game")) { AppHelper.Quit(); } GUI.EndGroup(); } }
void OnGUI() { GUI.skin = skin; GUI.Box(new Rect(10, 10, 80, 70), ""); GUI.Label(new Rect(20, 20, 120, 20), "Epoch: " + geneticAlgo.CurrentEpoch); GUI.Label(new Rect(20, 45, 120, 20), "Batch: " + geneticAlgo.CurrentBatch); // Draw the pause menu if (isPaused) { int menuWidth = 300; int menuHeight = 220; // Center the menu on the screen. GUI.BeginGroup(new Rect(Screen.width / 2 - menuWidth / 2, Screen.height / 2 - menuHeight / 2, menuWidth, menuHeight)); GUI.Box(new Rect(0, 0, menuWidth, menuHeight), ""); GUI.Label(new Rect(79, 30, 100, 30), "Game Paused", pauseText); // Draw the button which will take the player back to the main menu. // And handle the situation in which it is pressed. if (GUI.Button(new Rect(100, 70, 100, 30), "Main Menu")) { UnPause(); AStarTargeter.ClearGrids(); Application.LoadLevel("Menu"); } if (GUI.Button(new Rect(100, 110, 100, 30), "Resume")) { UnPause(); } if (GUI.Button(new Rect(100, 150, 100, 30), "Exit Game")) { AppHelper.Quit(); } GUI.EndGroup(); } }