protected void ProcessTargetSearch(Character currentCharacter) { var availableTargets = this.characterList .Where(t => this.IsWithinRange(currentCharacter.X, currentCharacter.Y, t.X, t.Y, currentCharacter.Range)) .ToList(); if (availableTargets.Count == 0) { return; } var target = currentCharacter.GetTarget(availableTargets); if (target == null) { return; } this.ProcessInteraction(currentCharacter, target); }
protected void ProcessInteraction(Character currentCharacter, Character target) { if (currentCharacter is IHeal) { target.Health += (currentCharacter as IHeal).Healing; } else if (currentCharacter is IAttack) { target.Health -= (currentCharacter as IAttack).Attack - target.Defence; if (target.Health <= 0) { target.IsAlive = false; } } }