public BlockData(Vector2 position, FigureData figureData, bool bloquea) { Position = position; FigureData = figureData; RectangleInWorld = new Rectangle((int)Position.X, (int)Position.Y, FigureData.Rect.Width, FigureData.Rect.Height); Bloquea = bloquea; }
public override void Draw(GameTime gameTime) { #if SHOW_CAMERAS SpriteBatch sb = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); FigureData fd = TextureManager.Figures [FigureEnum.MarcaCamera]; foreach (CameraBlock cb in camerasInTheWorld) { Rectangle vp = _currentCamera.CurrentViewPort; if (vp.Intersects(cb.Region)) { Rectangle inScreen = new Rectangle(cb.Region.X - vp.X, cb.Region.Y - vp.Y, cb.Region.Width, cb.Region.Height); sb.Draw(fd.Container, inScreen, fd.Rect, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, fd.Depth); } } #endif base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { SpriteBatch sb = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); Rectangle currentView = _currentCamera.CurrentViewPort; foreach (BlockData bd in _blocks) { if (currentView.Intersects(bd.RectangleInWorld)) { // se comprueba si entra dentro del recuadro a pintar float newX = bd.Position.X - currentView.X; float newY = bd.Position.Y - currentView.Y; // Nullable<Rectangle> sourceRect = bd.FigureData.Rect; // se comprueba si se sale por la parte inferior para reducir el alto del rectangulo de origen // if ( bd.RectangleInWorld.Y + bd.RectangleInWorld.Height > currentView.Y + currentView.Height ) // sourceRect = new Rectangle ( bd.FigureData.Rect.X, bd.FigureData.Rect.Y, bd.FigureData.Rect.Width, // bd.FigureData.Rect.Height - ( bd.RectangleInWorld.Y + bd.RectangleInWorld.Height - currentView.Height ) ); sb.Draw( bd.FigureData.Container, new Vector2(newX, newY), // sourceRect, bd.FigureData.Rect, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, bd.FigureData.Depth); } } #if SHOW_WALLS int ini_i = currentView.Y / 20; if (ini_i > 0) { ini_i--; } int ini_j = currentView.X / 20; if (ini_j > 0) { ini_j--; } int fin_i = (currentView.Y + currentView.Height) / 20; int fin_j = (currentView.X + currentView.Width) / 20; FigureData marca = TextureManager.Figures [FigureEnum.MarcaBloquePared]; for (int i = ini_i; i <= fin_i; i++) { for (int j = ini_j; j <= fin_j; j++) { if (_wallMap [i, j]) { sb.Draw( marca.Container, new Vector2(j * 20 - currentView.X, i * 20 - currentView.Y), marca.Rect, Color.Yellow, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, marca.Depth); } } } #endif base.Draw(gameTime); }
public BlockData(float x, float y, FigureData figureData, bool bloquea) : this(new Vector2(x, y), figureData, bloquea) { }
public BlockData(float x, float y, FigureData figureData) : this(new Vector2(x, y), figureData, true) { }