Exemplo n.º 1
0
        public RendererCreature(_Sprite defaultSprite, _Sprite liftingSprite = null)
        {
            _defaultSprite = defaultSprite.WithGrid(3, 4);

            if (liftingSprite != null)
            {
                _liftingSprite = liftingSprite.WithGrid(3, 4);
            }
            else
            {
                _liftingSprite = _defaultSprite;
            }

            _waterEffect = Resources.Sprites["water"].WithGrid(4, 1);
        }
Exemplo n.º 2
0
        public static void DrawBox(this SpriteBatch spriteBatch, _Sprite sprite, Rectangle dest, float scale, Color color)
        {
            sprite = sprite.WithGrid(3, 3);

            var topLeft = sprite.SubSprite(0, 0);

            spriteBatch.DrawSprite(
                topLeft,
                dest.X,
                dest.Y,
                topLeft.Width * scale,
                topLeft.Height * scale,
                color);

            var topRight = sprite.SubSprite(2, 0);

            spriteBatch.DrawSprite(
                topRight,
                dest.X + dest.Width - topRight.Width * scale,
                dest.Y,
                topRight.Width * scale,
                topRight.Height * scale,
                color);

            var bottomLeft = sprite.SubSprite(0, 2);

            spriteBatch.DrawSprite(
                bottomLeft,
                dest.X,
                dest.Y + dest.Height - bottomLeft.Height * scale,
                bottomLeft.Width * scale,
                bottomLeft.Height * scale,
                color);

            var bottomRight = sprite.SubSprite(2, 2);

            spriteBatch.DrawSprite(
                bottomRight,
                dest.X + dest.Width - bottomRight.Width * scale,
                dest.Y + dest.Height - bottomRight.Height * scale,
                bottomRight.Width * scale,
                bottomRight.Height * scale,
                color);

            var top = sprite.SubSprite(1, 0);

            spriteBatch.DrawSprite(
                top,
                dest.X + top.Width,
                dest.Y,
                dest.Width - top.Width * 2,
                top.Height * scale,
                color);

            var bottom = sprite.SubSprite(1, 2);

            spriteBatch.DrawSprite(
                bottom,
                dest.X + bottom.Width * scale,
                dest.Y + dest.Height - bottom.Width * scale,
                dest.Width - bottom.Width * 2 * scale,
                bottom.Height * scale,
                color);

            var left = sprite.SubSprite(0, 1);

            spriteBatch.DrawSprite(
                left,
                dest.X,
                dest.Y + left.Height * scale,
                left.Width * scale,
                dest.Height - left.Height * 2 * scale,
                color);

            var right = sprite.SubSprite(2, 1);

            spriteBatch.DrawSprite(
                right,
                dest.X + dest.Width - right.Width * scale,
                dest.Y + right.Height * scale,
                right.Width * scale,
                dest.Height - right.Height * 2 * scale,
                color);
        }