Exemplo n.º 1
0
        public PlayGameMenu(MainMenu menuParent)
        {
            MenuParent = menuParent;
            Parent = menuParent.ParentWindow;

            resumeGameButton = new Button();
            resumeGameButton.Text = "Resume Game";
            resumeGameButton.Location = new Vector(255, 0);
            resumeGameButton.ApplyStylishEffect();
            resumeGameButton.Size.X -= 10;
            resumeGameButton.Image = "data/img/bck.bmp";

            resumeGameButton.MouseClick += (pos) =>
                {
                    Game.Game.ResumeGame();
                    Hide();
                    MenuParent.HideMenu();
                };

            newGameButton = new Button();
            newGameButton.Text = "New Game";
            newGameButton.Location = new Vector(250, 0);
            newGameButton.ApplyStylishEffect();
            newGameButton.Image = "data/img/bck.bmp";
            newGameButton.MouseClick += (pos) =>
                {
                    Game.Game.NewGame();
                    Hide();
                    MenuParent.HideMenu();
                };

            backButton = new Button();
            backButton.Text = "Back";
            backButton.Location = new Vector(265, 0);
            backButton.ApplyStylishEffect();
            backButton.Image = "data/img/bck.bmp";
            backButton.Size.X -= 30;
            backButton.MouseClick += (pos) => Hide();

            mainTimer = new Timer();
            mainTimer.Interval = 10;
            mainTimer.Tick += (o, e) =>
                {
                    if (curShift < destShift)
                    {
                        curShift += shiftIncr;

                        resumeGameButton.Location.Y -= curShift;
                        newGameButton.Location.Y -= curShift;
                        backButton.Location.Y -= curShift;

                        return;
                    }
                    mainTimer.Stop();
                };

            resumeGameButton.Location.Y = -250.5f;
            newGameButton.Location.Y = -220.5f;
            backButton.Location.Y = -1900.5f;
            Parent.AddChildren(resumeGameButton, newGameButton, backButton);

            canResume = Game.Game.CheckProgress();
            if (!canResume)
            {
                Parent.Children.Remove(resumeGameButton);
                Parent.Children.Add(this);
            }
        }