public override void Draw(GraphicsDevice device, WorldState world) { if(_Dirty){ if (_Floor == null){ _Floor = Content.Get().WorldFloors.Get((ulong)_FloorID); if (_Floor != null) { _Sprite = new _2DSprite { RenderMode = _2DBatchRenderMode.NO_DEPTH }; } } if (_DirtyTexture && _Floor != null){ SPR2 sprite = null; switch(world.Zoom){ case WorldZoom.Far: sprite = _Floor.Far; _Sprite.DestRect = DESTINATION_FAR; break; case WorldZoom.Medium: sprite = _Floor.Medium; _Sprite.DestRect = DESTINATION_MED; break; case WorldZoom.Near: sprite = _Floor.Near; _Sprite.DestRect = DESTINATION_NEAR; break; } if (world.Rotation == WorldRotation.TopRight || world.Rotation == WorldRotation.BottomRight) _Sprite.FlipVertically = true; if ((int)world.Rotation > 1) _Sprite.FlipHorizontally = true; //todo - find out why these don't work (really it is a mystery) _Sprite.Pixel = world._2D.GetTexture(sprite.Frames[0]); _Sprite.SrcRect = new Microsoft.Xna.Framework.Rectangle(0, 0, _Sprite.Pixel.Width, _Sprite.Pixel.Height); } _DirtyTexture = false; _Dirty = false; } if (_Sprite != null){ world._2D.Draw(_Sprite); } }
//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; }
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; }