Пример #1
0
        public ScoreTable(Window parent, bool playing = true)
        {
            Playing = playing;

            Size = new Vector(500, 300);
            Location = new Vector(200, 100);
            Visible = false;

            closeButton = new Button();
            closeButton.ApplyStylishEffect();
            closeButton.Image = "data/img/bck.bmp";
            closeButton.Location = new Vector(370, 350);
            closeButton.Visible = false;
            closeButton.Text = "Close";

            closeButton.MouseClick += (pos) =>
                {
                    Visible = false;
                    if (Playing)
                        Game.StartNextLevel();
                };

            parent.Children.Add(this);
            parent.Children.Add(closeButton);
        }
        public BetaVerification(GameWindow parent)
        {
            mainLabel = new Label();
            mainLabel.Location = new Vector(350, 180);
            mainLabel.Text = "Please enter your open beta key.";

            nameBox = new TextBox();
            nameBox.Location = new Vector(325, 220);

            nameLabel = new Label();
            nameLabel.Location = new Vector(315, 200);
            nameLabel.Text = "Name:";

            keyLabel = new Label();
            keyLabel.Location = new Vector(325, 240);
            keyLabel.Text = "Beta key:";

            keyBox = new TextBox();
            keyBox.Location = new Vector(300, 260);
            keyBox.Size.X = 200;

            verifyButton = new Button();
            verifyButton.Location = new Vector(335, 290);
            verifyButton.ApplyStylishEffect();
            verifyButton.Image = "data/img/bck.bmp";
            verifyButton.Text = "Verify";

            verifyButton.MouseClick += (pos) =>
                {
                    if (OpenBetaFunctions.VerifyBetaKey(nameBox.Text, keyBox.Text))
                    {
                        Parent.Children.Remove(nameBox);
                        Parent.Children.Remove(nameLabel);
                        Parent.Children.Remove(keyBox);
                        Parent.Children.Remove(keyLabel);
                        Parent.Children.Remove(verifyButton);
                        Parent.Children.Remove(wrongKeyMessage);
                        Parent.Children.Remove(mainLabel);

                        Settings.Default.CredentialsVerified = true;
                        Settings.Default.Save();

                        if (Settings.Default.MusicStatus)
                            BackgroundMusic.StartPlayback();

                        Parent.Menu = new MainMenu(Parent);
                    }
                    else wrongKeyMessage.Visible = true;
                };

            wrongKeyMessage = new Label();
            wrongKeyMessage.Text = "The key and username do not match.";
            wrongKeyMessage.Location = new Vector(340, 310);
            wrongKeyMessage.Visible = false;

            Parent = parent;

            Parent.AddChildren(nameLabel, nameBox, mainLabel, keyLabel, keyBox, verifyButton, wrongKeyMessage);
        }
Пример #3
0
        public MainMenu(Window window)
        {
            ParentWindow = window;
            skybox = new Skybox();

            start = new Button();
            start.ApplyStylishEffect();
            //start.Location = new Vector()
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the InfoBox class.
        /// It flashes an exclamation mark 2 times, then moves
        /// to the target location.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="target"></param>
        public InfoBox(Window parent, Vector target, string message)
        {
            CanBeMoved = true;
            Location = new Vector(target.X, target.Y);
            OKClicked = new MouseEventDel((pos) => { });
            ExclamationClicked = new MouseEventDel((pos) => { });

            ExclamationSize = new Vector(60, 55);
            ExclamationLocation = new Vector((parent.Width - ExclamationSize.X) / 2,
                (parent.Height - ExclamationSize.Y) / 2);
            Size = new Vector(200, 10);
            Parent = parent;

            frameAlpha = 0f;
            startAlpha = 0f;
            currentAlpha = startAlpha;
            frameTargetY = 200;
            targetAlpha = 1f;
            animationCoef = 0.0f;

            mainLabel = new Label();
            Message = message;
            mainLabel.Location = new Vector(Location.X - 50 + message.Length * 4, Location.Y + 30);
            mainLabel.Visible = false;

            buttonOk = new Button();
            buttonOk.Image = "data/img/bck.bmp";
            buttonOk.ApplyStylishEffect();
            buttonOk.Visible = false;
            buttonOk.Size.X = 70;
            buttonOk.Location = new Vector(Location.X + (Size.X - buttonOk.Size.X) / 2, Location.Y + 160);
            buttonOk.Text = "OK";
            buttonOk.MouseClick += (pos) =>
            {
                OKClicked.Invoke(pos);

                Parent.Children.Remove(buttonOk);
                Parent.Children.Remove(mainLabel);
                Parent.Children.Remove(this);
                MainTimer.Stop();
            };

            Parent.Mouse.Move += MouseMoveFunc;

            targetLocation = target;
            targetLocation.X += Size.X / 2;
            targetLocation.Y += Size.Y / 2;

            MainTimer = new Timer();
            MainTimer.Interval = 10;
            MainTimer.Tick += AnimationStep;
            MainTimer.Start();
        }
Пример #5
0
        public IngameMenu(GameWindow parent)
        {
            Parent = parent;
            Visible = false;

            float shift = 30;
            float x = parent.Width / 2;
            float y = parent.Height / 2;

            resume = new Button();
            resume.ApplyStylishEffect();
            resume.Location = new Vector(x - resume.Size.X, y - shift * 3);
            resume.Text = "Resume";
            resume.Visible = false;
            resume.MouseClick += (pos) =>
                {
                    Hide();
                    Parent.State = Window.WindowState.Game;
                };

            settings = new Button();
            settings.ApplyStylishEffect();
            settings.Location = new Vector(x - settings.Size.X + 7, y - shift * 2);
            settings.Text = "Settings";
            settings.Visible = false;
            settings.MouseClick += (pos) =>
                {

                };

            quit = new Button();
            quit.ApplyStylishEffect();
            quit.Location = new Vector(x - quit.Size.X, y - shift);
            quit.Text = "Quit";
            quit.Visible = false;
            quit.MouseClick += (pos) =>
                {
                    Game.Game.QuitLevel();
                    Parent.Menu.RenderVisibility(true);
                    Hide();
                };

            Parent.AddChildren(resume, settings, quit, this);
        }
Пример #6
0
        public Credits(MainMenu parent)
        {
            ParentMenu = parent;

            credit = new Label();
            credit.Text = "     Credits \n\nProgrammers \n   Traiko Dinev \n\nGame Designer"+
                "\n   Traiko Dinev \n\nLead Programmer \n   Traiko Dinev";

            back = new Button();
            back.ApplyStylishEffect();
            back.Image = "data/img/bck.bmp";
            back.Text = "Return";
            back.Size.X = 80;
            back.MouseClick += (pos) =>
                {
                    Visible = false;
                };
            Visible = false;

            Initialize();
            ParentMenu.ParentWindow.AddChildren(this, back);

            LogManager.WriteInfo("Created credits menu.");
        }
Пример #7
0
        public MainMenu(GameWindow window)
        {
            ParentWindow = window;
            playGameMenu = new PlayGameMenu(this);

            play = new Button();
            play.ApplyStylishEffect();
            play.Text = "Play Game";
            play.Image = "data/img/bck.bmp";
            play.MouseClick += (pos) =>
                {
                    HideAllVisible();
                    playGameMenu.Show();
                };
            play.Location = new Vector(100, 120);

            settings = new Button();
            settings.ApplyStylishEffect();
            settings.Text = "Settings";
            //settings.Size.X = 100;
            settings.Image = "data/img/bck.bmp";
            settings.Location = new Vector(100, 150);
            settings.MouseClick += (pos) =>
                {
                    HideAllVisible();
                    settingsMenu.Visible = true;
                    settingsMenu.Show();
                };

            about = new Button();
            about.ApplyStylishEffect();
            about.Text = "About";
            //about.Size.X = 80;
            about.Image = "data/img/bck.bmp";
            about.Location = new Vector(100, 180);
            about.MouseClick += (pos) =>
                {
                    if (!credits.Visible) HideAllVisible();
                    credits.Visible = credits.Visible ? false : true;
                };

            highScores = new Button();
            highScores.ApplyStylishEffect();
            highScores.Text = "High Scores";
            highScores.Image = "data/img/bck.bmp";
            highScores.Location = new Vector(100, 210);
            highScores.MouseClick += (pos) =>
                {
                    HideAllVisible();
                    Game.Game.ShowScores();
                };

            quit = new Button();
            quit.ApplyStylishEffect();
            quit.Text = "Quit";
            //quit.Size.X = 60;
            quit.Image = "data/img/bck.bmp";
            quit.Location = new Vector(100, 240);
            quit.MouseClick += (pos) =>
                {
                    Environment.Exit(0);
                };

            credits = new Credits(this);
            credits.Visible = false;
            settingsMenu = new SettingsMenu(this);

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

                    play.Location.X -= curShift;
                    settings.Location.X -= curShift;
                    about.Location.X -= curShift;
                    quit.Location.X -= curShift;
                    highScores.Location.X -= curShift;
                    return;
                }
                mainTimer.Stop();
            };

            ParentWindow.State = Window.WindowState.MainMenu;
            ParentWindow.AddChildren(play, settings, about, quit, credits, settingsMenu, highScores);

            LogManager.WriteInfo("Main menu created.");
        }
Пример #8
0
        public SettingsMenu(MainMenu MenuParent)
        {
            Parent = MenuParent.ParentWindow;
            ParentMenu = MenuParent;
            soundStatus = Properties.Settings.Default.SoundStatus;
            musicStatus = Properties.Settings.Default.MusicStatus;

            mainTimer = new Timer();
            mainTimer.Interval = 10;

            titleLabel = new Label();
            titleLabel.Text = "Settings";
            titleLabel.Location = new Vector(100, -250.5f);

            toggleSoundLabel = new Label();
            toggleSoundLabel.Location = new Vector(130, -220.5f);
            toggleSoundLabel.Text = "Sound: " + (soundStatus ? "On " : "Off");

            toggleSound = new Button();
            toggleSound.Location = new Vector(270, -220.5f);
            toggleSound.ApplyStylishEffect();
            toggleSound.Size = new Vector(70, 20);
            toggleSound.Image = "data/img/bck.bmp";
            toggleSound.Text = "Toggle";
            toggleSound.MouseClick += (pos) =>
                {
                    soundStatus = soundStatus ? false : true;
                    toggleSoundLabel.Text = "Sound: " + (soundStatus ? "On " : "Off");
                };

            saveButton = new Button();
            saveButton.Location = new Vector(200, -30);
            saveButton.Image = "data/img/bck.bmp";
            saveButton.ApplyStylishEffect();
            saveButton.Text = "Save";
            saveButton.MouseClick += (pos) => SaveAndHide();

            toggleMusicLabel = new Label();
            toggleMusicLabel.Location = new Vector(130, -180.5f);
            toggleMusicLabel.Text = "Music: " + (musicStatus ? "On " : "Off");

            toggleMusic = new Button();
            toggleMusic.Location = new Vector(270, -180.5f);
            toggleMusic.ApplyStylishEffect();
            toggleMusic.Size = new Vector(70, 20);
            toggleMusic.Image = "data/img/bck.bmp";
            toggleMusic.Text = "Toggle";
            toggleMusic.MouseClick += (pos) =>
                {
                    musicStatus = musicStatus ? false : true;
                    toggleMusicLabel.Text = "Music: " + (musicStatus ? "On " : "Off");
                };

            deleteSaveGames = new Button();
            deleteSaveGames.Location = new Vector(150, -120.5f);
            deleteSaveGames.ApplyStylishEffect();
            deleteSaveGames.Image = "data/img/bck.bmp";
            deleteSaveGames.Text = "Delete saved games";
            deleteSaveGames.MouseClick += (pos) =>
                {
                    Game.Game.DeleteProgress(false);
                    Game.Game.LoadGame();
                    SaveAndHide();
                };
            deleteSaveGames.Size = new Vector(160, 25);

            Parent.AddChildren(toggleSound, saveButton, toggleMusicLabel, toggleMusic, deleteSaveGames);

            mainTimer.Tick += (o, e) =>
            {
                //lazy delay implementation
                //TODO: maybe fix
                elapsed++;
                if (elapsed < 10)
                    return;

                if (curShift < destShift)
                {
                    curShift += shiftIncr;

                    titleLabel.Location.Y -= curShift;
                    toggleSoundLabel.Location.Y -= curShift;
                    toggleSound.Location.Y -= curShift;
                    saveButton.Location.Y -= curShift;
                    toggleMusicLabel.Location.Y -= curShift;
                    toggleMusic.Location.Y -= curShift;
                    deleteSaveGames.Location.Y -= curShift;

                    return;
                }
                mainTimer.Stop();
            };
        }
Пример #9
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);
            }
        }