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);
            }
        }
Beispiel #2
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);
        }
        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++;
            }
        }
        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);
        }