예제 #1
0
        public override void Draw()
        {
            base.Draw();

            var startingPosition = new Vector2(64, 64);
            var position         = startingPosition;
            var spacing          = 100;

            GraphicsMgr.CurrentColor = Color.White;

            _fireSprite.Draw(position, _fireAnimation.Progress, Vector2.Zero, Vector2.One, Angle.Right, Color.White);

            position += Vector2.UnitX * spacing;
            CircleShape.Draw(position, 8, _autoAlarmSwitch);

            position += Vector2.UnitX * 32;
            CircleShape.Draw(position, 8, _slowAlarmSwitch);

            position += Vector2.UnitX * 32;
            CircleShape.Draw(position, 8, _counterSwitch);

            position += Vector2.UnitX * 32;
            GraphicsMgr.CurrentColor = _color;
            if (_isRectangle)
            {
                RectangleShape.DrawBySize(position, Vector2.One * 16, _isOutline);
            }
            else
            {
                CircleShape.Draw(position, 8, _isOutline);
            }
        }
예제 #2
0
        public override void Draw()
        {
            GraphicsMgr.CurrentColor = Color.Red * 0.3f;
            var position = GetComponent <PositionComponent>();

            RectangleShape.DrawBySize(position.Position, Size, false);
        }
예제 #3
0
 /// <summary>
 /// Draws a quadtree's node.
 /// NOTE: This is a debug-only method.
 /// </summary>
 public void Draw()
 {
     if (IsLeaf)
     {
         RectangleShape.DrawBySize(Position, Size, true);
         Text.Draw((_items.Count + _immovableItems.Count) + "", Position);
     }
     else
     {
         for (var i = 0; i < 4; i += 1)
         {
             _childNodes[i].Draw();
         }
     }
 }
예제 #4
0
        public void Draw()
        {
            // Transform matrices took care of the rotations,
            // so all panels assume they are drawn with no rotation\offset.
            RectangleShape.DrawBySize(Offset - Vector2.UnitY * Size / 2f, Size, true);

            CircleShape.Draw(Offset, 4, true);

            LineShape.Draw(Offset, Offset - Vector2.UnitY * 8);

            if (Attachments == null)
            {
                return;
            }

            // Transform matrices stack.
            GraphicsMgr.AddTransformMatrix(
                Matrix.CreateTranslation(-(Vector2.UnitY * Size / 2f).ToVector3())
                );
            foreach (var panel in Attachments)
            {
                // We need to offset the child panel by half of parent's
                // width or height depending on the side.
                var length     = Size.X / 2f;
                var resultSide = panel.Side;
                if (panel.Side % 2 == 0)
                {
                    length = Size.Y / 2f;
                }

                GraphicsMgr.AddTransformMatrix(
                    //Matrix.CreateRotationZ(0.3f) // Future reference - use this to pivot the panels.
                    Matrix.CreateTranslation(-(Vector2.UnitY * length).ToVector3())
                    * Matrix.CreateRotationZ((float)(Math.PI - Math.PI / 2f * resultSide))
                    * Matrix.CreateTranslation(Offset.ToVector3())
                    );
                panel.Draw();
                GraphicsMgr.ResetTransformMatrix();
            }

            GraphicsMgr.ResetTransformMatrix();
        }
예제 #5
0
        public override void Draw()
        {
            base.Draw();

            var startingPosition = new Vector2(64, 64);
            var position         = startingPosition;
            var spacing          = 100;

            GraphicsMgr.CurrentColor = _mainColor;

            // This position accounts for current camera transform matrix.
            // Visually it will be at the pointer's position when camera will move.
            CircleShape.Draw(Input.MousePosition, 4, false);

            // This position only accounts for screen transformation.
            // When the camera will move, it will offset.
            CircleShape.Draw(Input.ScreenMousePosition, 8, true);

            // You can also get mouse position from any camera.
            // This method can be used in Update, when no camera is active.
            CircleShape.Draw(GraphicsMgr.CurrentCamera.GetRelativeMousePosition(), 12, true);


            Text.CurrentFont = ResourceHub.GetResource <IFont>("Fonts", "Arial");

            Text.Draw("Keyboard input: " + _keyboardInput.ToString(), position);


            // Gamepad, mouse and keyboard buttons are using the same method.
            position += Vector2.UnitY * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(KeyboardTestButton));
            position += Vector2.UnitX * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(GamepadTestButton));
            position += Vector2.UnitX * 64;
            CircleShape.Draw(position, 16, Input.CheckButton(MouseTestButton));


            position = new Vector2(200, 200);

            if (Input.GamepadConnected(0))
            {
                Text.Draw("Gamepad is connected!", position);
            }
            else
            {
                Text.Draw("Gamepad is not connected.", position);
            }


            // Sticks.
            position += Vector2.UnitY * 96;
            CircleShape.Draw(position, 64, true);
            CircleShape.Draw(position + Input.GamepadGetLeftStick(0) * 64 * new Vector2(1, -1), 16, false);
            position += Vector2.UnitX * (128 + 64);
            CircleShape.Draw(position, 64, true);
            CircleShape.Draw(position + Input.GamepadGetRightStick(0) * 64 * new Vector2(1, -1), 16, false);

            // Triggers.
            position -= Vector2.UnitX * (64 + 16);
            RectangleShape.DrawBySize(position + Vector2.UnitY * Input.GamepadGetRightTrigger(0) * 64, Vector2.One * 8, false);
            LineShape.Draw(position, position + Vector2.UnitY * 64);
            position -= Vector2.UnitX * 32;
            RectangleShape.DrawBySize(position + Vector2.UnitY * Input.GamepadGetLeftTrigger(0) * 64, Vector2.One * 8, false);
            LineShape.Draw(position, position + Vector2.UnitY * 64);
        }
예제 #6
0
        public override void Draw()
        {
            base.Draw();

            _secondaryColor.H += TimeKeeper.Global.Time(360 / 4f);
            if (_secondaryColor.H >= 360f)
            {
                _secondaryColor.H -= 360;
            }
            Debug.WriteLine(_secondaryColor.H);

            // This code shows how to draw shapes using static methods and instanced objects.

            var startingPosition = new Vector2(100, 100);
            var position         = startingPosition;
            var spacing          = 100;

            // Circles.
            GraphicsMgr.CurrentColor = _mainColor;             // Setting current color. It's active for all shapes and sprites.
            CircleShape.Draw(position, 24, false);             // Filled circle.

            GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
            CircleShape.Draw(position, 32, true);             // Outline.


            position += Vector2.UnitX * spacing;


            CircleShape.CircleVerticesCount = 8;             // Changing the amount of circle vertices.

            GraphicsMgr.CurrentColor = _mainColor;
            CircleShape.Draw(position, 24, false);

            GraphicsMgr.CurrentColor = _secondaryColor.ToColor();
            CircleShape.Draw(position, 32, true);

            CircleShape.CircleVerticesCount = 32;
            // Circles.


            position  += Vector2.UnitY * spacing;
            position.X = startingPosition.X;


            // Rectangles.

            // You can draw rectangle using its top left and bottom right point...
            RectangleShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24, false);

            GraphicsMgr.CurrentColor = _mainColor;
            // ...or its center position and size!
            RectangleShape.DrawBySize(position, Vector2.One * 64, true);

            position += Vector2.UnitX * spacing;

            RectangleShape.Draw(             // We can also manually set colors for each vertex.
                position - Vector2.One * 24,
                position + Vector2.One * 24,
                false,
                _mainColor,
                _mainColor,
                _mainColor,
                _secondaryColor.ToColor()
                );

            RectangleShape.DrawBySize(
                position,
                Vector2.One * 64,
                true,
                _mainColor,
                _secondaryColor.ToColor(),
                _mainColor,
                _mainColor
                );
            // Rectangles.


            position  += Vector2.UnitY * spacing;
            position.X = startingPosition.X;


            // Triangles.

            _triangle.Position = position;
            _triangle.Draw();             // Drawing an instantiated triangle.

            GraphicsMgr.CurrentColor = _mainColor;

            TriangleShape.Draw(
                position + new Vector2(-24, -24),
                position + new Vector2(24, -24),
                position + new Vector2(24, 24),
                false
                );

            // Be aware of culling. This triangle, for example, will be culled.
            // You can disable culling, if you don't want to deal with it.
            TriangleShape.Draw(new Vector2(-24, -24), new Vector2(24, 24), new Vector2(24, -24), false);

            // Triangles.



            // Lines.

            position += Vector2.UnitX * spacing;
            LineShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24);

            position += Vector2.UnitX * spacing / 2f;
            ThickLineShape.Draw(position - Vector2.One * 24, position + Vector2.One * 24, 5);

            // Lines.
        }
예제 #7
0
        public override void Draw()
        {
            var position = GetComponent <PositionComponent>();

            RectangleShape.DrawBySize(position.Position, Size, true);
        }
예제 #8
0
        public override void Draw()
        {
            base.Draw();

            var startingPosition = new Vector2(100, 100);
            var position         = startingPosition;
            var spacing          = 100;


            // Sprites can't have static methods.
            _monofoxeSprite.Draw(position);

            position += Vector2.UnitX * spacing * 2;

            // Setting a shader for the sprite.
            GraphicsMgr.VertexBatch.Effect = _seizure;

            // If you want to animate the sprite, you must pass a value from 0 to 1 to it.
            _fireSprite.Draw(position, _animation);
            GraphicsMgr.VertexBatch.Effect = null;

            position += Vector2.UnitX * spacing;

            // You can also access sprite's frame array, if you want to draw a specific frame.
            _fireSprite[2].Draw(position, _fireSprite.Origin);

            position += Vector2.UnitX * spacing;

            // You can scale, rotate srites and set custom origin point.

            _fireSprite.Draw(
                position,
                0.4f,
                new Vector2(_fireSprite.Width, _fireSprite.Height) / 2,
                new Vector2(1, 2) * (float)Math.Sin(_animation * Math.PI * 2 * 2),
                new Angle(360 * _animation),
                Color.Red
                );


            position += Vector2.UnitX * spacing;

            // You also can draw only a part of the sprite.
            _monofoxeSprite.Draw(
                new RectangleF(position.X, position.Y, 64, 64),
                0,
                new RectangleF(64, 64, 64, 64),
                Angle.Right,
                Color.White
                );


            position  += Vector2.UnitY * spacing * 1.5f;
            position.X = 0;


            // You can extract raw texture from the frames. Note that you will get the whole texture atlas.
            var texture         = _monofoxeSprite[0].Texture;
            var texturePosition = _monofoxeSprite[0].TexturePosition;             // This will give you texture's position on the atlas.

            // We can also use default Monogame's SpriteBatch (or anything, for that matter).

            // But beforehand we must flush Monofoxe's own batcher.
            // This method draws all batched graphics.
            GraphicsMgr.VertexBatch.FlushBatch();

            // After that, you can draw anything you like using any method.

            _batch.Begin(
                SpriteSortMode.Deferred,
                null,
                SamplerState.PointWrap,
                null,
                null,
                null,
                GraphicsMgr.VertexBatch.View
                );
            _batch.Draw(texture, position, GraphicsMgr.CurrentColor);

            _batch.End();

            // After you're done, you can draw anything you like without switching graphics mode again.
            RectangleShape.Draw(position, position + new Vector2(texture.Width, texture.Height), true);


            position += Vector2.UnitX * 512;

            GraphicsMgr.CurrentColor = Color.Red;
            Surface.SetTarget(_surface);

            var po = new Vector2(_surface.Width, _surface.Height) / 2 + new Angle(GameMgr.ElapsedTimeTotal * 10).ToVector2() * 64;

            RectangleShape.DrawBySize(po, Vector2.One * 8, false);

            Surface.ResetTarget();

            _surface.Draw(position);

            position += new Vector2(16, 150);

            GraphicsMgr.CurrentColor = Color.White;
            Text.CurrentFont         = ResourceHub.GetResource <IFont>("Fonts", "Arial");
            Text.Draw("This text is drawn using default" + Environment.NewLine + "Monogame spritefont.", position);
            position        += Vector2.UnitY * 48;
            Text.CurrentFont = ResourceHub.GetResource <IFont>("Fonts", "FancyFont");
            Text.Draw("This text is drawn using custom" + Environment.NewLine + "font made from a sprite.", position, Vector2.One * 1.1f, Vector2.Zero, new Angle(-10));
        }
예제 #9
0
 public void Draw(bool isOutline) =>
 RectangleShape.DrawBySize(Position, HalfSize * 2, isOutline);