public void Draw(IResourceImage resource, int layer, MegaMan.Common.Geometry.Point position, MegaRect? sourceRect = null, bool flipHorizontal = false, bool flipVertical = false)
        {
            if (!IsLayerEnabled(layer)) return;

            var texture = _loadedTextures[resource.ResourceId];
            var batch = _spriteBatchLayers[layer];

            if (resource.PaletteName != null)
            {
                var palette = PaletteSystem.Get(resource.PaletteName);
                if (palette != null)
                {
                    VerifyPaletteSwaps(palette, resource.ResourceId, texture);
                    texture = this._paletteSwaps[resource.ResourceId][palette.CurrentIndex];
                }
            }

            var destination = new Vector2(position.X, position.Y);

            XnaRect? source = null;
            if (sourceRect != null)
                source = new XnaRect(sourceRect.Value.X, sourceRect.Value.Y, sourceRect.Value.Width, sourceRect.Value.Height);

            SpriteEffects effect = SpriteEffects.None;
            if (flipHorizontal) effect = SpriteEffects.FlipHorizontally;
            if (flipVertical) effect |= SpriteEffects.FlipVertically;

            batch.Draw(texture,
                destination, source,
                _opacityColor, 0,
                Vector2.Zero, 1, effect, 0);
        }
Example #2
0
        void Instance_GameRender(GameRenderEventArgs e)
        {
            if (!Engine.Instance.DrawHitboxes)
            {
                return;
            }
            foreach (CollisionBox hitbox in hitboxes)
            {
                if (!enabledBoxes.Contains(hitbox.ID))
                {
                    continue;
                }

                hitbox.SetParent(this);
                var boundBox = hitbox.BoxAt(PositionSrc.Position);
                boundBox.Offset(-Parent.Screen.OffsetX, -Parent.Screen.OffsetY);

                if (rectTex == null)
                {
                    rectTex = e.RenderContext.CreateColorResource(new MegaMan.Common.Color(1, 0.6f, 0, 0.7f));
                }

                e.RenderContext.Draw(rectTex, 5, new Common.Geometry.Point((int)(boundBox.X), (int)(boundBox.Y)), new Common.Geometry.Rectangle(0, 0, (int)(boundBox.Width), (int)(boundBox.Height)));
            }
        }
Example #3
0
            public void Draw(IRenderingContext renderContext, int layer, string text, Point position)
            {
                if (charTex == null)
                    charTex = renderContext.LoadResource(info.ImagePath);

                if (!info.CaseSensitive)
                {
                    text = text.ToUpper();
                }

                int xpos = position.X;

                foreach (char c in text)
                {
                    if (c == ' ')
                    {
                        xpos += info.CharWidth;
                        continue;
                    }

                    var location = info[c];

                    if (location != null)
                    {
                        renderContext.Draw(charTex, layer, new Point(xpos, position.Y),
                            new Rectangle(location.Value.X, location.Value.Y, info.CharWidth, info.CharWidth));

                        xpos += info.CharWidth;
                    }
                }
            }
Example #4
0
            public void Draw(IRenderingContext renderContext, int layer, string text, Point position)
            {
                if (charTex == null)
                {
                    charTex = renderContext.LoadResource(info.ImagePath);
                }

                if (!info.CaseSensitive)
                {
                    text = text.ToUpper();
                }

                int xpos = position.X;

                foreach (char c in text)
                {
                    if (c == ' ')
                    {
                        xpos += info.CharWidth;
                        continue;
                    }

                    var location = info[c];

                    if (location != null)
                    {
                        renderContext.Draw(charTex, layer, new Point(xpos, position.Y),
                                           new Rectangle(location.Value.X, location.Value.Y, info.CharWidth, info.CharWidth));

                        xpos += info.CharWidth;
                    }
                }
            }
Example #5
0
        public void Draw(IRenderingContext context, int layer, float positionX, float positionY)
        {
            if (!Visible || Count == 0 || context == null)
            {
                return;
            }

            if (texture == null)
            {
                texture = context.LoadResource(SheetPath, PaletteName);
            }

            bool flipHorizontal = HorizontalFlip ^ Reversed;
            bool flipVertical   = VerticalFlip;

            int hx = (HorizontalFlip ^ Reversed) ? Width - HotSpot.X : HotSpot.X;
            int hy = VerticalFlip ? Height - HotSpot.Y : HotSpot.Y;

            var drawTexture = this.texture;

            context.Draw(drawTexture, layer,
                         new Common.Geometry.Point((int)(positionX - hx), (int)(positionY - hy)),
                         new Common.Geometry.Rectangle(CurrentFrame.SheetLocation.X, CurrentFrame.SheetLocation.Y, CurrentFrame.SheetLocation.Width, CurrentFrame.SheetLocation.Height),
                         flipHorizontal, flipVertical);
        }
        public void Draw(IRenderingContext renderContext)
        {
            if (texture == null)
                texture = renderContext.CreateColorResource(color);

            renderContext.Draw(texture, layer, new MegaMan.Common.Geometry.Point((int)x, (int)y),
                new MegaMan.Common.Geometry.Rectangle((int)x, (int)y, (int)width, (int)height));
        }
        public void Draw(IRenderingContext renderContext)
        {
            if (texture == null)
            {
                texture = renderContext.CreateColorResource(color);
            }

            renderContext.Draw(texture, layer, new MegaMan.Common.Geometry.Point((int)x, (int)y),
                               new MegaMan.Common.Geometry.Rectangle((int)x, (int)y, (int)width, (int)height));
        }
Example #8
0
        public void Draw(IResourceImage resource, int layer, MegaMan.Common.Geometry.Point position, MegaRect?sourceRect = null, bool flipHorizontal = false, bool flipVertical = false)
        {
            if (!IsLayerEnabled(layer))
            {
                return;
            }

            var texture = _loadedTextures[resource.ResourceId];
            var batch   = _spriteBatchLayers[layer];

            if (resource.PaletteName != null)
            {
                var palette = PaletteSystem.Get(resource.PaletteName);
                if (palette != null)
                {
                    VerifyPaletteSwaps(palette, resource.ResourceId, texture);
                    texture = this._paletteSwaps[resource.ResourceId][palette.CurrentIndex];
                }
            }

            var destination = new Vector2(position.X, position.Y);

            XnaRect?source = null;

            if (sourceRect != null)
            {
                source = new XnaRect(sourceRect.Value.X, sourceRect.Value.Y, sourceRect.Value.Width, sourceRect.Value.Height);
            }

            SpriteEffects effect = SpriteEffects.None;

            if (flipHorizontal)
            {
                effect = SpriteEffects.FlipHorizontally;
            }
            if (flipVertical)
            {
                effect |= SpriteEffects.FlipVertically;
            }

            batch.Draw(texture,
                       destination, source,
                       _opacityColor, 0,
                       Vector2.Zero, 1, effect, 0);
        }
Example #9
0
        private void Draw(IRenderingContext context, float positionX, float positionY)
        {
            if (meterTexture == null)
            {
                meterTexture = context.LoadResource(this.info.Background);
                bounds       = new RectangleF(positionX, positionY, meterTexture.Width, meterTexture.Height);
            }

            if (tickTexture == null)
            {
                tickTexture = context.LoadResource(this.info.TickImage);
            }

            if (tickTexture != null)
            {
                int i     = 0;
                int ticks = (int)Math.Ceiling(value / tickSize);
                // prevent float errors
                if (ticks > 28)
                {
                    ticks = 28;
                }

                if (meterTexture != null)
                {
                    context.Draw(meterTexture, 4, new Common.Geometry.Point((int)positionX, (int)positionY));
                }

                if (horizontal)
                {
                    for (int y = (int)positionX; i < ticks; i++, y += tickTexture.Width)
                    {
                        context.Draw(tickTexture, 4, new Common.Geometry.Point(y, (int)positionY));
                    }
                }
                else
                {
                    for (int y = 54 + (int)positionY; i < ticks; i++, y -= tickTexture.Height)
                    {
                        context.Draw(tickTexture, 4, new Common.Geometry.Point((int)(positionX + tickOffset.X), (int)(y + tickOffset.Y)));
                    }
                }
            }
        }
Example #10
0
        private void Draw(IRenderingContext context, float positionX, float positionY)
        {
            if (meterTexture == null)
            {
                meterTexture = context.LoadResource(this.info.Background);
                bounds = new RectangleF(positionX, positionY, meterTexture.Width, meterTexture.Height);
            }

            if (tickTexture == null)
                tickTexture = context.LoadResource(this.info.TickImage);

            if (tickTexture != null)
            {
                int i = 0;
                int ticks = (int)Math.Ceiling(value / tickSize);
                // prevent float errors
                if (ticks > 28) ticks = 28;

                if (meterTexture != null)
                    context.Draw(meterTexture, 4, new Common.Geometry.Point((int)positionX, (int)positionY));

                if (horizontal)
                {
                    for (int y = (int)positionX; i < ticks; i++, y += tickTexture.Width)
                    {
                        context.Draw(tickTexture, 4, new Common.Geometry.Point(y, (int)positionY));
                    }
                }
                else
                {
                    for (int y = 54 + (int)positionY; i < ticks; i++, y -= tickTexture.Height)
                    {
                        context.Draw(tickTexture, 4, new Common.Geometry.Point((int)(positionX + tickOffset.X), (int)(y + tickOffset.Y)));
                    }
                }
            }
        }
Example #11
0
        void Instance_GameRender(GameRenderEventArgs e)
        {
            if (!Engine.Instance.DrawHitboxes) return;
            foreach (CollisionBox hitbox in hitboxes)
            {
                if (!enabledBoxes.Contains(hitbox.ID)) continue;

                RectangleF boundBox = hitbox.BoxAt(PositionSrc.Position);
                boundBox.Offset(-Parent.Screen.OffsetX, -Parent.Screen.OffsetY);

                if (rectTex == null)
                    rectTex = e.RenderContext.CreateColorResource(new MegaMan.Common.Color(1, 0.6f, 0, 0.7f));

                e.RenderContext.Draw(rectTex, 5, new Common.Geometry.Point((int)(boundBox.X), (int)(boundBox.Y)), new Common.Geometry.Rectangle(0, 0, (int)(boundBox.Width), (int)(boundBox.Height)));
            }
        }