public override void Draw(GameTime gameTime) { if (SpriteBatch == null) { SpriteBatch = new SpriteBatch(GraphicsDevice); } if (Template != null && Template.Texture != null) { Rectangle dest = Template.Texture.GetSource(0); SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise); if (Mode == 0) /*Viewer*/ { SpriteBatch.Draw(Template.Texture.Texture, dest, Template.Texture.GetSource(0), Color.White); } else if (Mode == 1) /*Collisions*/ { SpriteBatch.Draw(Template.Texture.Texture, dest, Color.White); Color col = new Color(255, 75, 0, 255); Color col2 = new Color(250, 35, 0, 255); foreach (Rectangle rect in Template.CollisionMap) { Rectangle w1 = new Rectangle(rect.X * 16, rect.Y * 16, rect.Width * 16, rect.Height * 16); Rectangle w2 = new Rectangle(rect.X * 16 + 1, rect.Y * 16 + 1, rect.Width * 16 - 1, rect.Height * 16 - 1); SelectionUtil.DrawRectangle(SpriteBatch, col * .7f, w1); SelectionUtil.FillRectangle(SpriteBatch, col2 * .3f, w2); } Rectangle ww = new Rectangle(selection.Region.X * 16, selection.Region.Y * 16, selection.Region.Width * 16, selection.Region.Height * 16); SelectionUtil.DrawRectangle(SpriteBatch, Color.White, ww); } else if (Mode == 2) { Vector2 pos = new Vector2(0, Template.ShadowOffset); Rectangle src = Template.Texture.GetSource(0); Rectangle target = new Rectangle((int)pos.X, (int)pos.Y, Template.Texture.FrameWidth, (int)(Template.Texture.FrameHeight * 0.6f)); if (Template.ShadowType == ShadowType.Perspective) { SpriteBatch.Draw(Template.Texture.Texture, target, src, new Color(0f, 0f, 0f, 0.3f), 0.0f, Vector2.Zero, SpriteEffects.FlipVertically, 0f); } SpriteBatch.Draw(Template.Texture.Texture, dest, Color.White); SelectionUtil.DrawStraightLine(SpriteBatch, Color.White, 0, Template.ShadowOffset, 1, Width); } SpriteBatch.End(); } }
public void Draw(GameTime gameTime) { int w = EditorEngine.Instance.CurrentMap.Width; int h = EditorEngine.Instance.CurrentMap.Height; int xs = EditorEngine.Instance.xCam; int ys = EditorEngine.Instance.yCam; //Columns for (int x = 0; x < w; x++) { SelectionUtil.DrawStraightLine(EditorEngine.Instance.World.ViewData.SpriteBatch, Color.Black, 0.6f, (x << 4) + xs, ys, 2, h << 4); } //Rows for (int y = 0; y < h; y++) { SelectionUtil.DrawStraightLine(EditorEngine.Instance.World.ViewData.SpriteBatch, Color.Black, 0.6f, xs, (y << 4) + ys, 1, w << 4); } this.ToolMachine.Draw(gameTime); }
public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) { int ypos = vscrollbar.Value; int xpos = hscrollbar.Value; if (Tileset != null) { if (Tileset.Texture != null && Tileset.Texture.Texture != null) { batch.Begin(); batch.Draw(Tileset.Texture.Texture, -new Vector2(xpos, ypos), Color.White); int x = Tileset.Texture.Texture.Width - xpos; int y = Tileset.Texture.Texture.Height - ypos; SelectionUtil.DrawStraightLine(batch, new Color(.9f, .4f, .4f, 1f), 1f, x, -ypos, 2, Tileset.Texture.Texture.Height); //vertical SelectionUtil.DrawStraightLine(batch, new Color(.9f, .4f, .4f, 1f), 1f, -xpos, y, 1, Tileset.Texture.Texture.Width); //horizontal SelectionUtil.DrawRectangle(batch, new Color(.7f, .1f, 0f, .6f), new Rectangle((xt << 4) - xpos, (yt << 4) - ypos, 16, 16)); SelectionUtil.FillRectangle(batch, new Color(.4f, .1f, 0f, .6f), new Rectangle((xt << 4) + 1 - xpos, (yt << 4) + 1 - ypos, 16, 16)); int ry = 0; int rx = 0; foreach (Tile t in Tileset.Tiles) { if (rx + 1 > Tileset.Texture.Texture.Width / 16) { rx = 0; ry++; } batch.Draw(ox.Texture, new Rectangle((rx << 4) - xpos, (ry << 4) - ypos, 16, 16), ox.GetSource(t.DefaultBehavior.BehaviorId == this.Behavior ? 0 : 1), Color.White * 0.8f); rx++; } batch.End(); } } base.Draw(gameTime); }
public void Draw(Microsoft.Xna.Framework.GameTime time) { if (!Initialized || World == null) { return; } if (CurrentMap == null) { return; } int w = CurrentMap.Width << 4; int h = CurrentMap.Height << 4; GraphicsDevice.Clear(new Color(0x2f, 0x2f, 0x2f)); SpriteBatch batch = World.ViewData.SpriteBatch; batch.Begin(Matrix.CreateScale(1)); SelectionUtil.FillRectangle(World.ViewData.SpriteBatch, Color.White * 0.5f, new Rectangle((int)World.Camera.Location.X, (int)World.Camera.Location.Y, (int)(w * World.Camera.Scale), (int)(h * World.Camera.Scale))); CurrentMap.Draw(time); if (this.World.Camera.Scale <= 0) { this.World.Camera.Scale = 1f; } StateMachine.Draw(time); if (Options.Instance.Grid) { if (CurrentMap != null) { //We could draw a rectangle for every Tiles... //Or we could be smart and draw lines for columns and rows! Color c1 = Color.DeepSkyBlue; Color c2 = Color.Black; float trans_white = Options.Instance.GridOpacity; float trans_black = Options.Instance.GridOpacity; //rows for (int y = 0; y < CurrentMap.Height; y++) { SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c1, trans_white, 0, (y << 4), CurrentMap.Width * 16, 1); SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c2, trans_black, 0, (y << 4) + 1, CurrentMap.Width * 16, 1); } //columns for (int x = 0; x < CurrentMap.Width; x++) { SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c1, trans_white, x << 4, 0, 1, CurrentMap.Height << 4); SelectionUtil.DrawStraightLine(World.ViewData.SpriteBatch, c2, trans_black, (x << 4) + 1, 0, 1, CurrentMap.Height << 4); } } } ScreenInterface.Draw(time); //batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise); //batch.Draw(renderTarget, new Rectangle(xCam, yCam, (int) (renderTarget.Width * Zoom), (int) (renderTarget.Height * Zoom)), Color.White); batch.End(); }
public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) { int xpos = hscrollbar.Value; int ypos = vscrollbar.Value; if (spriteBatch == null) { spriteBatch = new SpriteBatch(GraphicsDevice); } if (Tileset != null) { if (checkerboard) { int i = 0; for (int cy = 0; cy < Tileset.Texture.Rows; cy++) { for (int cx = 0; cx < Tileset.Texture.Columns; cx++) { bool odd = i % 2 != 0; //0xD8DEFF //0xBFC8FF Color col_dark = new Color(0xd8, 0xde, 0xff); Color col_light = new Color(0xbf, 0xc8, 0xff); SelectionUtil.FillRectangle(spriteBatch, odd ? col_light : col_dark, new Rectangle(cx * 16 - xpos, cy * 16 - ypos, 16, 16)); i++; } i++; } } spriteBatch.Begin(); spriteBatch.Draw(Tileset.Texture.Texture, -new Vector2(xpos, ypos), Color.White); spriteBatch.End(); int x = Tileset.Texture.Texture.Width - xpos; int y = Tileset.Texture.Texture.Height - ypos; SelectionUtil.DrawStraightLine(spriteBatch, new Color(.9f, .4f, .4f, 1f), 1f, x, -ypos, 2, Tileset.Texture.Texture.Height); //vertical SelectionUtil.DrawStraightLine(spriteBatch, new Color(.9f, .4f, .4f, 1f), 1f, -xpos, y, 1, Tileset.Texture.Texture.Width); //horizontal List <Vector2> _points = points[currentEntity]; foreach (Vector2 vec2 in _points) { Tuple <int, int, int> bcol = colors[currentEntity]; Color col = new Color(bcol.Item1, bcol.Item2, bcol.Item3); SelectionUtil.FillRectangle(spriteBatch, colorbuffer ? (col * 0.6f) : (Color.Red * 0.6f), new Rectangle((int)vec2.X * 16 - xpos, (int)vec2.Y * 16 - ypos, 16, 16)); } for (int i = 0; i < points.Length; i++) { if (i != currentEntity) { foreach (Vector2 vec2 in points[i]) { SelectionUtil.FillRectangle(spriteBatch, Color.Black * 0.4f, new Rectangle((int)vec2.X * 16 - xpos, (int)vec2.Y * 16 - ypos, 16, 16)); } } } } base.Draw(gameTime); }