Пример #1
0
 void miMenu_OnClicked(Button sender)
 {
     if (ShowMenuScreen != null)
         ShowMenuScreen(null, null);
     this.ExitScreen();
 }
Пример #2
0
 void miRetryLevel_OnClicked(Button sender)
 {
     if (RestartLevel != null)
         RestartLevel(null, null);
     this.ExitScreen();
 }
Пример #3
0
        private void CreateMenuButton()
        {
            //Menu Button
            int ButtonPosX = _viewport.Width / 2 - (int)(_woodPlank.Width / 2) - 25;
            _pnlMenu = new PanelControl();
            _pnlMenu.Position = new Vector2(ButtonPosX, (int)(_woodPlank.Height) - 60 - 35);

            //Menu
            Button miMenu = new Button(ScreenManager.Game)
            {
                Width = 150,
                Height = 49,
                NormalButtonTexture = _menuNormal,
                ClickedButtonTexture = _menuClicked,
                Position = new Vector2(310, 0)
            };
            miMenu.OnClicked += new Button.ClickHandler(miMenu_OnClicked);
            _pnlMenu.AddChild(miMenu);

            if (this._isGameOver)
            {
                //Retry
                Button miRetryLevel = new Button(ScreenManager.Game)
                {
                    Width = 150,
                    Height = 49,
                    NormalButtonTexture = _retryLevelNormal,
                    ClickedButtonTexture = _retryLevelClicked
                };

                miRetryLevel.OnClicked += new Button.ClickHandler(miRetryLevel_OnClicked);
                _pnlMenu.AddChild(miRetryLevel);

            }
            else
            {
                //Retry
                Button miContinueToNextLevel = new Button(ScreenManager.Game)
                {
                    Width = 150,
                    Height = 49,
                    NormalButtonTexture = _continueNormal,
                    ClickedButtonTexture = _continueClicked
                };

                miContinueToNextLevel.OnClicked += new Button.ClickHandler(miContinueToNextLevel_OnClicked);
                _pnlMenu.AddChild(miContinueToNextLevel);
            }
        }
Пример #4
0
 void miContinueToNextLevel_OnClicked(Button sender)
 {
     if (NextLevel != null)
         NextLevel(null, null);
     this.ExitScreen();
 }
Пример #5
0
        void miStartGame_OnClicked(Button sender)
        {
            if (_levelSelectorScreen == null)
                _levelSelectorScreen = new LevelSelectorScreen();

            ScreenManager.AddScreen(_levelSelectorScreen, null);
        }
Пример #6
0
        private void CreateMenu()
        {
            //Initialize MenuPanel
            _pnlMenu = new ScrollingPanelControl();

            //Add MenuItems
            int i = 0;
            foreach (Level item in Assets.Levels)
            {
                Button mi = new Button(ScreenManager.Game)
                            {
                                Width = _viewport.Width - 20,
                                Height = 96,
                                NormalButtonTexture = _btnNormal,
                                ClickedButtonTexture = _btnClicked,
                                DisplayText = item.LevelName + "\n" + item.Description,
                                TextVisible = true,
                                Font = ScreenManager.SpriteFonts.SegoeBold,
                                Tag = i,
                                TextSize = Button.FontSize.Big,
                                TextAlignment = Button.TextAlign.Left,
                                Position = new Vector2(10, i * 100)
                            };

                mi.OnClicked += (Button sender) =>
                    {
                        LoadLevelByIndex((int)sender.Tag);
                    };

                _pnlMenu.AddChild(mi);
                i++;
            }
        }
Пример #7
0
 void miInstructions_OnClicked(Button sender)
 {
     ScreenManager.AddScreen(new InstructionsScreen(), null);
 }
Пример #8
0
 void miHighScore_OnClicked(Button sender)
 {
     ScreenManager.AddScreen(new HighScoreScreen(), null);
 }
Пример #9
0
        private void CreateMenu()
        {
            //Initialize MenuPanel
            pnlMenu = new PanelControl();
            pnlMenu.Position = new Vector2(_viewport.Width / 2 - 125, 100);

            //Add MenuItems
            //1. Start Game
            Button miStartGame = new Button(ScreenManager.Game)
            {
                Width = 250,
                Height = 60,
                NormalButtonTexture = _startGameNormal,
                ClickedButtonTexture = _startGameClicked,
                //Position = new Vector2(_viewport.Width / 2 - _startGameNormal.Width / 2, _logo.Height + 25)
            };

            //2. Instructions
            Button miInstructions = new Button(ScreenManager.Game)
            {
                Width = 250,
                Height = 60,
                NormalButtonTexture = _instructionsNormal,
                ClickedButtonTexture = _instructionsClicked,
                Position = new Vector2(0, 62)
            };

            //3. Highscore
            Button miHighScore = new Button(ScreenManager.Game)
            {
                Width = 250,
                Height = 60,
                NormalButtonTexture = _highScoreNormal,
                ClickedButtonTexture = _highScoreClicked,
                Position = new Vector2(0, 124)
            };

            //Event Handlers
            miStartGame.OnClicked += new Button.ClickHandler(miStartGame_OnClicked);
            miInstructions.OnClicked += new Button.ClickHandler(miInstructions_OnClicked);
            miHighScore.OnClicked += new Button.ClickHandler(miHighScore_OnClicked);

            //Add MenuItems to Menupanel
            pnlMenu.AddChild(miStartGame);
            pnlMenu.AddChild(miInstructions);
            pnlMenu.AddChild(miHighScore);
        }
Пример #10
0
 void miGotIt_OnClicked(Button sender)
 {
     this.ExitScreen();
 }
Пример #11
0
        private void CreateBackButton()
        {
            //Initialize MenuPanel
            int ButtonPosX = _viewport.Width / 2 + (int)(_background.Width / 2) - 150;
            _pnlMenu = new PanelControl();
            _pnlMenu.Position = new Vector2(ButtonPosX, (int)(_background.Height) - 49 - 5);

            //Add MenuItems, Back button
            Button miGotIt = new Button(ScreenManager.Game)
            {
                Width = 150,
                Height = 49,
                NormalButtonTexture = _gotitNormal,
                ClickedButtonTexture = _gotitClicked
            };

            miGotIt.OnClicked += new Button.ClickHandler(miGotIt_OnClicked);

            _pnlMenu.AddChild(miGotIt);
        }