public override void Process() { _SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); base.Process(); //_SpriteBatch.Draw(_Hud, radarLocation, radarSource, Color.White); SpaceWorld w = world as SpaceWorld; for (int i = 0; i < w.enemySpawnSystem.RespawnTime.Length; ++i) { int time = w.enemySpawnSystem.RespawnTime[i]; if (time > 0) { int amount = (int)(time / 1000) + 1; amount = (int)MathHelper.Clamp(amount, 1, 3); Rectangle loc = hudLocations[i]; RectangleF locF = new RectangleF(loc.X, loc.Y, loc.Width, loc.Height); _Font.DrawString(_SpriteBatch, locF, amount.ToString()); } } if (!string.IsNullOrEmpty(SurgeWarning)) { if (SurgeWarning.Equals("Surge")) _SpriteBatch.Draw(_Hud, warningLocation, warningSource, Color.White); else { Vector2 warnDim = _Font.MeasureString(SurgeWarning); RectangleF loc = new RectangleF(ScreenHelper.Center.X - warnDim.X / 2, ScreenHelper.Center.Y - warnDim.Y * 6, warnDim.X, warnDim.Y); _Font.DrawString(_SpriteBatch, loc, SurgeWarning); } } _SpriteBatch.End(); }
public bool DrawString(SpriteBatch spriteBatch, RectangleF bounds, string s) { float scale = 1f; Vector2 size; while (scale > 0) { size = MeasureString(s, scale); if (size.X <= bounds.Width && size.Y <= bounds.Height) { Vector2 drawTo = new Vector2(bounds.X, bounds.Y); drawTo.X += bounds.Width / 2 - size.X / 2; drawTo.Y += bounds.Height / 2 - size.Y / 2; DrawString(spriteBatch, drawTo, s, scale); return true; } scale -= 0.1f; } return false; }