public static void changeScreen(UserControl current, string next) { //tmp is set to the form that this control is on Form tmp = current.FindForm(); tmp.Controls.Remove(current); UserControl ns = null; switch (next) { case "GameScreen": ns = new GameScreen(); break; case "InstructionScreen": ns = new InstructionScreen(); break; case "MenuScreen": ns = new MenuScreen(); break; case "OptionScreen": ns = new OptionScreen(); break; } ns.Size = new Size(controlWidth, controlHeight); ns.Location = startCentre; tmp.Controls.Add(ns); ns.Focus(); }
/// <summary> /// Called during initial app startup, this function performs all the /// permanent initialization. /// </summary> protected override void OneTimeSceneInitialization() { // Initialize the font's internal textures m_pFont.InitializeDeviceObjects(device); m_Engine.Initialize(this, device); CGameEngine.Inputs.MapKeyboardAction(Key.Escape, new ButtonAction(Terminate), true); CGameEngine.Inputs.MapKeyboardAction(Key.A, new ButtonAction(MoveCameraXM), false); CGameEngine.Inputs.MapKeyboardAction(Key.W, new ButtonAction(MoveCameraZP), false); CGameEngine.Inputs.MapKeyboardAction(Key.S, new ButtonAction(MoveCameraXP), false); CGameEngine.Inputs.MapKeyboardAction(Key.Z, new ButtonAction(MoveCameraZM), false); CGameEngine.Inputs.MapKeyboardAction(Key.P, new ButtonAction(ScreenCapture), true); CGameEngine.Inputs.MapMouseAxisAction(0, new AxisAction(PointCamera)); CGameEngine.Inputs.MapMouseAxisAction(1, new AxisAction(PitchCamera)); m_Console = new GameEngine.Console(m_pFont, @"..\..\Resources\console.jpg"); GameEngine.Console.AddCommand("QUIT", "Terminate the game", new CommandFunction(TerminateCommand)); GameEngine.Console.AddCommand("STATISTICS", "Toggle statistics display", new CommandFunction(ToggleStatistics)); m_OptionScreen = new OptionScreen(@"..\..\Resources\Options2.jpg"); m_OptionScreen.AddButton(328, 150, @"..\..\Resources\PlayOff.bmp", @"..\..\Resources\PlayOn.bmp", @"..\..\Resources\PlayHover.bmp", new ButtonFunction(Play)); m_OptionScreen.AddButton(328, 300, @"..\..\Resources\QuitOff.bmp", @"..\..\Resources\QuitOn.bmp", @"..\..\Resources\QuitHover.bmp", new ButtonFunction(Terminate)); m_Engine.SetOptionScreen(m_OptionScreen); music = new Jukebox(); music.AddSong("nadine.mp3"); music.AddSong("ComeOn.mp3"); music.AddSong("Rock.mp3"); music.Volume = 0.75f; music.Play(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Global.Pixel = new Texture2D(GraphicsDevice, 1, 1); Global.Pixel.SetData <Color>(new Color[] { Color.White }); HighScoreControl.Images = new System.Collections.Generic.Dictionary <ControlTypes, Texture2D>(); HighScoreControl.Images.Add(ControlTypes.Tap, Content.Load <Texture2D>("Screen Images/Tap Asset")); HighScoreControl.Images.Add(ControlTypes.Swipe, Content.Load <Texture2D>("Screen Images/Swipe Asset")); TitleScreen titleScreen = new TitleScreen(GraphicsDevice, 1080, 1920); GameScreen gameScreen = new GameScreen(GraphicsDevice, 1080, 1920); GameOverScreen gameOverScreen = new GameOverScreen(GraphicsDevice, 1080, 1920); OptionScreen optionScreen = new OptionScreen(GraphicsDevice, 1080, 1920); ControlSelectScreen controlScreen = new ControlSelectScreen(GraphicsDevice, 1080, 1920); StatScreen highScoreScreen = new StatScreen(GraphicsDevice, 1080, 1920); ScreenManager.Add(gameScreen); ScreenManager.Add(titleScreen); ScreenManager.Add(optionScreen); ScreenManager.Add(controlScreen); ScreenManager.Add(highScoreScreen); ScreenManager.Add(gameOverScreen); ScreenManager.Load(Content); Global.ElapsedGameTime = TimeSpan.Zero; Vector2 currentScale = new Vector2(GraphicsDevice.Viewport.Width / 1080f, GraphicsDevice.Viewport.Height / 1920f); #if WINDOWS MouseManager.Instance.Scale = currentScale; #else //Global.ShowAds(true); #endif ScreenManager.Scale(currentScale); ScreenManager.MainScreen = "Title"; }
private void MenuScreen_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { lastIndex = index; Form form = this.FindForm(); //to make sure that if you click to the bottom or top you will go to the other end instead of just stopping switch (e.KeyCode) { case Keys.Up: if (upKeyDown == false) { upKeyDown = true; //play sound Form1.pick.Stop(); Form1.pick.Play(); if (index != 0) { index--; } else { index = 3; } } break; case Keys.Down: if (downKeyDown == false) { downKeyDown = true; //play sound Form1.pick.Stop(); Form1.pick.Play(); if (index != 3) { index++; } else { index = 0; } } break; //clicking on the screen with space key case Keys.Space: switch (index) { //start button case 0: //play sound Form1.select.Stop(); Form1.select.Play(); InstructionScreen si = new InstructionScreen(); si.Location = new Point((form.Width - si.Width) / 2, (form.Height - si.Height) / 2); form.Controls.Add(si); form.Controls.Remove(this); break; //highscore button case 1: //play sound Form1.select.Stop(); Form1.select.Play(); HighscoreScreen hs = new HighscoreScreen(); form.Controls.Add(hs); form.Controls.Remove(this); hs.Location = new Point((form.Width - hs.Width) / 2, (form.Height - hs.Height) / 2); break; //option button case 2: //play sound Form1.select.Stop(); Form1.select.Play(); OptionScreen os = new OptionScreen(); form.Controls.Add(os); form.Controls.Remove(this); os.Location = new Point((form.Width - os.Width) / 2, (form.Height - os.Height) / 2); break; //exit button case 3: //play sound Form1.gameOver.Stop(); Form1.gameOver.Play(); Thread.Sleep(1000); Application.Exit(); break; } break; } //set button to white if not clicked on switch (lastIndex) { case 0: startLabel.ForeColor = Color.White; break; case 1: highScoreLabel.ForeColor = Color.White; break; case 2: optionLabel.ForeColor = Color.White; break; case 3: exitLabel.ForeColor = Color.White; break; } //set selected button to red switch (index) { case 0: startLabel.ForeColor = Color.Red; break; case 1: highScoreLabel.ForeColor = Color.Red; break; case 2: optionLabel.ForeColor = Color.Red; break; case 3: exitLabel.ForeColor = Color.Red; break; } }
public void OpenOptionsWindow(bool inGame) { optionScreen = new OptionScreen { InGame = inGame }; optionScreen.Closed += new EventHandler((o2, e2) => { Program.Instance.Interface.RemoveFader(); if (OnOptionWindowedClosed != null) OnOptionWindowedClosed(); }); Interface.AddFader(); Interface.AddChild(optionScreen); }
public void LoadWizardPage(ContentItem.OptionsItemNames contentItemName, bool calledFromClickEvent) { try { Cursor = Cursors.WaitCursor; Slyce.Common.Utility.SuspendPainting(panelContent); panelContent.Controls.Clear(); OptionScreen nextContentItem = _contentItems[contentItemName]; //webBrowserHelp.Navigate(HelpDirectory + @"\" + nextContentItem.HelpFileName); switch (contentItemName) { case ContentItem.OptionsItemNames.General: //ShowTaskHelp(TaskHelpTypes.ProjectDetails); if (!calledFromClickEvent) { sequentialNavBar1.ClickButton("General"); } pictureHeading.Image = imageListHeading.Images[0]; break; case ContentItem.OptionsItemNames.Formatting: //ShowTaskHelp(TaskHelpTypes.ProjectDetails); if (!calledFromClickEvent) { sequentialNavBar1.ClickButton("Formatting"); } pictureHeading.Image = imageListHeading.Images[0]; break; default: throw new NotImplementedException("Not coded yet: " + contentItemName.ToString()); } _currentContentItem = nextContentItem; Slyce.Common.Utility.SuspendPainting(_currentContentItem); if (_currentContentItem == null) { return; } _currentContentItem.OnDisplaying(); panelContent.Controls.Clear(); panelContent.Controls.Add(_currentContentItem); _currentContentItem.Dock = DockStyle.Fill; //this.BackColor = _currentContentItem.BackColor; //pnlImageBackground.Visible = _currentContentItem.DisplayImage; panelTop.Visible = true; // _currentContentItem.DisplayTopPanel; headingContentTitle.Visible = !_currentContentItem.DisplayTopPanel; buttonBack.Visible = true; // _currentContentItem.HasPrev; buttonBack.BringToFront(); buttonNext.Enabled = true; // _currentContentItem.HasNext || _currentContentItem.HasFinish; headingContentTitle.Text = _currentContentItem.Title; headingContentTitle.Refresh(); labelPageHeader.Text = _currentContentItem.PageHeader; labelPageDescription.Text = _currentContentItem.PageDescription; if (!string.IsNullOrEmpty(_currentContentItem.NextText)) { buttonNext.Text = _currentContentItem.NextText; } ResizeControls(); } finally { Slyce.Common.Utility.ResumePainting(panelContent); Slyce.Common.Utility.ResumePainting(_currentContentItem); Cursor = Cursors.Default; } }