internal void AddBossHealthBar(Boss b) { ProgressBar lastPlayerHealth = playerHUDS.Last().healthBar; Vector2 size = new Vector2(This.Game.GraphicsDevice.Viewport.Width * 0.8f, barSize.Y * 1.5f); ProgressBar healthBar = new ProgressBar(b.Name + "_health", b.MaxHealth, Color.DarkRed, Color.Firebrick, Color.Black, size); healthBar.Pos = new Vector2( (This.Game.GraphicsDevice.Viewport.Width - size.X) / 2, This.Game.GraphicsDevice.Viewport.Height - size.Y * 2); healthBar.Static = true; healthBar.Value = b.MaxHealth; b.HealthChanged += delegate(object obj, int value) { healthBar.Value = value; }; bossHealthBars.Add(healthBar); }
internal PlayerHUD(IHUDTheme theme, Player p, int xOffset, int yOffset) { #region Name Text name = new Text("player_name_" + p.Name, "Text", p.Name); name.DisplayColor = theme.TextColor; name.Pos = new Vector2(xOffset, yOffset); name.Static = true; #endregion #region HealthBar healthBar = new ProgressBar("Health_" + p.Name, p.MaxHealth, Color.DarkRed, Color.Firebrick, Color.Black, barSize); healthBar.Pos = new Vector2(xOffset, name.Pos.Y + name.GetAnimation().Height); healthBar.Static = true; healthBar.Value = p.MaxHealth; p.HealthChanged += delegate(object obj, int value) { healthBar.Value = value; if (value == 0) { name.DisplayColor = Color.Tomato; } else { name.DisplayColor = theme.TextColor; } }; #endregion #region ManaBar manaBar = new ProgressBar("Mana_" + p.Name, p.MaxMana, Color.MidnightBlue, Color.Blue, Color.Black, barSize); manaBar.Pos = new Vector2(xOffset, healthBar.Pos.Y + barSize.Y + barSpacing.Y); manaBar.Static = true; manaBar.Value = p.MaxMana; p.ManaChanged += delegate(object obj, int value) { manaBar.Value = value; }; #endregion #region Spell Queue spellQueue = new SpellQueue("Queue", theme, p); spellQueue.Pos = new Vector2(xOffset, healthBar.Pos.Y + barSize.Y + 2 * barSpacing.Y + barSize.Y); spellQueue.Static = true; #endregion }
public Enemy(string name, Actor actor, float speed, int _health) : base(name, actor) { FrostbyteLevel l = This.Game.LoadingLevel as FrostbyteLevel; Personality = new WanderingMinstrelPersonality(this); UpdateBehavior = update; l.enemies.Add(this); EndBehavior = Die; Speed = speed; Health = _health; CollidesWithBackground = true; #region HealthBar float alpha = 0.15f; healthBar = new ProgressBar("Health_" + Name, MaxHealth, Color.Black * 0, Color.Red * 0.5f, Color.Black * alpha, barSize); healthBar.Pos = Pos - l.Camera.Pos + new Vector2(0, -20); healthBar.Static = true; healthBar.Value = MaxHealth; HealthChanged += delegate(object obj, int value) { if (healthBar != null) { healthBar.Value = value; if (value == 0) { This.Game.CurrentLevel.RemoveSprite(healthBar); } } }; #endregion }