This may be something fairly trivial, but I've decided to jump feet first into this and don't quite understand how to handle this.
private void OnBattleUpdate(object sender, ElapsedEventArgs e)
{
if (monster.IsAlive)
{
ActionResult result = monster.GetAttackResult();
messages.Add(result.LookMessage);
state.Character.CauseDamage(result.HealthChange);
if (state.Character.Health <= 0)
{
messages.Add("You are dead.");
}
int playerDamage = state.Character.GetDamage().HealthChange;
messages.Add(String.Format("You swing your sword at {0} and cause {1} damage", monster.Name, playerDamage));
monster.CauseDamage(playerDamage);
messages.Add(String.Format("Health : {0}/{1}", state.Character.Health, state.Character.MaxHealth));
}
else
{
messages.Add(String.Format("{0} is dead.", monster.Name));
state.Character.Gold += monster.Gold;
mapManager.RemoveMonster(monster, mapManager.MapName);
battleTimer.Stop();
}
}
The code to handle "IsAlive"
private bool _isAlive;
public bool IsAlive
{
get { return _isAlive; }
set
{
if (Health > 0)
{
_isAlive = true;
}
else
{
_isAlive = false;
}
}
}
Am I just approaching this the wrong way? Any tips that you all can provide would be extremely helpful :)