예제 #1
0
        private void UpdateState()
        {
            if (Entity.Graphic == null)
            {
                return;
            }

            if (_input.MouseScreenX > Entity.X - _sprite.HalfWidth &&
                _input.MouseScreenX < Entity.X + _sprite.HalfWidth &&
                _input.MouseScreenY > Entity.Y - _sprite.HalfHeight &&
                _input.MouseScreenY < Entity.Y + _sprite.HalfHeight)
            {
                if (!_isHovered)
                {
                    OnHoverStartEvent?.Invoke();
                }
                _isHovered = true;
                _isPressed = _input.MouseButtonDown(MouseButton.Any);
            }
            else
            {
                if (_isHovered)
                {
                    OnHoverEndEvent?.Invoke();
                }
                _isHovered = false;
            }
        }
예제 #2
0
 private void UpdateState()
 {
     if (_input.MouseScreenX > X - Sprite.HalfWidth && _input.MouseScreenX < X + Sprite.HalfWidth &&
         _input.MouseScreenY > Y - Sprite.HalfHeight && _input.MouseScreenY < Y + Sprite.HalfHeight)
     {
         if (!_isHovered)
         {
             OnHoverStartEvent?.Invoke();
         }
         _isHovered = true;
         _isPressed = _input.MouseButtonDown(_button);
     }
     else
     {
         if (_isHovered)
         {
             OnHoverEndEvent?.Invoke();
         }
         _isHovered = false;
     }
 }
예제 #3
0
        private void UpdateState()
        {
            if (Entity.Graphic == null)
            {
                return;
            }

            _shaderSprite ??= Image.CreateRectangle(_sprite.Width, _sprite.Height, Color.White);
            _shaderSprite.CenterOrigin();

            if (!Entity.Graphics.Contains(_shaderSprite))
            {
                _shaderSprite.Shader = _shader;
                Entity.AddGraphic(_shaderSprite);
            }

            if (_input.MouseScreenX > Entity.X - _sprite.HalfWidth &&
                _input.MouseScreenX < Entity.X + _sprite.HalfWidth &&
                _input.MouseScreenY > Entity.Y - _sprite.HalfHeight &&
                _input.MouseScreenY < Entity.Y + _sprite.HalfHeight)
            {
                if (!_isHovered)
                {
                    OnHoverStartEvent?.Invoke();
                }
                _isHovered = true;
                _isPressed = _input.MouseButtonDown(MouseButton.Any);
            }
            else
            {
                if (_isHovered)
                {
                    OnHoverEndEvent?.Invoke();
                }
                _isHovered = false;
            }
        }
 public void InvokeHoverStart(GameObject _other)
 {
     OnHoverStart.Invoke(this, _other);
 }