示例#1
0
        public Effect Load(IEffectPartInfo info)
        {
            var pal = (PaletteEffectPartInfo)info;

            return(e =>
            {
                var palette = PaletteSystem.Get(pal.PaletteName);
                if (palette != null)
                {
                    palette.CurrentIndex = pal.PaletteIndex;
                }
            });
        }
示例#2
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);
        }