protected int RunnawayDir() { List <GameCharacter> detectedEnemies = PredatorsInSightSensor(); // // Choose most inminent predator: proximity criteria if (detectedEnemies.Count <= 0) { return(-1); } Vector2Int predPosition = ClosestObjective(detectedEnemies); HexTile currentTile = BattleMap_.mapTiles[InGamePosition]; HexTile neighbor; List <int> oppositedir = HexCalculator.OppositeDir(HexCalculator.GeneralDirectionTowards(this.InGamePosition, predPosition)); // // Check directions available for (int i = 0; i < oppositedir.Count; i++) { if (currentTile.Neighbors.TryGetValue(oppositedir[i], out neighbor)) { if (!neighbor.Occupied) { return(oppositedir[i]); // return most optimal escape route (if possible) } } } // If all are occupied, "failed escape" return(-1); }