Inheritance: VirtualGamePadControlSkin
Ejemplo n.º 1
0
 public VirtualGamePadSkin()
 {
     LeftStick     = new VirtualGamePadStickSkin();
     RightStick    = new VirtualGamePadStickSkin();
     A             = new VirtualGamePadButtonSkin();
     B             = new VirtualGamePadButtonSkin();
     X             = new VirtualGamePadButtonSkin();
     Y             = new VirtualGamePadButtonSkin();
     DpadLeft      = new VirtualGamePadButtonSkin();
     DpadRight     = new VirtualGamePadButtonSkin();
     DpadUp        = new VirtualGamePadButtonSkin();
     DpadDown      = new VirtualGamePadButtonSkin();
     LeftShoulder  = new VirtualGamePadButtonSkin();
     RightShoulder = new VirtualGamePadButtonSkin();
     Start         = new VirtualGamePadButtonSkin();
     LeftTrigger   = new VirtualGamePadButtonSkin();
     RightTrigger  = new VirtualGamePadButtonSkin();
 }
Ejemplo n.º 2
0
 public VirtualGamePadSkin()
 {
     LeftStick = new VirtualGamePadStickSkin();
     RightStick = new VirtualGamePadStickSkin();
     A = new VirtualGamePadButtonSkin();
     B = new VirtualGamePadButtonSkin();
     X = new VirtualGamePadButtonSkin();
     Y = new VirtualGamePadButtonSkin();
     DpadLeft = new VirtualGamePadButtonSkin();
     DpadRight = new VirtualGamePadButtonSkin();
     DpadUp = new VirtualGamePadButtonSkin();
     DpadDown = new VirtualGamePadButtonSkin();
     LeftShoulder = new VirtualGamePadButtonSkin();
     RightShoulder = new VirtualGamePadButtonSkin();
     Start = new VirtualGamePadButtonSkin();
     LeftTrigger = new VirtualGamePadButtonSkin();
     RightTrigger = new VirtualGamePadButtonSkin();
 }
Ejemplo n.º 3
0
        private void DrawStick(VirtualGamePadStickSkin stickSkin, TouchMap touchMap, float elapsedTime)
        {
            if (stickSkin.AreaTexture == null || touchMap.TouchArea == Rectangle.Empty) return;

            var areaTexture = stickSkin.AreaTexture;
            Vector2 areaPosition, thumbPosition = Vector2.Zero;

            if(touchMap.Static)
            {
                areaPosition = new Vector2(touchMap.TouchArea.X + touchMap.TouchArea.Width/2f, touchMap.TouchArea.Y + touchMap.TouchArea.Height/2f);
            }
            else
            {
                areaPosition = touchMap.CenterPosition - new Vector2(areaTexture.Width/2f, areaTexture.Height/2f);
            }

            if(stickSkin.ThumbStickTexture != null)
            {
                if (touchMap.Id != -1)
                {
                    var direction = (touchMap.CenterPosition - touchMap.CurrentPosition) / stickSkin.MaxThumbStickDistance;
                    if(direction.LengthSquared() > 1f)
                        direction.Normalize();

                    thumbPosition = touchMap.CenterPosition - (direction * stickSkin.MaxThumbStickDistance) - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f);
                }
                else
                {
                    thumbPosition = touchMap.CenterPosition - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f);
                }
            }

            if (stickSkin.SensibleVisibility || touchMap.Id != -1)
            {
                stickSkin.Opacity = stickSkin.MaxOpacity;
            }
            else
            {
                stickSkin.Opacity -= elapsedTime;
                if (stickSkin.Opacity < stickSkin.MinOpacity)
                    stickSkin.Opacity = stickSkin.MinOpacity;
            }

            _virtualGamePadRenderer.Draw(
                areaTexture,
                areaPosition,
                Color.White * stickSkin.Opacity);

            if (stickSkin.ThumbStickTexture != null)
            {
                var thumbStickTexture = stickSkin.ThumbStickTexture;
                _virtualGamePadRenderer.Draw(
                    thumbStickTexture,
                    thumbPosition,
                    Color.White * stickSkin.Opacity);
            }
        }
Ejemplo n.º 4
0
        private void DrawStick(VirtualGamePadStickSkin stickSkin, TouchMap touchMap, float elapsedTime)
        {
            if (stickSkin.AreaTexture == null || touchMap.TouchArea == Rectangle.Empty)
            {
                return;
            }

            var     areaTexture = stickSkin.AreaTexture;
            Vector2 areaPosition, thumbPosition = Vector2.Zero;

            if (touchMap.Static)
            {
                areaPosition = new Vector2(touchMap.TouchArea.X + touchMap.TouchArea.Width / 2f, touchMap.TouchArea.Y + touchMap.TouchArea.Height / 2f);
            }
            else
            {
                areaPosition = touchMap.CenterPosition - new Vector2(areaTexture.Width / 2f, areaTexture.Height / 2f);
            }

            if (stickSkin.ThumbStickTexture != null)
            {
                if (touchMap.Id != -1)
                {
                    var direction = (touchMap.CenterPosition - touchMap.CurrentPosition) / stickSkin.MaxThumbStickDistance;
                    if (direction.LengthSquared() > 1f)
                    {
                        direction.Normalize();
                    }

                    thumbPosition = touchMap.CenterPosition - (direction * stickSkin.MaxThumbStickDistance) - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f);
                }
                else
                {
                    thumbPosition = touchMap.CenterPosition - new Vector2(stickSkin.ThumbStickTexture.Width / 2f, stickSkin.ThumbStickTexture.Height / 2f);
                }
            }

            if (stickSkin.SensibleVisibility || touchMap.Id != -1)
            {
                stickSkin.Opacity = stickSkin.MaxOpacity;
            }
            else
            {
                stickSkin.Opacity -= elapsedTime;
                if (stickSkin.Opacity < stickSkin.MinOpacity)
                {
                    stickSkin.Opacity = stickSkin.MinOpacity;
                }
            }

            _virtualGamePadRenderer.Draw(
                areaTexture,
                areaPosition,
                Color.White * stickSkin.Opacity);

            if (stickSkin.ThumbStickTexture != null)
            {
                var thumbStickTexture = stickSkin.ThumbStickTexture;
                _virtualGamePadRenderer.Draw(
                    thumbStickTexture,
                    thumbPosition,
                    Color.White * stickSkin.Opacity);
            }
        }