/// <summary>
/// Handles the Hero talking with Characters. Will be expanded later to "interact" with
/// scenery as well.
/// </summary>
/// <param name="hero">The main character</param>
/// <param name="targets">List of interactables in the scene</param>
public static void handleInteractions(Hero hero, List<IInteractable> targets)
{
nullCheck();
if (!hero.isTalking())
{
if (KeyboardManager.isKeyPressed(keyTypes[(int)KeyInputType.Action]))
{
bool foundTarget = false;
for (int i = 0; i < targets.Count; i++)
{
if (hero.inRangeAction(targets[i]) && hero.facing(targets[i]))
{
targets[i].onInteract();
foundTarget = true;
break;
}
}
if (!foundTarget)
{
hero.talkToSelf();
}
}
}
else
{
if (KeyboardManager.isKeyPressed(keyTypes[(int)KeyInputType.MoveNorth]))
hero.dialogueChoiceMove(Direction.North);
else if (KeyboardManager.isKeyPressed(keyTypes[(int)KeyInputType.MoveSouth]))
hero.dialogueChoiceMove(Direction.South);
else if (KeyboardManager.isKeyPressed(keyTypes[(int)KeyInputType.Action]))
hero.dialogueConfirm();
else if (KeyboardManager.isKeyPressed(keyTypes[(int)KeyInputType.Cancel]))
hero.dialogueCancel();
}
}