Example #1
0
        private void AddControls(string message)
        {
            var gameName        = MenuDesign.MakeName(new Point(Width / 2 - 300, 150));
            var startButton     = MenuDesign.MakeButton(new Point(Width / 6 - 130, 320), "Начать");
            var exitButton      = MenuDesign.MakeButton(new Point(5 * Width / 6 - 130, 320), "Выйти");
            var gameOverMessage = new Label
            {
                Text      = message,
                Location  = new Point(Width / 2 - 300, 425),
                BackColor = Color.Transparent,
                Size      = new Size(600, 200),
                ForeColor = Color.Azure,
                Font      = new Font(FontFamily.GenericMonospace, 26, FontStyle.Regular),
                TextAlign = ContentAlignment.MiddleCenter
            };
            var levelChanger = new ComboBox()
            {
                DropDownStyle = ComboBoxStyle.DropDownList,
                Location      = new Point(Width / 2 - 130, 325),
                Font          = new Font(FontFamily.GenericMonospace, 26, FontStyle.Bold),
                Size          = new Size(260, 90),
                ForeColor     = Color.Black,
                BackColor     = Color.White,
                FlatStyle     = FlatStyle.System
            };

            levelChanger.Items.AddRange(LevelsDict.Keys.ToArray());
            levelChanger.SelectedIndex         = 0;
            levelChanger.SelectedIndexChanged += (sender, args) =>
                                                 CurrentLevel = LevelsDict[levelChanger.SelectedItem.ToString()];

            startButton.Click += (sender, args) =>
            {
                new GameForm(Location, CurrentLevel).Show();
                Hide();
            };
            exitButton.Click += (sender, args) => Application.Exit();
            Controls.Add(levelChanger);
            Controls.Add(gameName);
            Controls.Add(startButton);
            Controls.Add(exitButton);
            Controls.Add(gameOverMessage);
        }
Example #2
0
        private void AddControls()
        {
            var gameName = MenuDesign.MakeName(new Point(Width / 2 - 300, 150));

            var startButton = MenuDesign.MakeButton(new Point(Width / 2 - 130, 320), "Начать");

            var tutorButton = MenuDesign.MakeButton(new Point(Width / 2 - 130, 420), "Инструкция");

            var exitButton = MenuDesign.MakeButton(new Point(Width / 2 - 130, 520), "Выйти");

            startButton.Click += (sender, args) =>
            {
                new GameForm(Location, Levels.Dungeon).Show();
                Hide();
            };

            tutorButton.Click += (sender, args) => MessageBox.Show(
                @"Задача:
    Найти ключ и дверь, к которой он подходит и выбраться из замка, 
        но торопитесь, иначе тьма поглотит вас.

Управление:
    W,A,S,D - Передвижение 
    F - Открыть/Закрыть дверь 
    Space - Выстрелить",
                "Инструкция",
                MessageBoxButtons.OK,
                MessageBoxIcon.None);

            exitButton.Click += (sender, args) => Application.Exit();

            Controls.Add(startButton);
            Controls.Add(exitButton);
            Controls.Add(tutorButton);
            Controls.Add(gameName);
        }