public void LoseLife(int damage) { if (CurrentEntityStates.Contains(EntityStates.Hit)) { return; } CurrentEntityStates.Add(EntityStates.Hit); HitSound.Play(); Health -= damage; if (Health <= 0) { CurrentEntityStates.Add(EntityStates.Dead); CurrentEntityStates.Remove(EntityStates.Hit); Health = 0; } }
public void Update(GameTime gameTime) { if (CurrentEntityStates.Contains(EntityStates.Dead)) { bool dead = StatesTime[EntityStates.Dead].Update(gameTime); if (dead) { Active = false; } } if (CurrentEntityStates.Contains(EntityStates.Hit)) { bool hit = StatesTime[EntityStates.Hit].Update(gameTime); if (hit) { CurrentEntityStates.Remove(EntityStates.Hit); } } if (CurrentEntityStates.Contains(EntityStates.Recharge)) { bool recharge = StatesTime[EntityStates.Recharge].Update(gameTime); if (recharge) { CurrentEntityStates.Remove(EntityStates.Recharge); } } if (CurrentEntityStates.Contains(EntityStates.Boost)) { bool boost = StatesTime[EntityStates.Boost].Update(gameTime); if (boost) { CurrentEntityStates.Remove(EntityStates.Boost); CurrentEntityStates.Add(EntityStates.Recharge); } } }