Example #1
0
File: MapCM.cs Project: AciesNN/cyc
		protected static void _GetSeaPathFromMoveCosts(MapCM map, Hex from, Hex to, Dictionary<Hex, int> moveCosts, List<Hex> path, int curCost)
		{
			List<Hex> neibors = map.GetNeiborSeasByMapPos(from);
			for (int i = 0; i < neibors.Count; ++i)
			{
				Hex h = neibors[i];
				if (moveCosts.ContainsKey(h) && moveCosts[h] == curCost - 1)
				{
					path.Add(h);
					if (h == to)
						return;
					else
						_GetSeaPathFromMoveCosts(map, from, to, moveCosts, path, moveCosts[h]-1);
					break;
				}
			}
		}
Example #2
0
File: MapCM.cs Project: AciesNN/cyc
		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);
					}
				}
			}
		}