protected virtual IEnumerator TakeTurn() { ActionManager actionManager = ActionManager.Get(); Vector2Int playerPos = LevelManager.Get().playerObject.GetGridCell(); Direction[] directions; int playerDist = LevelGrid.Get().FindShortestPathBetween(enemyObject.GetGridCell(), playerPos, out directions); yield return(null); if (playerDist <= sight && playerDist > 0) { int movesTaken = 0; while (movesTaken < movement && (playerDist - movesTaken) > 1) { ActionData actionData = new ActionData() { type = ActionType.Move, direction = directions[movesTaken] }; actionManager.AddActionToQueue(actionData); movesTaken++; } if ((playerDist - movesTaken) == 1) { ActionData actionData = new ActionData() { type = ActionType.Attack, direction = directions[movesTaken] }; actionManager.AddActionToQueue(actionData); } actionManager.StartProcessingQueue(enemyObject); } yield return(null); }