A floor resource.
Esempio n. 1
0
        //Gets a floor sprite. Used to draw floors cut in half by walls.
        private _2DSprite GetFloorSprite(Floor pattern, int rotation, WorldState world, byte cut)
        {
            var _Sprite = new _2DSprite()
            {
                RenderMode = _2DBatchRenderMode.Z_BUFFER
            };
            if (pattern == null) return _Sprite;
            SPR2 sprite = null;
            switch (world.Zoom)
            {
                case WorldZoom.Far:
                    sprite = pattern.Far;
                    _Sprite.DestRect = FLRDEST_FAR;
                    _Sprite.Depth = WallZBuffers[14];
                    break;
                case WorldZoom.Medium:
                    sprite = pattern.Medium;
                    _Sprite.DestRect = FLRDEST_MED;
                    _Sprite.Depth = WallZBuffers[13];
                    break;
                case WorldZoom.Near:
                    sprite = pattern.Near;
                    _Sprite.DestRect = FLRDEST_NEAR;
                    _Sprite.Depth = WallZBuffers[12];
                    break;
            }
            if (sprite != null)
            {
                _Sprite.Pixel = world._2D.GetTexture(sprite.Frames[rotation]);
                _Sprite.SrcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, _Sprite.Pixel.Width, _Sprite.Pixel.Height);
            }

            switch (cut)
            {
                case 0: //vertical cut, left side
                    _Sprite.DestRect.Width /= 2;
                    _Sprite.SrcRect.Width /= 2;
                    break;
                case 1: //vertical cut, right side
                    _Sprite.DestRect.X += _Sprite.DestRect.Width / 2;
                    _Sprite.DestRect.Width /= 2;
                    _Sprite.SrcRect.X += _Sprite.SrcRect.Width / 2;
                    _Sprite.SrcRect.Width /= 2;
                    break;
                case 2: //horizontal cut, top side
                    _Sprite.DestRect.Height /= 2;
                    _Sprite.SrcRect.Height /= 2;
                    break;
                case 3:
                    _Sprite.DestRect.Y += _Sprite.DestRect.Height / 2;
                    _Sprite.DestRect.Height /= 2;
                    _Sprite.SrcRect.Y += _Sprite.SrcRect.Height / 2;
                    _Sprite.SrcRect.Height /= 2;
                    break;
            }

            return _Sprite;
        }
Esempio n. 2
0
        private _2DSprite GetFloorSprite(Floor pattern, int rotation, WorldState world)
        {
            var _Sprite = new _2DSprite()
            {
                RenderMode = _2DBatchRenderMode.Z_BUFFER
            };
            if (pattern == null) return _Sprite;
            SPR2 sprite = null;
            bool vertFlip = world.Rotation == WorldRotation.TopRight || world.Rotation == WorldRotation.BottomRight;
            int bufOff = (vertFlip) ? 3 : 0;
            switch (world.Zoom)
            {
                case WorldZoom.Far:
                    sprite = pattern.Far;
                    _Sprite.DestRect = FLOORDEST_FAR;
                    _Sprite.Depth = ArchZBuffers[14+bufOff];
                    break;
                case WorldZoom.Medium:
                    sprite = pattern.Medium;
                    _Sprite.DestRect = FLOORDEST_MED;
                    _Sprite.Depth = ArchZBuffers[13 + bufOff];
                    break;
                case WorldZoom.Near:
                    sprite = pattern.Near;
                    _Sprite.DestRect = FLOORDEST_NEAR;
                    _Sprite.Depth = ArchZBuffers[12 + bufOff];
                    break;
            }
            if (sprite != null)
            {
                _Sprite.Pixel = world._2D.GetTexture(sprite.Frames[rotation]);
                _Sprite.SrcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, _Sprite.Pixel.Width, _Sprite.Pixel.Height);

                if (vertFlip) _Sprite.FlipVertically = true;
                if ((int)world.Rotation > 1) _Sprite.FlipHorizontally = true;
            }

            return _Sprite;
        }