Ejemplo n.º 1
0
        /// <summary>
        /// Обработчик нажатия по кнопке меню
        /// </summary>
        /// <param name="sender">Объект, который в обработке</param>
        /// <param name="e">Аргументы события</param>
        private void Buttons_Click(object sender, EventArgs e)
        {
            string buttonText = (sender as SmoothLabel).Text;

            switch (buttonText)
            {
            case "Начать":
            {
                gameName.Hide();
                for (int i = 0; i < smoothButtons.Count; i++)
                {
                    smoothButtons[i].Hide();
                }
                InitGame();
                break;
            }

            case "Продолжить":
            {
                labelRes.Hide();
                scoreLabel.Hide();
                for (int i = 0; i < smoothButtons2.Count; i++)
                {
                    smoothButtons2[i].Hide();
                }
                InitGame();
                break;
            }

            case "Правила игры":
                gameRules.Show();
                break;

            case "Об игре":
                gameInfo.Show();
                break;

            case "Сохранить":
            {
                SaveGame();
                break;
            }

            case "Загрузить":
                OpenGame();
                break;

            case "Выход":
                Close();
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Таймер при инициализации
        /// </summary>
        /// <param name="sender">Объект, который в обработке</param>
        /// <param name="e">Аргументы события</param>
        private void TimerIntro_Tick(object sender, System.EventArgs e)
        {
            timerValue++;
            BackColor = setColor ? Color.FromArgb(92, 74, 114) : Color.FromArgb(244, 106, 78);
            setColor  = !setColor;

            if (timerValue == 5)
            {
                timerIntro.Enabled = false;
                timerValue         = 0;
                label.Hide();
                timerCreateBlock.Enabled = true;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Таймер перед исчезновением слова
 /// </summary>
 /// <param name="sender">Объект, который в обработке</param>
 /// <param name="e">Аргументы события</param>
 private void TimerFind_Tick(object sender, EventArgs e)
 {
     timerValue++;
     if (timerValue == 5)
     {
         labelFind.Hide();
     }
     else if (timerValue == 6)
     {
         indexHideWord = numberWords[rnd.Next(5)];
         int n = smoothLabels.Count;
         while (n > 1)
         {
             n--;
             int k              = rnd.Next(n);
             var tempLabel      = smoothLabels[n];
             var tempNumberWord = numberWords[n];
             smoothLabels[n] = smoothLabels[k];
             numberWords[n]  = numberWords[k];
             smoothLabels[k] = tempLabel;
             numberWords[k]  = tempNumberWord;
         }
         curIndex = Array.IndexOf(numberWords, indexHideWord);
         for (int i = 0; i < smoothLabels.Count; i++)
         {
             smoothLabels[i].Left = 364;
             smoothLabels[i].Top  = blockPositions2[i];
             if (i == curIndex)
             {
                 smoothLabels[curIndex].Text = "?";
             }
         }
         timerFind.Enabled      = false;
         timerValue             = 0;
         timerShowBlock.Enabled = true;
     }
     else
     {
         BackColor = setColor ? Color.FromArgb(92, 74, 114) : Color.FromArgb(244, 106, 78);
         setColor  = !setColor;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Инициализация уровня
        /// </summary>
        public void InitGame()
        {
            if (labelSave != null)
            {
                labelSave.Hide();
            }
            setColor                  = true;
            timerValue                = 0;
            timerIntro.Interval       = timerInterval;
            timerCountDown.Interval   = timerInterval;
            timerCreateBlock.Interval = timerInterval;
            timerFind.Interval        = timerInterval;
            timerFinish.Interval      = timerInterval;
            timerShowBlock.Interval   = timerInterval;
            timerIntro.Enabled        = true;
            numberWords               = new int[] { -1, -1, -1, -1, -1 };
            if (smoothLabels != null)
            {
                Dispose();
            }
            smoothLabels  = new List <SmoothLabel>();
            smoothTimers  = new List <SmoothLabel>();
            smoothAnswers = new List <SmoothLabel>();
            numberAnswers = new List <int>();
            label         = new SmoothLabel
            {
                BackColor = Color.Transparent,
                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font(private_fonts.Families[0], 80F),
                UseCompatibleTextRendering = true,
                TextRenderingHint          = TextRenderingHint.AntiAlias,
                Text      = "Запомни!",
                Width     = 800,
                Height    = 200,
                ForeColor = Color.White,
                Parent    = this
            };
            label.Left = (Width / 2) - (label.Width / 2);
            label.Top  = (Height / 2) - (label.Height / 2);

            int curTemp = 0;

            while (curTemp != 5)
            {
                int  tempNumber = rnd.Next(words.Length);
                bool find       = false;
                for (int i = 0; i < curTemp; i++)
                {
                    if (tempNumber == numberWords[i])
                    {
                        find = true;
                        break;
                    }
                }
                if (!find)
                {
                    numberWords[curTemp] = tempNumber;
                    curTemp++;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Конструктор формы
        /// </summary>
        public FormLostWord()
        {
            InitializeComponent();
            LoadFont();
            timerInterval = 700;
            rnd           = new Random();
            setColor      = true;
            score         = 0;
            words         = Regex.Split(Properties.Resources.words, "\r\n");

            blockPositions    = new int[5][];
            blockPositions[0] = new int[] { 107, 100 };
            blockPositions[1] = new int[] { 621, 100 };
            blockPositions[2] = new int[] { 364, 300 };
            blockPositions[3] = new int[] { 107, 500 };
            blockPositions[4] = new int[] { 621, 500 };

            timerPositions    = new int[4][];
            timerPositions[0] = new int[] { 464, 100 };
            timerPositions[1] = new int[] { 207, 300 };
            timerPositions[2] = new int[] { 721, 300 };
            timerPositions[3] = new int[] { 464, 500 };

            blockPositions2 = new int[] { 45, 165, 285, 405, 525 };
            answerPositions = new int[] { 17, 696, 17, 696 };
            buttonsText     = new string[] { "Начать", "Загрузить", "Правила игры", "Об игре", "Выход" };
            buttonsText2    = new string[] { "Продолжить", "Загрузить", "Сохранить", "Выход" };
            smoothButtons   = new List <SmoothLabel>();
            smoothButtons2  = new List <SmoothLabel>();
            gameName        = new SmoothLabel
            {
                BackColor = Color.Transparent,
                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font(private_fonts.Families[0], 80F),
                UseCompatibleTextRendering = true,
                TextRenderingHint          = TextRenderingHint.AntiAlias,
                Text      = "Потерянное слово",
                Width     = 800,
                Height    = 200,
                ForeColor = Color.White,
                Parent    = this
            };
            gameName.Left = (Width / 2) - (gameName.Width / 2);
            gameName.Top  = 50;
            gameName.Show();

            gameInfo = new SmoothLabel
            {
                BackColor = Color.Transparent,
                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font(private_fonts.Families[0], 20F),
                UseCompatibleTextRendering = true,
                TextRenderingHint          = TextRenderingHint.AntiAlias,
                Text      = "Игра \"Потерянное слово\" помогает развивать память, способствует концентрации внимания и улучшает реакцию. Игра создана в учебных целях.",
                Width     = 800,
                Height    = 600,
                ForeColor = Color.White,
                Parent    = this
            };
            gameInfo.Left = (Width / 2) - (gameInfo.Width / 2);
            gameInfo.Top  = (Height / 2) - (gameInfo.Height / 2);
            gameInfo.Hide();

            closeWindow = new SmoothLabel
            {
                BackColor = Color.FromArgb(163, 88, 109),
                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font(private_fonts.Families[0], 20F),
                UseCompatibleTextRendering = true,
                TextRenderingHint          = TextRenderingHint.AntiAlias,
                Text      = "Закрыть",
                Width     = 300,
                Height    = 40,
                ForeColor = Color.White,
                Parent    = gameInfo
            };
            closeWindow.Left        = (closeWindow.Parent.Width / 2) - (closeWindow.Width / 2);
            closeWindow.Top         = 400;
            closeWindow.MouseEnter += ChangeBackMouseEnter;
            closeWindow.MouseLeave += ChangeBackMouseLeave;
            closeWindow.Click      += Window_Close;
            closeWindow.Show();

            gameRules = new SmoothLabel
            {
                BackColor = Color.Transparent,
                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font(private_fonts.Families[0], 12F),
                UseCompatibleTextRendering = true,
                TextRenderingHint          = TextRenderingHint.AntiAlias,
                Text = "После начала игры Вам будет предложено 5 слов, которые нужно запомнить. Спустя некоторое время слова пропадут и заново отобразятся за исключением одного," +
                       "которое Вам и нужно отгадать. На выбор Вам будет предложено 4 варианта ответа и всего 1 попытка, чтобы отгадать слово. Цель игры: отгадать как можно " +
                       "больше слов подряд. Но учтите, что с каждым отгаданным словом времени на запоминание слов будет всё меньше и меньше. Удачи!",
                Width     = 800,
                Height    = 600,
                ForeColor = Color.White,
                Parent    = this
            };
            gameRules.Left = (Width / 2) - (gameRules.Width / 2);
            gameRules.Top  = (Height / 2) - (gameRules.Height / 2);
            gameRules.Hide();

            closeWindow2 = new SmoothLabel
            {
                BackColor = Color.FromArgb(163, 88, 109),
                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font(private_fonts.Families[0], 20F),
                UseCompatibleTextRendering = true,
                TextRenderingHint          = TextRenderingHint.AntiAlias,
                Text      = "Закрыть",
                Width     = 300,
                Height    = 40,
                ForeColor = Color.White,
                Parent    = gameRules
            };
            closeWindow2.Left        = (closeWindow2.Parent.Width / 2) - (closeWindow2.Width / 2);
            closeWindow2.Top         = 400;
            closeWindow2.MouseEnter += ChangeBackMouseEnter;
            closeWindow2.MouseLeave += ChangeBackMouseLeave;
            closeWindow2.Click      += Window_Close;
            closeWindow2.Show();

            for (int i = 0; i < buttonsText.Length; i++)
            {
                label = new SmoothLabel
                {
                    BackColor = Color.FromArgb(163, 88, 109),
                    TextAlign = ContentAlignment.MiddleCenter,
                    Font      = new Font(private_fonts.Families[0], 20F),
                    UseCompatibleTextRendering = true,
                    TextRenderingHint          = TextRenderingHint.AntiAlias,
                    Width     = 300,
                    Height    = 40,
                    ForeColor = Color.White,
                    Parent    = this
                };
                label.Text        = buttonsText[i];
                label.MouseEnter += ChangeBackMouseEnter;
                label.MouseLeave += ChangeBackMouseLeave;
                label.Click      += Buttons_Click;

                label.Left = (Width / 2) - (label.Width / 2);
                label.Top  = 330 + i * 50;
                smoothButtons.Add(label);
                label.Show();
            }

            for (int i = 0; i < buttonsText2.Length; i++)
            {
                label = new SmoothLabel
                {
                    BackColor = Color.FromArgb(163, 88, 109),
                    TextAlign = ContentAlignment.MiddleCenter,
                    Font      = new Font(private_fonts.Families[0], 20F),
                    UseCompatibleTextRendering = true,
                    TextRenderingHint          = TextRenderingHint.AntiAlias,
                    Width     = 300,
                    Height    = 40,
                    ForeColor = Color.White,
                    Parent    = this
                };
                label.Text        = buttonsText2[i];
                label.MouseEnter += ChangeBackMouseEnter;
                label.MouseLeave += ChangeBackMouseLeave;
                label.Click      += Buttons_Click;

                label.Left = (Width / 2) - (label.Width / 2);
                label.Top  = 370 + i * 50;
                label.Hide();
                smoothButtons2.Add(label);
            }
        }