private GameEntity GetTarget(GameEntity entity) { GameEntity result; switch (entity.character.type) { case CharacterType.GoodGuy: var badGuys = CharacterUtils.FindBadGuys(_allCharacters.AsEnumerable()); result = badGuys.FirstOrDefault(e => e.isCurrentTarget); break; case CharacterType.BadGuy: var goodGuys = CharacterUtils.FindGoodGuys(_allCharacters.AsEnumerable()); result = CharacterUtils.FirstAliveCharacter(goodGuys); break; default: throw new ArgumentOutOfRangeException(); } return(result); }