Exemple #1
0
 /// <summary>
 /// Функция для сохранения игры
 /// </summary>
 public void SaveGame()
 {
     using (FileStream file = new FileStream("lostWordSave", FileMode.Create))
     {
         string s     = score.ToString() + "\n" + timerInterval.ToString();
         byte[] array = System.Text.Encoding.Default.GetBytes(s);
         file.Write(array, 0, array.Length);
     }
     labelSave = 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    = 70,
         ForeColor = Color.White,
         Parent    = this
     };
     labelSave.Left = (Width / 2) - (labelSave.Width / 2);
     labelSave.Top  = 600;
     labelSave.Show();
     timerSave.Enabled = true;
 }
Exemple #2
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;
            }
        }
Exemple #3
0
 /// <summary>
 /// Таймер при повторном отображении блоков
 /// </summary>
 /// <param name="sender">Объект, который в обработке</param>
 /// <param name="e">Аргументы события</param>
 private void TimerShowBlock_Tick(object sender, EventArgs e)
 {
     if (timerValue == 6)
     {
         timerValue             = 0;
         timerShowBlock.Enabled = false;
         for (int i = 0; i < 4; 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.MouseEnter += ChangeBackMouseEnter;
             label.MouseLeave += ChangeBackMouseLeave;
             label.Click      += Answer_Click;
             while (true)
             {
                 var tempNumberWord = rnd.Next(words.Length);
                 if (numberAnswers.IndexOf(tempNumberWord) == -1 && Array.IndexOf(numberWords, tempNumberWord) == -1)
                 {
                     label.Text = words[tempNumberWord];
                     break;
                 }
             }
             label.Left = answerPositions[i];
             label.Top  = blockPositions2[curIndex] + 60 * (i / 2);
             smoothAnswers.Add(label);
             label.Show();
         }
         smoothAnswers[rnd.Next(4)].Text = words[numberWords[curIndex]];
         return;
     }
     else if (timerValue < 5)
     {
         smoothLabels[timerValue].Show();
     }
     timerValue++;
 }
Exemple #4
0
        /// <summary>
        /// Таймер при прохождения уровня
        /// </summary>
        /// <param name="sender">Объект, который в обработке</param>
        /// <param name="e">Аргументы события</param>
        private void TimerFinish_Tick(object sender, EventArgs e)
        {
            if (timerValue == 1)
            {
                foreach (var item in smoothAnswers)
                {
                    item.Hide();
                }
            }
            else if (timerValue == 2)
            {
                foreach (var item in smoothLabels)
                {
                    item.Hide();
                }
            }
            else if (timerValue == 3)
            {
                labelRes = new SmoothLabel
                {
                    BackColor = Color.Transparent,
                    TextAlign = ContentAlignment.MiddleCenter,
                    Font      = new Font(private_fonts.Families[0], 80F),
                    UseCompatibleTextRendering = true,
                    TextRenderingHint          = TextRenderingHint.AntiAlias,
                    Text      = win ? "Победа!" : "Провал...",
                    Width     = 800,
                    Height    = 130,
                    ForeColor = Color.White,
                    Parent    = this
                };
                labelRes.Left = (Width / 2) - (labelRes.Width / 2);
                labelRes.Top  = 150;
                labelRes.Show();

                scoreLabel = new SmoothLabel
                {
                    BackColor = Color.Transparent,
                    TextAlign = ContentAlignment.MiddleCenter,
                    Font      = new Font(private_fonts.Families[0], 30F),
                    UseCompatibleTextRendering = true,
                    TextRenderingHint          = TextRenderingHint.AntiAlias,
                    Text      = "Количество очков: " + score.ToString(),
                    Width     = 800,
                    Height    = 100,
                    Top       = 265,
                    ForeColor = Color.White,
                    Parent    = this
                };
                scoreLabel.Left = (Width / 2) - (scoreLabel.Width / 2);
                scoreLabel.Show();

                for (int i = 0; i < smoothButtons2.Count; i++)
                {
                    smoothButtons2[i].Show();
                }
                timerValue          = 0;
                timerFinish.Enabled = false;
            }
            timerValue++;
        }
Exemple #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);
            }
        }