public override void Draw(SpriteBatch spriteBatch) { foreach (Block b in this.blocks) { DrawHelper.DrawRectangle(spriteBatch, b.position - camera, b.size, Color.LawnGreen); } base.Draw(spriteBatch); }
public virtual void Draw(SpriteBatch spriteBatch, Color color) { DrawHelper.DrawRectangle(spriteBatch, this.position, this.size, color * (color.A / 255f)); spriteBatch.DrawString(font, text, position + Vector2.One * 16, Color.Black, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); if (blink > 0) { Vector2 enterSize = font.MeasureString(closeKey.ToString()); DrawHelper.DrawRectangle(spriteBatch, position + size - enterSize * 2, enterSize, color * (color.A / 255f)); spriteBatch.DrawString(font, closeKey.ToString(), position + size - enterSize * 2, Color.Black, 0, Vector2.Zero, 2f, SpriteEffects.None, 0f); } }
public override void Draw(SpriteBatch spriteBatch) { if (!pauseGameplay) { zoom = 1f; } spriteBatch.End(); Engine.Instance.GraphicsDevice.SetRenderTarget(editorSurface); Engine.Instance.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise); // Draw world objects and decals. base.Draw(spriteBatch); // Draw collision markers. if (showCollision) { foreach (Floor f in floors) { f.Draw(spriteBatch, camera); } foreach (Block b in blocks) { if (!b.topSolidOnly) { b.Draw(spriteBatch, camera, Color.Yellow); } else { b.Draw(spriteBatch, camera, Color.Pink); } } foreach (Tuple <String, Vector2> n in nodes.GetAllNodes()) { spriteBatch.DrawString(TextureBin.mainFont, n.Item1, n.Item2 - camera, Color.OrangeRed); } } if (pauseGameplay) { // Show locators and aligning lines. if (helpInfo) { DrawHelper.DrawLine(spriteBatch, new Vector2(-camera.X, 0), new Vector2(-camera.X, Engine.WINDOW_HEIGHT * zoom), Color.Blue, 2); DrawHelper.DrawLine(spriteBatch, new Vector2(0, -camera.Y), new Vector2(Engine.WINDOW_WIDTH * zoom, -camera.Y), Color.Green, 2); DrawHelper.DrawRectangleOutline(spriteBatch, boundsTopLeft - camera, (boundsBottomRight - boundsTopLeft), Color.Purple); DrawHelper.DrawRectangleOutline(spriteBatch, boundsTopLeft - camera - Vector2.One, (boundsBottomRight - boundsTopLeft) + Vector2.One, Color.Purple); } if (mode == EditorMode.FloorMode || (mode == EditorMode.DecalMode && Input.IsKeyUp(Keys.LeftControl)) || mode == EditorMode.NodeMode || mode == EditorMode.CameraMode) { // Display X cursor. spriteBatch.DrawString(TextureBin.mainFont, "x", snapMouse - camera + new Vector2(3, -3), Color.Red, 0f, TextureBin.mainFont.MeasureString("X") / 2, 4f, SpriteEffects.None, 0f); if (point1 != null && mode == EditorMode.FloorMode) { DrawHelper.DrawLine(spriteBatch, (Vector2)point1 - camera, snapMouse - camera, Color.Red, 2); } } else if (mode == EditorMode.SquareMode || mode == EditorMode.GeneralMode) { // Display block cursor. DrawHelper.DrawRectangleOutline(spriteBatch, snapMouse.X - camera.X, snapMouse.Y - camera.Y, blockSize.X, blockSize.Y, Color.Red); } // Show decal preview. if (mode == EditorMode.DecalMode) { // Decal Delete Boxes. if (Input.IsKeyDown(Keys.LeftControl)) { List <Decal> all = new List <Decal>(); all.AddRange(decalsFront); all.AddRange(decalsBack); foreach (Decal d in all) { float alpha = 0.5f; Vector2 decalOnScreen = d.position - (d.origin + (camera - d.origin) * d.drift); if ((decalOnScreen - Input.MousePosition * zoom).Length() < 14) { spriteBatch.Draw(d.texture, decalOnScreen, null, Color.Red, d.angle, Vector2.Zero, d.scale, SpriteEffects.None, 0f); alpha = 1f; } DrawHelper.DrawRectangleOutline(spriteBatch, decalOnScreen - Vector2.One * 8, Vector2.One * 16, Color.Red * alpha); } } // Decal preview. else if (decal != null) { spriteBatch.Draw(decal, snapMouse - (decalOrigin + (camera - decalOrigin) * decalDrift), null, decalColor * 0.5f, decalAngle, Vector2.Zero, decalScale, SpriteEffects.None, 0f); } } } spriteBatch.End(); Engine.Instance.GraphicsDevice.SetRenderTarget(null); Engine.Instance.GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); spriteBatch.Draw(editorSurface, new Rectangle(0, 0, Engine.WINDOW_WIDTH, Engine.WINDOW_HEIGHT), new Rectangle(0, 0, (int)(Engine.WINDOW_WIDTH * zoom), (int)(Engine.WINDOW_HEIGHT * zoom)), Color.White); spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise); // Draw HUD. if (pauseGameplay) { if (helpInfo) { // Draw help text. spriteBatch.DrawString(TextureBin.mainFont, ((int)mode).ToString() + ". " + mode.ToString() + "\n\n" + modeText[(int)mode], Vector2.One * 16, Color.Red, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); // Draw info bar. DrawHelper.DrawRectangle(spriteBatch, new Vector2(0, Engine.WINDOW_HEIGHT - DEBUG_WINDOW_HEIGHT), new Vector2(Engine.WINDOW_WIDTH, DEBUG_WINDOW_HEIGHT), Color.Black * 0.5f); spriteBatch.DrawString(TextureBin.mainFont, "NAME: <" + this.name + "> - POS: " + snapMouse.ToString(), new Vector2(16, Engine.WINDOW_HEIGHT - DEBUG_WINDOW_HEIGHT), Color.Red, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); } // Draw specific details. if (mode == EditorMode.NodeMode) { spriteBatch.DrawString(TextureBin.mainFont, "Node Name: " + nodeString, new Vector2(Engine.WINDOW_WIDTH - 300, 16), Color.Red, 0f, Vector2.Zero, 2, SpriteEffects.None, 0f); } if (mode == EditorMode.DecalMode) { spriteBatch.DrawString(TextureBin.mainFont, "Decal Scale: " + decalScale.ToString() + "\nDecal Angle: " + decalAngle.ToString() + "\nDecal Drift: " + decalDrift.ToString() + "\nDecal Layer: " + decalLayer.ToString(), new Vector2(Engine.WINDOW_WIDTH - 300, 16), Color.Red, 0f, Vector2.Zero, 2, SpriteEffects.None, 0f); } // Show textbox. if (textBoxStack.Count > 0) { textBoxStack[textBoxStack.Count - 1].Draw(spriteBatch); } } }
public void Draw(SpriteBatch sb) { DrawHelper.DrawRectangle(sb, position, size, color); DrawHelper.DrawRectangle(sb, position + Vector2.UnitY * (this.size.Y * (1 - amount) - 2), new Vector2(size.X, 4), Color.Black); }