//**************************************************************************************************** // Methods: //**************************************************************************************************** /// <summary> /// Hides the menu and load a level. /// </summary> /// <param name="index"></param> private void loadLevel(int index) { CurrentScreen = MenuScreenType.None; UseEscape = true; Application.LoadLevel(index); CurrentScreen = (index == 0) ? MenuScreenType.Menu : MenuScreenType.Game; updateBlockedAreas(); }
public MenuScreen(MenuScreenType type, string extraLabelData, ContentManager content, GraphicsDevice graphicsDevice, SoundControl soundControl) { texture = CreateTexture(graphicsDevice); largeFont = content.Load <SpriteFont>("large"); smallFont = content.Load <SpriteFont>("small"); options = GetOptionList(type, content); //set title switch (type) { case MenuScreenType.Title: { title = "Tetris"; break; } case MenuScreenType.Settings: { title = "Settings"; break; } case MenuScreenType.Credits: { title = "Credits"; break; } case MenuScreenType.Pause: { title = "Pause"; break; } case MenuScreenType.GameOver: { title = "Game Over"; break; } } //set locations for options for (int i = 0; i < options.Count; i++) { if (i == 0) { int totalHeight = 0; foreach (MenuOption option in options) { totalHeight += option.Height; } totalHeight += (options.Count - 1) * 10; options[i].Position = new Vector2(options[i].Position.X, (Game.WINDOW_HEIGHT - totalHeight) / 2); } else { options[i].Position = new Vector2(options[i].Position.X, options[i - 1].Position.Y + options[i - 1].Height + 10); } } //extra label if (type == MenuScreenType.GameOver) { extraLabel += "Score: " + extraLabelData.Substring(0, extraLabelData.IndexOf(' ')); extraLabel += "\nLevel: " + extraLabelData.Substring(extraLabelData.IndexOf(' ') + 1); } else { extraLabel = extraLabelData; } this.type = type; this.soundControl = soundControl; SelectedOption = 0; }
private static List <MenuOption> GetOptionList(MenuScreenType menuScreenType, ContentManager content) { List <MenuOption> options = new List <MenuOption>(); switch (menuScreenType) { case MenuScreenType.Title: { options.Add(new MenuOption(MenuOptionType.StartGame, "Start Game", content)); options.Add(new MenuOption(MenuOptionType.SettingLink, "Settings", content)); options.Add(new MenuOption(MenuOptionType.CreditsLink, "Credits", content)); options.Add(new MenuOption(MenuOptionType.ExitApplication, "Exit", content)); break; } case MenuScreenType.Settings: { options.Add(new MenuOption(MenuOptionType.SoundToggle, "Sound ", content)); options.Add(new MenuOption(MenuOptionType.MusicToggle, "Music ", content)); options.Add(new MenuOption(MenuOptionType.FullScreenToggle, "Full Screen ", content)); options.Add(new MenuOption(MenuOptionType.ParticlesToggle, "Particles ", content)); options.Add(new MenuOption(MenuOptionType.TitleScreenLink, "Back", content)); break; } case MenuScreenType.Credits: { options.Add(new MenuOption(MenuOptionType.TitleScreenLink, "Back", content)); break; } case MenuScreenType.Pause: { options.Add(new MenuOption(MenuOptionType.ResumeGame, "Resume Game", content)); options.Add(new MenuOption(MenuOptionType.StartGame, "Restart Game", content)); options.Add(new MenuOption(MenuOptionType.TitleScreenLink, "Back to Menu", content)); break; } case MenuScreenType.GameOver: { options.Add(new MenuOption(MenuOptionType.StartGame, "Try Again", content)); options.Add(new MenuOption(MenuOptionType.TitleScreenLink, "Back to Menu", content)); break; } } return(options); }
/// <summary> /// The on update event of the behaviour. /// </summary> public void Update() { if (UseEscape && Input.GetKeyDown(KeyCode.Escape)) { switch (CurrentScreen) { case MenuScreenType.Menu: if (Application.loadedLevelName != "Main") { Game.main.ShowGUI = true; CurrentScreen = MenuScreenType.Game; } break; case MenuScreenType.Game: Game.main.ShowGUI = false; CurrentScreen = MenuScreenType.Menu; break; } updateBlockedAreas(); } }
private MenuScreen(MenuScreenType type) : base(TDGame.MainGame) { this.type = type; }