/*/// <summary> * /// Used to display main menu with all default options, centred, over the top of whatever, without initiating a background * /// NOTE: for more control ignore this event and call mainMenuScript.InitialiseMainMenu * /// </summary> * private void CreateDefaultMainMenu() * { * //menu only accessible if player is active * if (GameManager.i.playerScript.status == ActorStatus.Active) * { * ModalMainMenuDetails detailsMain = new ModalMainMenuDetails() * { * alignHorizontal = AlignHorizontal.Centre, * background = Background.None, * isCustomise = false, * isCredits = false * }; * //activate menu * InitialiseMainMenu(detailsMain); * } * else * { * //display a pop-up info window * GameManager.i.guiScript.SetAlertMessageModalOne(AlertType.MainMenuUnavailable); * } * }*/ #region OpenMainMenu /// <summary> /// Initialise and run a main menu with a preset Configuration based on the MainMenuType.enum /// </summary> /// <param name="menuType"></param> private void OpenMainMenu(MainMenuType menuType) { ModalMainMenuDetails details = new ModalMainMenuDetails(); //default settings (can override below) details.alignHorizontal = AlignHorizontal.Centre; details.background = Background.None; //preset configurations switch (menuType) { case MainMenuType.Main: //game start details.header = "Main Menu"; details.background = Background.Start; details.isResume = false; details.isSaveGame = false; details.isMainMenu = false; break; case MainMenuType.Game: //in-game, press ESC details.header = "Game Menu"; details.isCustomise = false; details.isNewGame = false; details.isCredits = false; details.isTutorial = false; details.isMainMenu = true; break; case MainMenuType.Tutorial: //tutorial mode details.header = "Tutorial Menu"; details.isSaveGame = false; details.isLoadGame = false; details.isNewGame = false; details.isTutorial = false; details.isCustomise = false; details.isCredits = false; details.isMainMenu = true; break; default: Debug.LogWarningFormat("Unrecognised menuType \"{0}\"", menuType); break; } //set and run main menu InitialiseMainMenu(details); }
/// <summary> /// Initialises Main menu details and passes configuration data to SetMainMenu which then fires it up. Use this method instead of SetMainMenu to display menu (enables easy set up of buttons) /// </summary> /// <param name="detailsMain"></param> private void InitialiseMainMenu(ModalMainMenuDetails detailsMain) { //game state -> save current state first gameState = GameManager.i.inputScript.GameState; //menu ModalGenericMenuDetails details = new ModalGenericMenuDetails(); details.itemName = detailsMain.header; details.itemDetails = "2033"; float horizontalPos = 0f; float verticalPos = Screen.height / 2; //horizontal position can vary but vertical is always centred switch (detailsMain.alignHorizontal) { case AlignHorizontal.Left: horizontalPos = Screen.width / 3; break; case AlignHorizontal.Centre: horizontalPos = Screen.width / 2; break; case AlignHorizontal.Right: horizontalPos = Screen.width * 0.6666f; break; default: Debug.LogErrorFormat("Unrecognised alignHorizontal \"{0}\"", detailsMain.alignHorizontal); break; } //position details.menuPos = new Vector3(horizontalPos, verticalPos); // // - - - Configure buttons (not buttons need to be in top to bottom menu display order) // //Resume button if (detailsMain.isResume == true) { EventButtonDetails button0 = new EventButtonDetails() { buttonTitle = "Resume", buttonTooltipHeader = string.Format("{0}Resume{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Return to Game{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}HQ are wondering where you've gone{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.ResumeGame, this, -1, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button0); } //Tutorial button if (detailsMain.isTutorial == true) { EventButtonDetails button1 = new EventButtonDetails() { buttonTitle = "Tutorial", buttonTooltipHeader = string.Format("{0}Tutorial{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Do the Tutorial{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}You weren't expecting to figure this out on your own, were you?{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.TutorialOptions, this, -1, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button1); } //New Game button if (detailsMain.isNewGame == true) { EventButtonDetails button2 = new EventButtonDetails() { buttonTitle = "New Game", buttonTooltipHeader = string.Format("{0}New Game{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Start a new game{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}HQ are keen to get moving{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.CreateNewGame, this, null, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button2); } //Load Game button if (detailsMain.isLoadGame == true) { EventButtonDetails button3 = new EventButtonDetails() { buttonTitle = "Load Game", buttonTooltipHeader = string.Format("{0}Load Game{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Load a saved game{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}HQ would like now how you manage that trick?{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.LoadGame, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button3); } //Save Game button if (detailsMain.isSaveGame == true) { EventButtonDetails button4 = new EventButtonDetails() { buttonTitle = "Save Game", buttonTooltipHeader = string.Format("{0}Save Game{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Save your current game{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}HQ are working on uploading memories{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.SaveGame, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button4); } //Options button if (detailsMain.isOptions == true) { EventButtonDetails button5 = new EventButtonDetails() { buttonTitle = "Options", buttonTooltipHeader = string.Format("{0}Options{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Game Options{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}It's good to have options{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.CreateOptions, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button5); } //Feedback button if (detailsMain.isFeedback == true) { EventButtonDetails button6 = new EventButtonDetails() { buttonTitle = "Feedback", buttonTooltipHeader = string.Format("{0}Feedback{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Send Feedback on bugs or design{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}All feedback, good or bad, is much appreciated{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.CloseMainMenu, this, -1, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button6); } //Customise button if (detailsMain.isCustomise == true) { EventButtonDetails button7 = new EventButtonDetails() { buttonTitle = "Customise", buttonTooltipHeader = string.Format("{0}Customise{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Personalise the game environment in an easy to use manner{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}Who doesn't like to do things there way?{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.CloseMainMenu, this, -1, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button7); } //Credits button if (detailsMain.isCredits == true) { EventButtonDetails button8 = new EventButtonDetails() { buttonTitle = "Credits", buttonTooltipHeader = string.Format("{0}Credits{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}The cast of thousands who made this mighty game{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}Make yourself a cuppa and then sit back and roll the Credits{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.CloseMainMenu, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button8); } //Information button if (detailsMain.isInformation == true) { EventButtonDetails button9 = new EventButtonDetails() { buttonTitle = "Information", buttonTooltipHeader = string.Format("{0}Information{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Find info on Game Mechanics and Game Design{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}Information is Power{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.CloseMainMenu, this, -1, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button9); } //Return to Main Menu button if (detailsMain.isMainMenu == true) { EventButtonDetails button10 = new EventButtonDetails() { buttonTitle = "Main Menu", buttonTooltipHeader = string.Format("{0}Main Menu{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Return to the Main Menu{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}Take a moment to recalibrate{1}", colourAlert, colourEnd) }; //depends on where you are returning from switch (GameManager.i.inputScript.GameState) { case GameState.NewInitialisation: //playGame when exiting to main menu case GameState.PlayGame: button10.action = () => { EventManager.i.PostNotification(EventType.GameReturn, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); }; break; case GameState.Tutorial: button10.action = () => { EventManager.i.PostNotification(EventType.TutorialReturn, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); }; break; default: Debug.LogWarningFormat("Unrecognised GameState \"{0}\"", GameManager.i.inputScript.GameState); break; } details.listOfButtonDetails.Add(button10); } //Exit to Desktop button if (detailsMain.isExit == true) { EventButtonDetails button11 = new EventButtonDetails() { buttonTitle = "EXIT to Desktop", buttonTooltipHeader = string.Format("{0}EXIT{1}", colourSide, colourEnd), buttonTooltipMain = string.Format("{0}Leave the game and exit to the desktop{1}", colourNormal, colourEnd), buttonTooltipDetail = string.Format("{0}HQ will hold the fort until you return{1}", colourAlert, colourEnd), action = () => { EventManager.i.PostNotification(EventType.ExitGame, this, gameState, "ModalMainMenu.cs -> InitialiseMainMenu"); } }; details.listOfButtonDetails.Add(button11); } //display background (default is none) GameManager.i.modalGUIScript.SetBackground(detailsMain.background); //activate menu SetMainMenu(details); }