Example #1
0
        /// <summary>
        /// Subtract the damage from the current life and switch into the
        /// ChaseState if necessary.</summary>
        public void OnAttacked(IFighter attacker, float damage)
        {
            if (!(CurrentState is AttackState))
            {
                TargetedEnemy = attacker;
                ChangeState(ChaseState);
            }
            AddEnemy(attacker);
            Stats.Life.Value -= damage;

            if (Stats.Life.Value <= 0)
            {
                attacker.HasDefeated(this);
            }
            else
            {
                EmitOnBeingAttacked(attacker);
            }
        }