private static void _GetConnectedSeas(MapCM map, int playerID, Hex h, int moveLimit, List<Hex> res, bool is_possible_to_attack_enemy) { if (moveLimit < 1) return; List<Hex> neighbours = map.GetPointNeighbors(h); for(int i = 0; i < neighbours.Count; ++i) { Hex n = neighbours[i]; if (!res.Contains(n)) { if (map.IsPointAccessibleForShip(n, playerID, false)) { res.Add(n); _GetConnectedSeas(map, playerID, n, moveLimit - 1, res, is_possible_to_attack_enemy); } else if (is_possible_to_attack_enemy && map.IsPointAccessibleForShip(n, playerID, true)) { res.Add(n); continue; } } } }
protected static void _GetSeaPathMoveCosts(Dictionary<Hex, int> moveCosts, MapCM map, Hex from, int playerID, int moveLimit, int curCost, bool is_possible_to_attack_enemy) { if (moveLimit == 0) return; List<Hex> neibors = map.GetNeiborSeasByMapPos(from); for (int i = 0; i < neibors.Count; ++i) { Hex h = neibors[i]; if (map.IsPointAccessibleForShip(h, playerID, is_possible_to_attack_enemy)) { if (!moveCosts.ContainsKey(h) || moveCosts[h] > curCost) { moveCosts[h] = curCost; int enemyID = map.GetSeaPointOwnerID(h); if (enemyID == playerID || enemyID == PlayerInfoCM.NoID) _GetSeaPathMoveCosts(moveCosts, map, h, playerID, moveLimit - 1, curCost + 1, is_possible_to_attack_enemy); } } } }