Esempio n. 1
0
        public GameManager(Canvas gameCanvas, ToggleSwitch difficultyLevel, Button buttonNewWord, TextBlock textBlockGuessWord, TextBlock textBlockCommentHard)
        {
            #region init Xaml attribute
            _gameCanvas = gameCanvas;

            _toggleSwitchLevels          = difficultyLevel;
            _toggleSwitchLevels.Toggled += toggleSwitchLevel_Toggled;


            _buttonNewWord        = buttonNewWord;
            _buttonNewWord.Click += buttonNewWord_Click;


            _textBlockGuessWord = textBlockGuessWord;

            _textBlockCommentHard            = textBlockCommentHard;
            _textBlockCommentHard.Foreground = new SolidColorBrush(Colors.Red);
            _textBlockCommentHard.FontSize   = 20;
            #endregion

            _keyBoard = new KeyBoard(_gameCanvas, new System.Drawing.Rectangle(25, 25, 75, 75));
            _keyBoard.AddClickEventHandler(KeyBoard_Click);

            _pictureFrames = new HangManFrames(_gameCanvas, new System.Drawing.Rectangle(600, 400, 250, 250), @"/Assets/HangManImage/");

            _randomWord = new RandomWord();
            EasyGame();
            _textBlockGuessWord.FontSize = FontSizeTextBlocks;
        }
Esempio n. 2
0
        private void WrongGuessUpdateFrame(KeyBoard key)
        {
            char keyContent = (char)key.Content;
            bool ignoreUpperCaseSpecialKey = !(keyContent.Equals('>') || keyContent.Equals('<'));

            if (ignoreUpperCaseSpecialKey && !_word.GuessChar(keyContent))
            {
                UpdateHangManPicture();
            }
        }
Esempio n. 3
0
        private void KeyBoard_Click(object sender, RoutedEventArgs e)
        {
            KeyBoard key        = (KeyBoard)sender;
            bool     SpecialKey = !(key.IndexI == _buttons.GetLength(0) - 1 && key.IndexJ == _buttons.GetLength(1) - 1);

            if (SpecialKey)
            {
                _disableKeys.Add((char)key.Content);
            }
            else
            {
                ChangeCase();
            }

            UpdateKeyBoard();
        }
Esempio n. 4
0
 private void InitButtons()
 {
     for (int i = 0; i < _buttons.GetLength(0); i++)
     {
         for (int j = 0; j < _buttons.GetLength(1); j++)
         {
             _buttons[i, j]          = new KeyBoard();
             _buttons[i, j].IndexI   = i;
             _buttons[i, j].IndexJ   = j;
             _buttons[i, j].Width    = _rectChar.Width;
             _buttons[i, j].Height   = _rectChar.Height;
             _buttons[i, j].FontSize = fontSize;
             _buttons[i, j].Click   += KeyBoard_Click;
             // _buttons[i, j].Background = new SolidColorBrush(Windows.UI.Color.FromArgb(25, 0, 100, 0));
             Canvas.SetLeft(_buttons[i, j], _rectChar.X + (j * (_rectChar.Width + spaceBetweenBtn)));
             Canvas.SetTop(_buttons[i, j], _rectChar.Y + (i * (_rectChar.Height + spaceBetweenBtn)));
             _buttons[i, j].Content = _spliteKeyBoardLowerCase[i][j];
             _gameCanvas.Children.Add(_buttons[i, j]);
         }
     }
 }