private static void InitialiserLabyrinthe(Carte carte) { //carte.Initialisation(new Vector2(Taille_Map.LARGEUR_MAP, Taille_Map.HAUTEUR_MAP)); for (int y = 0; y < hauteur; y++) for (int x = 0; x < largeur; x++) cellules[x, y] = new Cellule(); for (int y = 0; y < hauteur; y++) { for (int x = 0; x < largeur; x++) { if (x - 1 >= 0) cellules[x, y].addNeighbor(cellules[x - 1, y]); if (y - 1 >= 0) cellules[x, y].addNeighbor(cellules[x, y - 1]); if (x + 1 < largeur) cellules[x, y].addNeighbor(cellules[x + 1, y]); if (y + 1 < hauteur) cellules[x, y].addNeighbor(cellules[x, y + 1]); } } generate(); }
private static void generate(Cellule c, Random random) { c.IsVisited = true; List<Cellule> CList = new List<Cellule>(); c.randomizeNeighbors(random); foreach (Cellule cellule in c.getNeighbors()) if (!cellule.IsVisited) { c.addLink(cellule); cellule.addLink(c); generate(cellule, random); } }
public bool isNeighbor(Cellule c) { return neighbors.Contains(c); }
public bool isLinked(Cellule c) { return linked.Contains(c); }
public void addNeighbor(Cellule c) { neighbors.Add(c); }
public void addLink(Cellule c) { if (neighbors.Contains(c)) { linked.Add(c); } }