Esempio n. 1
0
        /// <summary>
        ///     Updates the Input.
        /// </summary>
        private void UpdateInput()
        {
            _newMouseState = Input.Mouse.GetState();

            if (!_gameStarted)
            {
                if (_newMouseState.IsMouseButtonDown(MouseButtons.Left))
                {
                    _gameStarted = true;
                }
            }
            else
            {
                if (!_isDead)
                {
                    if (_newMouseState.IsMouseButtonDown(MouseButtons.Left))
                    {
                        _player.Velocity= new Vector2(0, -4.5f);
                        _swing.Play();
                    }
                }
            }

            if (_gameStarted && _isDead)
            {
                if (_newMouseState.IsMouseButtonDown(MouseButtons.Left))
                {
                    //reset game.
                    _player.Position = new Vector2(300, 230);
                    _player.Dead = false;
                    _player.Velocity = new Vector2(0, 0);
                    _isDead = false;
                    _gameStarted = false;
                    _pipeManager.Reset();
                    _pipeManager.Opacity = 1f;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the object.
        /// </summary>
        /// <param name="gameTime">The GameTime.</param>
        public void Update(GameTime gameTime)
        {
            _mouseState = _inputManager.Mouse.GetState();
            _keyState = _inputManager.Keyboard.GetState();
            _mouseRectangle.X = _mouseState.Position.X;
            _mouseRectangle.Y = _mouseState.Position.Y;
            IsMouseHoverState = _mouseRectangle.Intersects(Bounds.ToRectangle());

            //check if the mouse clicked the control

            if (IsMouseHoverState && IsMouseDown(MouseButtons.Left))
            {
                SetFocus();
            }

            OnUpdate(gameTime);
        }