示例#1
0
        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);
        }
示例#2
0
        public MenuOptions(MenuUI ui, string mainPage)
        {
            _ui = ui;

            MenuPage optionsPage = new MenuPage(150);

            _fullscreenButton = optionsPage.Add(new MenuButton(optionsPage, "Fullscreen: ?", "icons/fullscreen.png", "", "Displays the game over the\nwhole monitor")) as MenuButton;
            _fullscreenButton.RegisterEvent(MenuElement.EventType.Clicked,
                                            (e, h) => { if (!h)
                                                        {
                                                            ui.Parent.Game.Fullscreen = !ui.Parent.Game.Fullscreen;
                                                        }
                                            });

            _vsyncButton = optionsPage.Add(new MenuButton(optionsPage, "V-sync: ?", "icons/vsync.png", "", "Synchronizes the game to\nthe monitor")) as MenuButton;
            _vsyncButton.RegisterEvent(MenuElement.EventType.Clicked,
                                       (e, h) => { if (!h)
                                                   {
                                                       ui.Parent.Game.VSync = !ui.Parent.Game.VSync;
                                                   }
                                       });

            optionsPage.Add(new MenuSpacer(4));
            optionsPage.Add(new MenuButton(optionsPage, "Audio", "icons/audio.png", "", "")).
            RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h)
                                                                     {
                                                                         ui.SwitchPage("__options/audio", false);
                                                                     }
                          });
            optionsPage.Add(new MenuButton(optionsPage, "Input", "icons/input.png", "", "")).
            RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h)
                                                                     {
                                                                         ui.SwitchPage("__options/input", false);
                                                                     }
                          });
            optionsPage.Add(new MenuSpacer(4));
            optionsPage.Add(new MenuButton(optionsPage, "Back", "icons/arrow_left.png")).
            RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h)
                                                                     {
                                                                         ui.SwitchPage(mainPage, true);
                                                                     }
                          });

            MenuPage audioPage = new MenuPage(150);

            _masterVolume = audioPage.Add(new MenuButton(audioPage, "Master Volume: Muted", "icons/audio.png")) as MenuButton;
            _musicVolume  = audioPage.Add(new MenuButton(audioPage, "Music Volume: Muted", "icons/music.png")) as MenuButton;

            _masterVolume.RegisterEvent(MenuElement.EventType.Left, (e, h) =>
            {
                if (!h)
                {
                    Settings.MasterVolume -= 10;
                }
                if (Settings.MasterVolume < 0)
                {
                    Settings.MasterVolume = 0;
                }
            });
            _masterVolume.RegisterEvent(MenuElement.EventType.Right, (e, h) =>
            {
                if (!h)
                {
                    Settings.MasterVolume += 10;
                }
                if (Settings.MasterVolume > 100)
                {
                    Settings.MasterVolume = 100;
                }
            });

            _musicVolume.RegisterEvent(MenuElement.EventType.Left, (e, h) =>
            {
                if (!h)
                {
                    Settings.MusicVolume -= 10;
                }
                if (Settings.MusicVolume < 0)
                {
                    Settings.MusicVolume = 0;
                }
            });
            _musicVolume.RegisterEvent(MenuElement.EventType.Right, (e, h) =>
            {
                if (!h)
                {
                    Settings.MusicVolume += 10;
                }
                if (Settings.MusicVolume > 100)
                {
                    Settings.MusicVolume = 100;
                }
            });

            audioPage.Add(new MenuSpacer(4));
            audioPage.Add(new MenuButton(audioPage, "Back", "icons/arrow_left.png")).
            RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h)
                                                                     {
                                                                         ui.SwitchPage("__options", true);
                                                                     }
                          });

            MenuPage inputPage = new MenuPage(150);

            inputPage.Add(new MenuSpacer(4));
            inputPage.Add(new MenuButton(inputPage, "Back", "icons/arrow_left.png")).
            RegisterEvent(MenuElement.EventType.Clicked, (e, h) => { if (!h)
                                                                     {
                                                                         ui.SwitchPage("__options", true);
                                                                     }
                          });

            ui.AddPage("__options", optionsPage);
            ui.AddPage("__options/audio", audioPage);
            ui.AddPage("__options/input", inputPage);
        }
示例#3
0
 public IEnumerator <ICoroutineOperation> SwitchToOptionsPage()
 {
     return(_ui.SwitchPage("__options"));
 }