Exemplo n.º 1
0
        private void Start()
        {
            LabyrinthGenerator labyrinth = new LabyrinthGenerator(
                transform,
                _labyrinthSizeX,
                _labyrinthSizeZ,
                _cellPrefub,
                _wallPrefub
                );

            labyrinth.GenerateLabyrinth();
        }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        LabyrinthGenerator.LabyrinthGenerator generator = new LabyrinthGenerator.LabyrinthGenerator();
        _maze = generator.Generate(5, 5, 20);


        for (int y = 0; y < _maze.GetLength(1); y++)
        {
            for (int x = 0; x < _maze.GetLength(0); x++)
            {
                if (_maze[x, y].IsVisited)
                {
                    GameObject go      = Instantiate(cell, new Vector3(x * 3 * 5, 0, y * 3 * 3), Quaternion.identity);
                    Cell       newCell = go.GetComponent <Cell>();
                    newCell.x = x;
                    newCell.y = y;
                    go.name   = $"Cell {newCell.x},{newCell.y}";

                    if (_maze[x, y].IsFirst)
                    {
                        go.ChangeColor(Color.green);
                    }
                    else
                    {
                        go.GetComponentInChildren <Camera>().gameObject.SetActive(false);
                    }

                    if (_maze[x, y].IsLast)
                    {
                        go.ChangeColor(Color.red);
                    }



                    foreach (Direction dir in Enum.GetValues(typeof(Direction)))
                    {
                        if (dir == Direction.None)
                        {
                            continue;
                        }
                        //Si la direction dans laquelle je suis doit être ouverte
                        if ((_maze[x, y].Doors & dir) != 0)
                        {
                            Destroy(newCell.walls.First(wall => wall.direction == dir).door);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
        private void Generate()
        {
            if (_parent == null)
            {
                _parent = new GameObject {
                    name = PARENT
                }
            }
            ;

            LabyrinthGenerator labyrinth = new LabyrinthGenerator(
                _parent.transform,
                _labyrinthSizeX,
                _labyrinthSizeZ,
                _cellPrefub,
                _wallPrefub
                );

            labyrinth.GenerateLabyrinth();
        }