private IEnumerator <ICoroutineOperation> TransitionToStoryCoroutine() { foreach (MenuElement e in UI.SelectedPage) { if (e is MenuButton && (e as MenuButton).IconLeft == "icons/start_game.png") { for (int i = 0; i < 3; i++) { e.OnDeselected(null); yield return(Wait.Seconds(Game, 0.08f)); e.OnSelected(null); yield return(Wait.Seconds(Game, 0.08f)); } e.OnDeselected(null); yield return(Wait.Seconds(Game, 0.4f)); } } UI.SwitchPage("start-game"); while (!_doneWithName) { yield return(null); } UI.Toggle(); yield return(Wait.Seconds(Game, 0.3f)); _exitTransition.TweenTo(1, TweenEaseType.Linear, 1.5f); yield return(Wait.Seconds(Game, 2f)); string pname = ""; foreach (MenuElement e in UI.SelectedPage) { if (e is MenuTextInput) { pname = (e as MenuTextInput).Text.Trim(); } } if (pname == "") { pname = "Player"; } Game.CurrentState = new StoryMenuState(pname); }
public override void OnEnter(GameState previousState) { _exitTransition = new TweenedDouble(Game, 0); MenuPage startGamePage = new MenuPage(150); startGamePage.Add(new MenuLabel(startGamePage, "Choose a name to begin")); startGamePage.Add(new MenuSpacer(4)); startGamePage.Add(new MenuTextInput(startGamePage, "Player", "Name: ")); startGamePage.Add(new MenuButton(startGamePage, "Start Game")).RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h) { _doneWithName = true; } }); MenuPage mainPage = new MenuPage(150); mainPage.Add(new MenuButton(mainPage, "Start New Game", "icons/start_game.png")). RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h && Coroutine.Active.Count == 0) { Coroutine.Start(TransitionToStoryCoroutine); } }); mainPage.Add(new MenuButton(mainPage, "Load Game", "icons/load_game.png")); mainPage.Add(new MenuSpacer(4)); mainPage.Add(new MenuButton(mainPage, "Options", "icons/settings.png", "", "")). RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h) { OptionsUI.SwitchToOptionsPage(); } }); mainPage.Add(new MenuButton(mainPage, "Credits", "icons/credits.png", "", "")). RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h) { UI.SwitchPage("credits", false); } }); mainPage.Add(new MenuSpacer(4)); mainPage.Add(new MenuButton(mainPage, "Exit Game", "icons/arrow_left.png")). RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h) { Game.Exit(); } }); MenuPage creditsPage = new MenuPage(250); creditsPage.Add(new MenuLabel(creditsPage, "Age of Darkness " + Program.VERSION)); creditsPage.Add(new MenuLabel(creditsPage, "Made with MonoGame and Team STOR Engine")); creditsPage.Add(new MenuLabel(creditsPage, "")); creditsPage.Add(new MenuLabel(creditsPage, "Programming")); creditsPage.Add(new MenuLabel(creditsPage, "Hannes Mann", "", "", 0.8f)); creditsPage.Add(new MenuLabel(creditsPage, "")); creditsPage.Add(new MenuLabel(creditsPage, "Game Design and Art")); creditsPage.Add(new MenuLabel(creditsPage, "Kasper Kjällström", "", "", 0.8f)); creditsPage.Add(new MenuLabel(creditsPage, "Henrik Eriksson", "", "", 0.8f)); creditsPage.Add(new MenuSpacer(4)); creditsPage.Add(new MenuButton(creditsPage, "Back", "icons/arrow_left.png")). RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h) { UI.SwitchPage("main", true); } }); UI = new MenuUI(this, "main", mainPage, true); UI.AddPage("credits", creditsPage); UI.AddPage("start-game", startGamePage); OptionsUI = new MenuOptions(UI, "main"); UI.Toggle(); Game.IsMouseVisible = false; }