internal void DrawReloadTime(IDrawContext context, Vector2 offset, float angle) { const float width = 40; const float height = 10; var rotationMatrix = Matrix.CreateRotationZ(angle); Vector2 Rotate(float w) => Center + Vector2.Transform(new Vector2(Size.X - (width - w) - offset.X, Size.Y - height - offset.Y), rotationMatrix); switch (FiringState) { case FiringState.Idle: context.FillRectangle(Rotate(0), new Vector2(width, height), Color.Green, angle); break; case FiringState.Firing: context.FillRectangle(Rotate(0), new Vector2(width, height), Color.Black, angle); break; case FiringState.Reloading: float loadedPercent = 1 - (float)TimeToNextFiringState.TotalMilliseconds / Settings.ReloadTime; float loadedWidth = width * loadedPercent; context.FillRectangle(Rotate(0), new Vector2(loadedWidth, height), Color.Green, angle); context.FillRectangle(Rotate(loadedWidth), new Vector2(width - loadedWidth, height), Color.Green, angle); break; } }
public override void Draw(IDrawContext context) { if (IsEnabled) { switch (ClickState) { case ClickState.Pressed: context.FillRectangle(Bounds, new Color(Color.Orange, 0.3f)); break; case ClickState.None: context.FillRectangle(Bounds, new Color(Color.Orange, 0.05f)); break; } } else { context.FillRectangle(Bounds, new Color(Color.Gray, 0.3f)); } DrawContent(context); if (Globals.ShowButtonsInfo) { DrawInfo(context); } base.Draw(context); }
void DrawHealth(IDrawContext context) { const float width = 40; const float height = 10; const float verticalOffset = 5; var topLeft = Center - OffsetToCenter + new Vector2(0, -height - verticalOffset); if (Health == settings.Health) { context.FillRectangle(topLeft, new Vector2(width, height), Color.Red); } else { float percent = (float)Health / settings.Health; float healthWidth = width * percent; context.FillRectangle(topLeft, new Vector2(healthWidth, height), Color.Red); var blackTopLeft = topLeft + new Vector2(healthWidth, 0); context.FillRectangle(blackTopLeft, new Vector2(width - healthWidth, height), Color.Black); } }
void DrawHeader(IDrawContext context) { const int HeaderHeight = 60; const float BetweenColumns = 80; const float BetweenRows = 20; const float Top = 10; const float Left = 10; var view = View; var topLeftView = new Vector2(view.Left, view.Top); context.FillRectangle(new Rectangle(view.Left, view.Top, view.Width, HeaderHeight), new Color(Color.Black, 0.2f)); context.DrawString(GlobalContent.Default.HudFont, "Health", topLeftView + new Vector2(Left, Top), Color.Yellow); context.DrawString(GlobalContent.Default.HudFont, Health.ToString("#,##0"), topLeftView + new Vector2(Left, Top + BetweenRows), Color.Yellow); context.DrawString(GlobalContent.Default.HudFont, "Amount", topLeftView + new Vector2(Left + BetweenColumns, Top), Color.Yellow); context.DrawString(GlobalContent.Default.HudFont, Amount.ToString("#,##0"), topLeftView + new Vector2(Left + BetweenColumns, Top + BetweenRows), Color.Yellow); }
public override void Draw(IDrawContext context) { context.FillRectangle(ContentBounds, new Color(Color.Green, 0.8f)); DrawContent(context); base.Draw(context); }