private void UpdatePaths(PathMap distanceMap, bool infected = false) { distanceMap.Init(); for (int y = 0; y < tiles.GetLength(1); ++y) for (int x = 0; x < tiles.GetLength(0); ++x) { Vector2 pos = new Vector2(x, y); switch (tiles[x, y]) { case Tile.Street: distanceMap[pos, new Vector2(pos.x + 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y - 1)] = 1.0f; distanceMap[pos, new Vector2(pos.x - 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y + 1)] = 1.0f; break; case Tile.Checkpoint: if (!infected) { distanceMap[pos, new Vector2(pos.x + 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y - 1)] = 1.0f; distanceMap[pos, new Vector2(pos.x - 1, pos.y)] = 1.0f; distanceMap[pos, new Vector2(pos.x, pos.y + 1)] = 1.0f; } break; case Tile.Hospital: case Tile.Home: case Tile.Office: case Tile.Bar: case Tile.Mall: distanceMap[pos, new Vector2(pos.x, pos.y + 1)] = 1.0f; break; } } // Floyd for (int k = 0; k < distanceMap.DimX * distanceMap.DimY; ++k) for (int i = 0; i < distanceMap.DimX * distanceMap.DimY; ++ i) for (int j = 0; j < distanceMap.DimX * distanceMap.DimY; ++j) { if (distanceMap.Distance[i, k] + distanceMap.Distance[k, j] < distanceMap.Distance[i, j]) { distanceMap.Distance[i, j] = distanceMap.Distance[i, k] + distanceMap.Distance[k, j]; distanceMap.ShortestPath[i, j] = distanceMap.ShortestPath[i, k]; } } }