Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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);
                }
        }
Esempio n. 3
0
 public bool isNeighbor(Cellule c)
 {
     return neighbors.Contains(c);
 }
Esempio n. 4
0
 public bool isLinked(Cellule c)
 {
     return linked.Contains(c);
 }
Esempio n. 5
0
 public void addNeighbor(Cellule c)
 {
     neighbors.Add(c);
 }
Esempio n. 6
0
 public void addLink(Cellule c)
 {
     if (neighbors.Contains(c)) { linked.Add(c); }
 }