Пример #1
0
        //Gestione bottoni puzzle
        private void ButtonAction(object sender, ButtEventArgs e)
        {
            if (widget.Count > 0)
            {
                if (widget[indexCard].type == e.T)
                {
                    answer = Answer.CORRECT;
                    effectAnswerCorrect.Play();

                    //_game.Score += _game.GameLevel.POINT;
                    addPoint();
                    widget.RemoveAt(indexCard);
                    if (indexCard == widget.Count && widget.Count != 0)
                    {
                        indexCard -= 1;
                    }
                }
                else
                {
                    answer = Answer.ERROR;
                    effectAnswerWrong.Play();
                    if (_game.Score < _game.GameLevel.POINT)
                    {
                        _game.Score = 0;
                    }
                    else
                    {
                        //_game.Score -= _game.GameLevel.POINT_ERROR;
                        removePoint();
                    }
                }
            }
        }
Пример #2
0
        public void update()
        {
            _previousMouse = _currentMouse;
            _currentMouse  = Mouse.GetState();
            var mouseRectangle = new Rectangle(_currentMouse.X, _currentMouse.Y, 1, 1);

            if (mouseRectangle.Intersects(rect) && _currentMouse.LeftButton == ButtonState.Pressed)
            {
                _isPressed = true;
            }
            else
            {
                _isPressed = false;
            }


            if (mouseRectangle.Intersects(rect) && _currentMouse.LeftButton == ButtonState.Released && _previousMouse.LeftButton == ButtonState.Pressed)
            {
                if (Enable)
                {
                    ButtEventArgs e = new ButtEventArgs();
                    e.T = this.Type;
                    Action?.Invoke(this, e);
                }
            }
        }