Esempio n. 1
0
 /// <summary>
 /// Таймер при создании блоков
 /// </summary>
 /// <param name="sender">Объект, который в обработке</param>
 /// <param name="e">Аргументы события</param>
 private void TimerCreateBlock_Tick(object sender, EventArgs e)
 {
     CreateBlocks(words[numberWords[timerValue]], blockPositions[timerValue][0], blockPositions[timerValue][1]);
     if (timerValue == 4)
     {
         timerValue = 5;
         timerCreateBlock.Enabled = false;
         timerCountDown.Enabled   = true;
         for (int i = 0; i < 4; i++)
         {
             label = new SmoothLabel
             {
                 BackColor = Color.Transparent,
                 TextAlign = ContentAlignment.MiddleCenter,
                 Font      = new Font(private_fonts.Families[0], 25F),
                 UseCompatibleTextRendering = true,
                 TextRenderingHint          = TextRenderingHint.AntiAlias,
                 Text      = "",
                 Width     = 100,
                 Height    = 100,
                 ForeColor = Color.White,
                 Parent    = this
             };
             label.Left = timerPositions[i][0];
             label.Top  = timerPositions[i][1];
             smoothTimers.Add(label);
         }
     }
     timerValue++;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /// <summary>
 /// Таймер при исчезновении блоков
 /// </summary>
 /// <param name="sender">Объект, который в обработке</param>
 /// <param name="e">Аргументы события</param>
 private void TimerCountDown_Tick(object sender, EventArgs e)
 {
     timerValue--;
     if (timerValue > 0)
     {
         for (int i = 0; i < 4; i++)
         {
             smoothTimers[i].Text = timerValue.ToString();
         }
     }
     if (timerValue == 0)
     {
         for (int i = 0; i < 4; i++)
         {
             smoothTimers[i].Text = "GO!";
         }
     }
     else if (timerValue == -1)
     {
         for (int i = 0; i < 5; i++)
         {
             smoothLabels[i].Hide();
         }
     }
     else if (timerValue == -2)
     {
         for (int i = 0; i < 4; i++)
         {
             smoothTimers[i].Hide();
         }
     }
     else if (timerValue == -3)
     {
         timerValue             = 0;
         timerCountDown.Enabled = false;
         labelFind = 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
         };
         labelFind.Left    = (Width / 2) - (labelFind.Width / 2);
         labelFind.Top     = (Height / 2) - (labelFind.Height / 2);
         timerFind.Enabled = true;
     }
 }
Esempio n. 4
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++;
 }
Esempio n. 5
0
        /// <summary>
        /// Создания блока
        /// </summary>
        /// <param name="word">Слово на блоке</param>
        /// <param name="left">Позиция для вставки по х</param>
        /// <param name="top">Позиция для вставки по у</param>
        public void CreateBlocks(string word, int left, int top)
        {
            SmoothLabel label2 = 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      = word,
                Width     = 300,
                Height    = 100,
                ForeColor = Color.White,
                Left      = left,
                Top       = top,
                Parent    = this
            };

            smoothLabels.Add(label2);
        }
Esempio n. 6
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++;
        }
Esempio n. 7
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++;
                }
            }
        }
Esempio n. 8
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);
            }
        }