public override void Draw(SpriteBatch batch) { foreach (GuiWidget widget in widgets) { if (widget.id.Item1 == WidgetType.Button) { GuiWidgetButton button = (GuiWidgetButton)widget; if (widget.id.Item2 == 0) { if (player.health == player.maxHealth) { widget.draw = false; } else { widget.draw = true; } if (widget.GetState() == GuiWidget.State.Hot || widget.GetState() == GuiWidget.State.Active) { button.drawText = true; } else { button.drawText = false; } if (widget.draw) { PrimiviteDrawing.DrawRectangle(null, batch, button.bounds, Color.LightGray * 0.5f); } } } widget.Draw(batch); } }
public override void Draw(SpriteBatch batch) { if (currentState == State.None) { outlineWidth = 2; PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[1]); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(bounds.X + outlineWidth, bounds.Y + outlineWidth, bounds.Width - (int)(outlineWidth * 2), bounds.Height - (int)(outlineWidth * 2)), colors[0]); } if (currentState == State.Hot) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[0]); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(bounds.X + outlineWidth, bounds.Y + outlineWidth, bounds.Width - (int)(outlineWidth * 2), bounds.Height - (int)(outlineWidth * 2)), colors[1]); } if (currentState == State.Active || currentState == State.Active2) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[2]); } if (currentState == State.Done || currentState == State.Done2) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[2]); } if (item != null && item.item != null && item.item.texture != null) { batch.Draw(item.item.texture, bounds, Color.White); if (item.stackSize > 1) { batch.DrawString(Assets.GetFont(Assets.munro12), item.stackSize.ToString(), new Vector2(bounds.Right, bounds.Bottom), Color.White); } } }
public override void Draw(SpriteBatch batch) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[1]); PrimiviteDrawing.DrawRectangle(null, batch, interiorBounds, colors[0]); if (count <= wrappedChars.Length && !finished) { finalText.Clear(); for (int i = 0; i < wrappedChars.Length; i++) { if (i == 0 && Regex.IsMatch(wrappedChars[i].ToString(), @"^\d+$")) { //if the first char (and only first) is a number - sets the text speed to that. textSpeed = (int)char.GetNumericValue(wrappedChars[i]); continue; } if (i <= count) { finalText.Append(wrappedChars[i].ToString()); } } } else { finished = true; count = 0; } batch.DrawString(font, finalText.ToString(), new Vector2(interiorBounds.X, interiorBounds.Y), Color.Black); }
public override void Draw(SpriteBatch batch) { //batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.AnisotropicClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, camera.GetTransformation()); batch.Draw(texture, position, null, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f); PrimiviteDrawing.DrawRectangle(null, batch, hitbox, 1, Color.Red); //batch.End(); }
public void DrawDEBUG(SpriteBatch batch, Camera2D camera) { //batch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, camera.GetTransformation()); PrimiviteDrawing.DrawRectangle(null, batch, rect, 1, Color.Red); PrimiviteDrawing.DrawLineSegment(null, batch, new Vector2(rect.X, rect.Y), new Vector2(rect.X + rect.Width, rect.Y + rect.Height), Color.Blue, 1); batch.DrawString(Assets.GetFont(Assets.munro12), "layer:" + layer, new Vector2(position.X + 32, position.Y + 32), Color.Black); //batch.End(); }
public override void Draw(SpriteBatch batch) { if (draw) { //batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, camera.GetTransformation()); //batch.Draw(texture, new Vector2(rect.X, rect.Y), new Rectangle(0, 0, rect.Width, rect.Height), Color.White); PrimiviteDrawing.DrawRectangle(null, batch, rect, 1, Color.Red); //batch.End(); } }
public override void Draw(SpriteBatch batch) { if (active) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, Color.CadetBlue); foreach (GuiWidget widget in widgets) { widget.Draw(batch); } } }
public override void Draw(SpriteBatch batch) { if (active) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, Color.White); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(bounds.X + 4, bounds.Y + 4, bounds.Width - 4 * 2, bounds.Height - 4 * 2), Color.Black); foreach (GuiWidget widget in widgets) { PrimiviteDrawing.DrawRectangle(null, batch, widget.bounds, 1, Color.Red); widget.Draw(batch); } PrimiviteDrawing.DrawRectangle(null, batch, bounds, 1, Color.Red); } }
public override void Draw(SpriteBatch batch) { if (draw) { Vector2 size = font.MeasureString(text); Vector2 pos = bounds.Center.ToVector2(); Vector2 origin = size * 0.5f; if (currentState == State.None) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, outlineWidth, colors[1]); PrimiviteDrawing.DrawRectangle(null, batch, interiorBounds, colors[0]); } if (currentState == State.Hot) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, outlineWidth, colors[0]); PrimiviteDrawing.DrawRectangle(null, batch, interiorBounds, colors[1]); } if (currentState == State.Active || currentState == State.Active2) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[2]); } if (currentState == State.Done || currentState == State.Done2) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, colors[2]); } if (align == Alignment.Left) { origin.X += bounds.Width / 2 - size.X / 2; } if (align == Alignment.Right) { origin.X -= bounds.Width / 2 - size.X / 2; } if (align == Alignment.Top) { origin.Y += bounds.Height / 2 - size.Y / 2; } if (align == Alignment.Bottom) { origin.Y -= bounds.Height / 2 - size.Y / 2; } if (drawText) { batch.DrawString(font, text, pos, textColor, 0, origin, 1, SpriteEffects.None, 0); } } }
public override void Draw(SpriteBatch batch) { batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, camera.GetTransformation()); if (!timeFade) { PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle((int)position.X, (int)position.Y, 2, 2), color); } else { PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle((int)position.X, (int)position.Y, 2, 2), new Color(1, 0, 0, fadeAlpha)); } batch.End(); }
public override void Draw(SpriteBatch batch) { //batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, camera.GetTransformation()); batch.Draw(texture, position, null, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f); PrimiviteDrawing.DrawRectangle(null, batch, hitbox, 1, Color.Red); if (health < maxHealth) { PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle((int)position.X, (int)position.Y - 16, 32, 8), Color.Gray); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle((int)position.X, (int)position.Y - 16, healthBarWidth, 8), Color.Red); batch.DrawString(Assets.GetFont(Assets.munro12), health + "/" + maxHealth, new Vector2(position.X, position.Y - 16), Color.White); } //batch.End(); }
public override void Draw(SpriteBatch batch) { if (active) { PrimiviteDrawing.DrawRectangle(null, batch, bounds, Color.Black); foreach (GuiWidget widget in widgets) { widget.Draw(batch); // PrimiviteDrawing.DrawRectangle(null, batch, widget.bounds, 1, Color.Red); } if (reallyExit.active) { reallyExit.Draw(batch); } } }
public override void Draw(SpriteBatch batch) { //double angleDegrees = (angleRadians * 180)/Math.PI; foreach (HurtBox box in hurtboxes) { //batch.Draw(texture, new Vector2(box.rect.CollisionRectangle.X, box.rect.CollisionRectangle.Y), box.rect.CollisionRectangle, Color.White, box.rotation, Vector2.Zero, 1f, SpriteEffects.None, 0f); PrimiviteDrawing.DrawRectangle(null, batch, box.rect.CollisionRectangle, Color.Red, box.rect.Rotation, box.rect.center - Utilities.GetOriginRectangle(box.rect.CollisionRectangle).Item1); } batch.Draw(texture, position, null, Color.White, 0f, new Vector2(0, 0), 1f, SpriteEffects.None, 0f); //batch.Draw(texture, position, null, Color.White, 30f, center - position, 1f, SpriteEffects.None, 0f); //PrimiviteDrawing.DrawRectangle(null, batch, hitbox, Color.Red, -angleToMouse, center - position); batch.DrawString(Assets.GetFont(Assets.munro12), ("Layer:" + layer + "\nHealth: " + health), new Vector2(position.X, position.Y - 32), Color.Black); if (isHit) { PrimiviteDrawing.DrawRectangle(null, batch, hitbox, new Color(1, 0, 0, 0.5f)); } PrimiviteDrawing.DrawRectangle(null, batch, hitbox, 1, Color.Red); }
public void Draw(SpriteBatch batch) { if (drawMouse) { batch.Draw(texture, positionRelativeCamera, Color.White); } if (currentState.LeftButton == ButtonState.Pressed) { PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(positionRelativeCamera.ToPoint(), new Point(texture.Bounds.Width, texture.Bounds.Height)), Color.Red * 0.5f); } drawMouse = true; if (heldItem != null) { if (heldItem.item.texture != null) { batch.Draw(heldItem.item.texture, center, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0); drawMouse = false; } } if (hoveredItem != null) { batch.DrawString(Assets.GetFont(Assets.munro12), hoveredItem.name, Game1.mouse.positionRelativeCamera, Color.Black); for (int i = 0; i < hoveredItem.description.Length; i++) { if (hoveredItem.description[i] != null) { batch.DrawString(Assets.GetFont(Assets.munro12), hoveredItem.description[i], new Vector2(Game1.mouse.positionRelativeCamera.X, Game1.mouse.positionRelativeCamera.Y + 12 * (i + 1)), Color.Black); } } drawMouse = false; } hoveredItem = null; }
public override void Draw(SpriteBatch batch) { //Noop //TileTriggers do not draw anything, aside from debug outlines PrimiviteDrawing.DrawRectangle(null, batch, rect, 1, Color.Red); }
} //Static tiles never update public override void Draw(SpriteBatch batch) { if (draw) { //batch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null); batch.Draw(texture, new Vector2(rect.X, rect.Y), new Rectangle(0, 0, rect.Width, rect.Height), Color.White); float layerAlpha = 1f / 10f * (float)layer; PrimiviteDrawing.DrawRectangle(null, batch, rect, new Color(0, 0, 0, layerAlpha)); if (wall) { float percentLeft = 0.09f; if (facing == Directions.West) { int newWidth = (int)(rect.Width * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X + newWidth, rect.Y, rect.Width - newWidth, rect.Height), Color.Black); } if (facing == Directions.East) { int newWidth = (int)(rect.Width * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y, rect.Width - newWidth, rect.Height), Color.Black); } if (facing == Directions.North) { int newHeight = (int)(rect.Height * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y + newHeight, rect.Width, rect.Height - newHeight), Color.Black); } if (facing == Directions.South) { int newHeight = (int)(rect.Height * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height - newHeight), Color.Black); } if (facing == Directions.NorthWest) { int newWidth = (int)(rect.Width * percentLeft); int newHeight = (int)(rect.Height * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X + newWidth, rect.Y, rect.Width - newWidth, rect.Height), Color.Black); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y + newHeight, rect.Width, rect.Height - newHeight), Color.Black); } if (facing == Directions.NorthEast) { int newWidth = (int)(rect.Width * percentLeft); int newHeight = (int)(rect.Height * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y, rect.Width - newWidth, rect.Height), Color.Black); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y + newHeight, rect.Width, rect.Height - newHeight), Color.Black); } if (facing == Directions.SouthWest) { int newWidth = (int)(rect.Width * percentLeft); int newHeight = (int)(rect.Height * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X + newWidth, rect.Y, rect.Width - newWidth, rect.Height), Color.Black); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height - newHeight), Color.Black); } if (facing == Directions.SouthEast) { int newWidth = (int)(rect.Width * percentLeft); int newHeight = (int)(rect.Height * percentLeft); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y, rect.Width - newWidth, rect.Height), Color.Black); PrimiviteDrawing.DrawRectangle(null, batch, new Rectangle(rect.X, rect.Y, rect.Width, rect.Height - newHeight), Color.Black); } } //batch.End(); } }