Ejemplo n.º 1
0
 void DeathSequence()
 {
     Sprite.maskInteraction = SpriteMaskInteraction.VisibleOutsideMask;
     Prefab = Instantiate(Effect2, gameObject.transform);
     Prefab.transform.localPosition = new Vector3(0, 0, 0);
     Prefab.transform.localRotation = new Quaternion(0, 0, 0, 0);
     Transp = Prefab.GetComponent <ImageFlip>();
     Prefab.SetActive(true);
 }
Ejemplo n.º 2
0
 public void Prep()
 {
     Sprite = GetComponent <SpriteRenderer>();
     Sprite.maskInteraction = SpriteMaskInteraction.VisibleOutsideMask;
     Prefab = Instantiate(Effect, gameObject.transform);
     Prefab.transform.localPosition = new Vector3(0, 0, 0);
     Prefab.transform.localRotation = new Quaternion(0, 0, 0, 0);
     Transp = Prefab.GetComponent <ImageFlip>();
     Prefab.SetActive(true);
 }
Ejemplo n.º 3
0
 public void Render(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader = null, int?layer = null)
 {
     InternalRender(
         position,
         rotation,
         scale,
         flip,
         color,
         scroll,
         shader ?? Shader,
         layer ?? Layer
         );
 }
Ejemplo n.º 4
0
        public void SetTile(int x, int y, uint id, ImageFlip flipped, bool flippedDiagonally)
        {
            if (flippedDiagonally)
            {
                id |= Tiled.TiledTile.FlippedDiagonallyFlag;
            }

            if (flipped.HasFlag(ImageFlip.Horizontal))
            {
                id |= Tiled.TiledTile.FlippedHorizontallyFlag;
            }

            if (flipped.HasFlag(ImageFlip.Vertical))
            {
                id |= Tiled.TiledTile.FlippedVerticallyFlag;
            }

            SetTile(x, y, id);
        }
Ejemplo n.º 5
0
        private void InternalRender(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, int layer)
        {
#if DEBUG
            _lastPosition = position;
            _lastRotation = rotation;
            _lastScale    = scale;
            _lastFlip     = flip;
            _lastColor    = color;
            _lastScroll   = scroll;
#endif

            if (NeedsReload)
            {
                Load();
                NeedsReload = false;
            }

            BeforeDraw();
            Draw(position, rotation, scale, flip, color, scroll, shader, ShaderParameters, Origin, ConvertLayerToLayerDepth(layer));
            AfterDraw();
        }
Ejemplo n.º 6
0
        protected override void Draw(
            Vector2 position,
            float rotation,
            Vector2 scale,
            ImageFlip flip,
            Color color,
            Vector2 scroll,
            Shader shader,
            IShaderParameters shaderParameters,
            Vector2 origin,
            float layerDepth
        ) {
            if (_vertices == null
             || _vertices.Length == 0
             || _indices == null
             || _indices.Length == 0
            ) {
                return;
            }

            Renderer.DrawVertices(
                texture:            Texture,
                vertexData:         _vertices,
                minVertexIndex:     0,
                verticesLength:     _vertices.Length,
                indices:            _indices,
                minIndex:           0,
                primitivesCount:    _triangleCount,
                isHollow:           false,
                position:           position,
                rotation:           rotation,
                scale:              scale,
                color:              new Color(color, (color.A / 255f) * Opacity),
                origin:             origin,
                scroll:             scroll,
                shader:             shader,
                shaderParameters:   shaderParameters,
                layerDepth:         layerDepth
            );
        }
Ejemplo n.º 7
0
 protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
 {
     if (Filled)
     {
         Renderer.DrawFilledRectangle(
             position,
             Size,
             new Color(color, (color.A / 255f) * Opacity),
             rotation,
             scale,
             origin,
             scroll,
             shader,
             shaderParameters,
             layerDepth
             );
     }
     else
     {
         Renderer.DrawHollowRectangle(
             position,
             Size,
             new Color(color, (color.A / 255f) * Opacity),
             rotation,
             scale,
             origin,
             scroll,
             shader,
             shaderParameters,
             layerDepth
             );
     }
 }
Ejemplo n.º 8
0
        public void DrawString(Font font, Text.RenderData glyphs, Rectangle destinationRectangle, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader = null, IShaderParameters shaderParameters = null, float layerDepth = 1f)
        {
            if (Batch.BatchMode == BatchMode.Immediate)
            {
                PrepareBeforeRender();
                Batch.DrawString(font, glyphs, destinationRectangle, rotation, scale, flip, color, origin, scroll, shader, shaderParameters, layerDepth);
                AfterRender();
                return;
            }

            Batch.DrawString(font, glyphs, destinationRectangle, rotation, scale, flip, color, origin, scroll, shader, shaderParameters, layerDepth);
        }
Ejemplo n.º 9
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (Columns == 0 || Rows == 0 || TileSize.Area == 0)
            {
                return;
            }

            BasicShader bs = Game.Instance.BasicShader;

            // transformations
            bs.World = Microsoft.Xna.Framework.Matrix.CreateScale(scale.X, scale.Y, 1f)
                       * Microsoft.Xna.Framework.Matrix.CreateTranslation(-origin.X, -origin.Y, 0f)
                       * Microsoft.Xna.Framework.Matrix.CreateRotationZ(Math.ToRadians(rotation))
                       * Microsoft.Xna.Framework.Matrix.CreateTranslation(position.X, position.Y, 0f)
                       * Renderer.World;

            bs.View       = Renderer.View;
            bs.Projection = Renderer.Projection;

            // material
            bs.SetMaterial(color, Opacity);

            GraphicsDevice device = Game.Instance.GraphicsDevice;

            // texture
            bs.TextureEnabled = false;

            shaderParameters?.ApplyParameters(shader);

            // we need to manually update every GraphicsDevice states here
            device.BlendState        = Renderer.Batch.BlendState;
            device.SamplerStates[0]  = Renderer.Batch.SamplerState;
            device.DepthStencilState = Renderer.Batch.DepthStencilState;
            device.RasterizerState   = Renderer.Batch.RasterizerState;

            // grid
            foreach (object pass in bs)
            {
                device.Indices = _indexBuffer;
                device.SetVertexBuffer(_vertexBuffer);
                device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, _vertexBuffer.VertexCount, 0, Columns - 1 + (Rows - 1));
            }

            // borders
            if (_useBorderColor)
            {
                bs.SetMaterial(BorderColor, Opacity);
            }

            shaderParameters?.ApplyParameters(shader);

            // we need to manually update every GraphicsDevice states here
            device.BlendState        = Renderer.Batch.BlendState;
            device.SamplerStates[0]  = Renderer.Batch.SamplerState;
            device.DepthStencilState = Renderer.Batch.DepthStencilState;
            device.RasterizerState   = Renderer.Batch.RasterizerState;

            foreach (object pass in bs)
            {
                device.Indices = _indexBuffer;
                device.SetVertexBuffer(_vertexBuffer);
                device.DrawIndexedPrimitives(PrimitiveType.LineList, _usingVerticesCount - 4, 0, _vertexBuffer.VertexCount, _usingIndicesCount - 8, 4);
            }

            bs.ResetParameters();
        }
Ejemplo n.º 10
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (DestinationRegion.IsEmpty)
            {
                Renderer.Draw(
                    Texture,
                    position,
                    SourceRegion.Position + ClippingRegion,
                    rotation,
                    scale,
                    flip,
                    new Color(color, (color.A / 255f) * Opacity),
                    origin,
                    scroll,
                    shader,
                    shaderParameters,
                    layerDepth
                    );
                return;
            }

            Renderer.Draw(
                Texture,
                new Rectangle(position, DestinationRegion.Size * scale),
                SourceRegion.Position + ClippingRegion,
                rotation,
                flip,
                new Color(color, (color.A / 255f) * Opacity),
                origin,
                scroll,
                shader,
                shaderParameters,
                layerDepth
                );
        }
Ejemplo n.º 11
0
 protected abstract void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth);
Ejemplo n.º 12
0
        public void Draw(Canvas canvas, Rectangle destinationRectangle, Rectangle?sourceRectangle, float rotation, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader = null, IShaderParameters shaderParameters = null, float layerDepth = 1f)
        {
            if (Batch.BatchMode == BatchMode.Immediate)
            {
                PrepareBeforeRender();
                Batch.Draw(canvas.Texture, destinationRectangle, sourceRectangle, rotation, Vector2.One, flip, color, origin, scroll, shader, shaderParameters, layerDepth);
                AfterRender();
                return;
            }

            Batch.Draw(canvas.Texture, destinationRectangle, sourceRectangle, rotation, Vector2.One, flip, color, origin, scroll, shader, shaderParameters, layerDepth);
        }
Ejemplo n.º 13
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (_arcFill <= 0.001f)
            {
                return;
            }

            Renderer.DrawVertices(
                _vertices,
                minVertexIndex: 0,
                verticesLength: _vertices.Length,
                indices: _indices,
                minIndex: 0,
                primitivesCount: Math.EqualsEstimate(_arcFill, 1f) ? Segments : (int)Math.Round(_arcFill * Segments),
                isHollow: !Filled,
                position: position,
                rotation: rotation,
                scale: scale,
                color: new Color(color, (color.A / 255f) * Opacity),
                origin: origin,
                scroll: scroll,
                shader: shader,
                shaderParameters: shaderParameters,
                layerDepth: layerDepth
                );
        }
Ejemplo n.º 14
0
        public void Draw(Texture texture, Vector2 position, Rectangle?sourceRectangle, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, float layerDepth = 1f)
        {
            if (!IsBatching)
            {
                throw new System.InvalidOperationException("Begin() must be called before any Draw() operation.");
            }

            ref SpriteBatchItem batchItem = ref GetBatchItem(AutoHandleAlphaBlendedSprites && color.A < byte.MaxValue);
Ejemplo n.º 15
0
        public override void DebugRender(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll) {
            float x,
                  y = 0f;

            for (int row = 0; row < 3; row++) {
                float rowHeight = 0f;
                x = 0f;

                for (int column = 0; column < 3; column++) {
                    Patch patch = _patches[row * 3 + column];

                    Debug.Draw.Rectangle.AtWorld(
                        new Rectangle(
                            new Vector2(position.X + x, position.Y + y),
                            patch.Size
                        ),
                        false,
                        Colors.Magenta
                    );

                    x += patch.Width;

                    if (patch.Height > rowHeight) {
                        rowHeight = patch.Height;
                    }
                }

                y += rowHeight;
            }
        }
Ejemplo n.º 16
0
 public void Set(Texture texture, Vector2 position, Rectangle?sourceRectangle, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader = null, float layerDepth = 1f)
 {
     Set(texture, position, sourceRectangle, rotation, scale, flip, color, origin, scroll, shader, null, layerDepth);
 }
Ejemplo n.º 17
0
        public void Set(Texture texture, VertexPositionColorTexture[] vertexData, Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, float layerDepth = 1f)
        {
            Texture          = texture;
            Shader           = shader;
            ShaderParameters = shaderParameters;

            Vector2 topLeft     = (-origin + new Vector2(vertexData[0].Position.X, vertexData[0].Position.Y)) * scale,
                    topRight    = (-origin + new Vector2(vertexData[1].Position.X, vertexData[1].Position.Y)) * scale,
                    bottomRight = (-origin + new Vector2(vertexData[2].Position.X, vertexData[2].Position.Y)) * scale,
                    bottomLeft  = (-origin + new Vector2(vertexData[3].Position.X, vertexData[3].Position.Y)) * scale;

            if (rotation != 0)
            {
                float cos = Math.Cos(rotation),
                      sin = Math.Sin(rotation);

                topLeft     = new Vector2(topLeft.X * cos - topLeft.Y * sin, topLeft.X * sin + topLeft.Y * cos);
                topRight    = new Vector2(topRight.X * cos - topRight.Y * sin, topRight.X * sin + topRight.Y * cos);
                bottomRight = new Vector2(bottomRight.X * cos - bottomRight.Y * sin, bottomRight.X * sin + bottomRight.Y * cos);
                bottomLeft  = new Vector2(bottomLeft.X * cos - bottomLeft.Y * sin, bottomLeft.X * sin + bottomLeft.Y * cos);
            }

            VertexData[0] = new VertexPositionColorTexture(
                new Vector3(position + topLeft, layerDepth + vertexData[0].Position.Z),
                new Color(vertexData[0].Color) * color,
                vertexData[0].TextureCoordinate
                );

            VertexData[1] = new VertexPositionColorTexture(
                new Vector3(position + topRight, layerDepth + vertexData[1].Position.Z),
                new Color(vertexData[1].Color) * color,
                vertexData[1].TextureCoordinate
                );

            VertexData[2] = new VertexPositionColorTexture(
                new Vector3(position + bottomRight, layerDepth + vertexData[2].Position.Z),
                new Color(vertexData[2].Color) * color,
                vertexData[2].TextureCoordinate
                );

            VertexData[3] = new VertexPositionColorTexture(
                new Vector3(position + bottomLeft, layerDepth + vertexData[3].Position.Z),
                new Color(vertexData[3].Color) * color,
                vertexData[3].TextureCoordinate
                );

            if ((flip & ImageFlip.Horizontal) != ImageFlip.None)
            {
                Microsoft.Xna.Framework.Vector2 texCoord = VertexData[1].TextureCoordinate;
                VertexData[1].TextureCoordinate = VertexData[0].TextureCoordinate;
                VertexData[0].TextureCoordinate = texCoord;

                texCoord = VertexData[2].TextureCoordinate;
                VertexData[2].TextureCoordinate = VertexData[3].TextureCoordinate;
                VertexData[3].TextureCoordinate = texCoord;
            }

            if ((flip & ImageFlip.Vertical) != ImageFlip.None)
            {
                Microsoft.Xna.Framework.Vector2 texCoord = VertexData[2].TextureCoordinate;
                VertexData[2].TextureCoordinate = VertexData[1].TextureCoordinate;
                VertexData[1].TextureCoordinate = texCoord;

                texCoord = VertexData[3].TextureCoordinate;
                VertexData[3].TextureCoordinate = VertexData[0].TextureCoordinate;
                VertexData[0].TextureCoordinate = texCoord;
            }
        }
Ejemplo n.º 18
0
        public void Set(Texture texture, Vector2 position, Rectangle?sourceRectangle, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, float layerDepth = 1f)
        {
            if (!sourceRectangle.HasValue)
            {
                sourceRectangle = new Rectangle(texture.Size);
            }

            Rectangle destinationRectagle = new Rectangle(position, sourceRectangle.Value.Size);

            Set(texture, destinationRectagle, sourceRectangle, rotation, scale, flip, color, origin, scroll, shader, shaderParameters, layerDepth);
        }
Ejemplo n.º 19
0
        public void Set(Texture texture, Rectangle destinationRectangle, Rectangle?sourceRectangle, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, float layerDepth = 1f)
        {
            Texture          = texture;
            Shader           = shader;
            ShaderParameters = shaderParameters;

            if (!sourceRectangle.HasValue)
            {
                sourceRectangle = new Rectangle(texture.Size);
            }

            Vector2 topLeft     = -origin * scale,
                    topRight    = (-origin + new Vector2(destinationRectangle.Width, 0f)) * scale,
                    bottomRight = (-origin + destinationRectangle.Size) * scale,
                    bottomLeft  = (-origin + new Vector2(0f, destinationRectangle.Height)) * scale;

            if (rotation != 0)
            {
                float cos = Math.Cos(rotation),
                      sin = Math.Sin(rotation);

                topLeft     = new Vector2(topLeft.X * cos - topLeft.Y * sin, topLeft.X * sin + topLeft.Y * cos);
                topRight    = new Vector2(topRight.X * cos - topRight.Y * sin, topRight.X * sin + topRight.Y * cos);
                bottomRight = new Vector2(bottomRight.X * cos - bottomRight.Y * sin, bottomRight.X * sin + bottomRight.Y * cos);
                bottomLeft  = new Vector2(bottomLeft.X * cos - bottomLeft.Y * sin, bottomLeft.X * sin + bottomLeft.Y * cos);
            }

            VertexData[0] = new VertexPositionColorTexture(
                new Vector3(destinationRectangle.TopLeft + topLeft, layerDepth),
                color,
                new Microsoft.Xna.Framework.Vector2(sourceRectangle.Value.Left / texture.Width, sourceRectangle.Value.Top / texture.Height)
                );

            VertexData[1] = new VertexPositionColorTexture(
                new Vector3(destinationRectangle.TopLeft + topRight, layerDepth),
                color,
                new Microsoft.Xna.Framework.Vector2(sourceRectangle.Value.Right / texture.Width, sourceRectangle.Value.Top / texture.Height)
                );

            VertexData[2] = new VertexPositionColorTexture(
                new Vector3(destinationRectangle.TopLeft + bottomRight, layerDepth),
                color,
                new Microsoft.Xna.Framework.Vector2(sourceRectangle.Value.Right / texture.Width, sourceRectangle.Value.Bottom / texture.Height)
                );

            VertexData[3] = new VertexPositionColorTexture(
                new Vector3(destinationRectangle.TopLeft + bottomLeft, layerDepth),
                color,
                new Microsoft.Xna.Framework.Vector2(sourceRectangle.Value.Left / texture.Width, sourceRectangle.Value.Bottom / texture.Height)
                );

            if ((flip & ImageFlip.Horizontal) != ImageFlip.None)
            {
                Microsoft.Xna.Framework.Vector2 texCoord = VertexData[1].TextureCoordinate;
                VertexData[1].TextureCoordinate = VertexData[0].TextureCoordinate;
                VertexData[0].TextureCoordinate = texCoord;

                texCoord = VertexData[2].TextureCoordinate;
                VertexData[2].TextureCoordinate = VertexData[3].TextureCoordinate;
                VertexData[3].TextureCoordinate = texCoord;
            }

            if ((flip & ImageFlip.Vertical) != ImageFlip.None)
            {
                Microsoft.Xna.Framework.Vector2 texCoord = VertexData[2].TextureCoordinate;
                VertexData[2].TextureCoordinate = VertexData[1].TextureCoordinate;
                VertexData[1].TextureCoordinate = texCoord;

                texCoord = VertexData[3].TextureCoordinate;
                VertexData[3].TextureCoordinate = VertexData[0].TextureCoordinate;
                VertexData[0].TextureCoordinate = texCoord;
            }
        }
Ejemplo n.º 20
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (FrameCount > 0)
            {
                Rectangle frameDestination = _frames[CurrentFrameIndex].Destination;
                if (frameDestination.Position != Vector2.Zero)
                {
                    origin += frameDestination.Position;
                }
            }

            base.Draw(position, rotation, scale, flip, color, scroll, shader, shaderParameters, origin, layerDepth);
        }
Ejemplo n.º 21
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (Font == null || Data == null)
            {
                return;
            }

            if (shaderParameters == ShaderParameters)
            {
                if (ShaderParameters == null)
                {
                    if (Font.ShaderParameters != null)
                    {
                        shaderParameters = ShaderParameters = new TextShaderParameters(Font)
                        {
                            FontResolutionScale = FontResolutionScale,
                        };
                    }
                }
                else if (ShaderParameters is TextShaderParameters textShaderParameters)
                {
                    if (textShaderParameters.Font != Font)
                    {
                        textShaderParameters.Font = Font;
                    }

                    textShaderParameters.FontResolutionScale = FontResolutionScale;
                }
            }

            Renderer.DrawString(
                Font,
                Data,
                StartIndex,
                EndIndex < 0 ? (Data.GlyphCount + EndIndex + 1) : (EndIndex - StartIndex + 1),
                new Rectangle(position, UnscaledSize),
                rotation,
                scale,
                flip,
                color * Opacity,
                origin,
                scroll,
                shader ?? Font.Shader,
                shaderParameters,
                layerDepth
                );
        }
Ejemplo n.º 22
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (Shape.VertexCount == 0)
            {
                return;
            }

            if (Filled)
            {
                Renderer.DrawFilledPolygon(
                    Shape,
                    position,
                    new Color(color, (color.A / 255f) * Opacity),
                    rotation,
                    scale,
                    origin,
                    scroll,
                    shader,
                    shaderParameters,
                    layerDepth
                    );
            }
            else
            {
                Renderer.DrawHollowPolygon(
                    Shape,
                    position,
                    new Color(color, (color.A / 255f) * Opacity),
                    rotation,
                    scale,
                    origin,
                    scroll,
                    shader,
                    shaderParameters,
                    layerDepth
                    );
            }
        }
Ejemplo n.º 23
0
        public void Draw(Texture texture, Vector2 position, Rectangle?sourceRectangle, float rotation, float scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader = null, IShaderParameters shaderParameters = null, float layerDepth = 1f)
        {
            if (Batch.BatchMode == BatchMode.Immediate)
            {
                PrepareBeforeRender();
                Batch.Draw(texture, position, sourceRectangle, rotation, new Vector2(scale), flip, color, origin, scroll, shader, shaderParameters, layerDepth);
                AfterRender();
                return;
            }

            Batch.Draw(texture, position, sourceRectangle, rotation, new Vector2(scale), flip, color, origin, scroll, shader, shaderParameters, layerDepth);
        }
Ejemplo n.º 24
0
        public void DrawString(Font font, string text, Vector2 position, float rotation, float scale, ImageFlip flip, Color color, Vector2 origin, Vector2 scroll, Shader shader = null, IShaderParameters shaderParameters = null, float layerDepth = 1f)
        {
            if (Batch.BatchMode == BatchMode.Immediate)
            {
                PrepareBeforeRender();
                Batch.DrawString(font, text, position, rotation, new Vector2(scale), flip, color, origin, scroll, shader, shaderParameters, layerDepth);
                AfterRender();
                return;
            }

            Batch.DrawString(font, text, position, rotation, new Vector2(scale), flip, color, origin, scroll, shader, shaderParameters, layerDepth);
        }
Ejemplo n.º 25
0
        public override void DebugRender(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll)
        {
#if DEBUG
            /*
             * if (Sections == 0) {
             *  return;
             * }
             *
             * BasicShader bs = Game.Instance.BasicShader;
             *
             * // transformations
             * bs.World = Microsoft.Xna.Framework.Matrix.CreateTranslation(Position.X + position.X, Position.Y + position.Y, 0f)
             * Renderer.World;
             *
             * //bs.View = Microsoft.Xna.Framework.Matrix.Invert(scrollMatrix) * Renderer.View * scrollMatrix;
             * bs.View = Renderer.View;
             * bs.Projection = Renderer.Projection;
             *
             * // material
             * bs.SetMaterial(color, 1f);
             *
             * GraphicsDevice device = Game.Instance.GraphicsDevice;
             * foreach (object pass in bs) {
             *  device.Indices = _debug_indexBuffer;
             *  device.SetVertexBuffer(_vertexBuffer);
             *  device.DrawIndexedPrimitives(PrimitiveType.LineStrip, 0, 0, _vertexBuffer.VertexCount, 0, Sections * 6 - 1);
             * }
             *
             * bs.ResetParameters();
             */
#endif
        }
Ejemplo n.º 26
0
 public virtual void DebugRender(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll)
 {
 }
Ejemplo n.º 27
0
        protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
        {
            if (CurrentTrack != null && CurrentTrack.FramesDestinations != null)
            {
                // frame destination works like a guide to where render at local space
                // 'frameDestination.position' should be interpreted as 'origin'
                ref Rectangle frameDestination = ref CurrentTrack.CurrentFrameDestination;

                if (frameDestination.Position != Vector2.Zero)
                {
                    // frame region defines the crop rectangle at it's texture
                    ref Rectangle frameRegion = ref CurrentTrack.CurrentFrameRegion;

                    if (FlippedHorizontally)
                    {
                        if (FlippedVertically)
                        {
                            float rightSideSpacing  = frameDestination.Width - frameRegion.Width + frameDestination.X,
                                  bottomSideSpacing = frameDestination.Height - frameRegion.Height + frameDestination.Y;

                            origin = new Vector2(
                                (frameRegion.Width - origin.X) - rightSideSpacing,
                                (frameRegion.Height - origin.Y) - bottomSideSpacing
                                );
                        }
                        else
                        {
                            float rightSideSpacing = frameDestination.Width - frameRegion.Width + frameDestination.X;

                            origin = new Vector2(
                                (frameRegion.Width - origin.X) - rightSideSpacing,
                                origin.Y + frameDestination.Y
                                );
                        }
                    }
                    else if (FlippedVertically)
                    {
                        float bottomSideSpacing = frameDestination.Height - frameRegion.Height + frameDestination.Y;

                        origin = new Vector2(
                            origin.X + frameDestination.X,
                            (frameRegion.Height - origin.Y) - bottomSideSpacing
                            );
                    }
                    else
                    {
                        origin += frameDestination.Position;
                    }
                }
Ejemplo n.º 28
0
 protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
 {
     Renderer.DrawVertices(
         _vertices,
         minVertexIndex: 0,
         verticesLength: _vertices.Length,
         indices: _indices,
         minIndex: 0,
         primitivesCount: 2 * Segments,
         isHollow: false,
         position: position,
         rotation: rotation,
         scale: scale,
         color: new Color(color, (color.A / 255f) * Opacity),
         origin: origin,
         scroll: scroll,
         shader: shader,
         shaderParameters: shaderParameters,
         layerDepth: layerDepth
         );
 }
 protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
 {
     Graphic.Render(
         Graphic.Position + position,
         Graphic.Rotation + rotation,
         Graphic.Scale * scale,
         Graphic.Flipped ^ flip,
         Graphic.Color * color * Opacity,
         Graphic.Scroll * scroll,
         shader,
         Graphic.Layer + ConvertLayerDepthToLayer(layerDepth)
         );
 }
Ejemplo n.º 30
0
 protected override void Draw(Vector2 position, float rotation, Vector2 scale, ImageFlip flip, Color color, Vector2 scroll, Shader shader, IShaderParameters shaderParameters, Vector2 origin, float layerDepth)
 {
     Renderer.DrawLines(
         Points,
         position,
         new Color(color, (color.A / 255f) * Opacity),
         rotation,
         scale,
         origin,
         scroll,
         shader,
         shaderParameters,
         cyclic: false,
         layerDepth: layerDepth
         );
 }