Пример #1
0
    public BaseCell(BaseCell previousCell, Direction direction, MazeGenerator mazeGenerator)
    {
        m_center = previousCell.Center + MazeUtils.DirectionToVector2(direction);

        m_root      = GameObject.Instantiate(Resources.Load(PREFAB_NAME) as GameObject);
        m_root.name = string.Format("Cell {0},{1}", m_center.x, m_center.y);
        m_root.transform.position = new Vector3(m_center.x, m_center.y, -0.1f);

        m_maze = mazeGenerator.maze;
        m_maze.SetCell((int)m_center.x, (int)m_center.y, this);

        SetupWalls(direction);
        SetupNeighbours();
    }
Пример #2
0
    public BaseCell(int w, int h, MazeGenerator mazeGenerator)
    {
        m_center = new Vector2(w, h);

        m_root      = GameObject.Instantiate(Resources.Load(PREFAB_NAME) as GameObject);
        m_root.name = string.Format("Cell {0},{1}", m_center.x, m_center.y);
        m_root.transform.position = new Vector3(m_center.x, m_center.y, -0.1f);

        m_maze = mazeGenerator.maze;
        m_maze.SetCell(w, h, this);

        SetupWalls(Direction.None);
        SetupNeighbours();
    }
Пример #3
0
    //初始 BaseCell 只會執行一次
    public BaseCell(int w, int h, MazeGenerator mazeGenerator)
    {
        //設定 BaseCell 位置 初始預設為 [0, 0]
        m_x = w;
        m_y = h;

        //將 m_maze 的資料指向 MazeGenerator 的 BaseMaze
        m_maze = mazeGenerator.maze;

        //向 m_maze 傳當前 BaseCell 的資料
        m_maze.SetCell(w, h, this);

        //設定牆壁 初始預設為空
        SetupWalls(0);

        //設定牆壁狀態
        SetupNeighbours();
    }
Пример #4
0
    //新增 BaseCell
    public BaseCell(BaseCell previousCell, int direction, MazeGenerator mazeGenerator)
    {
        //取得前一個 BaseCell 的位置
        m_x = previousCell.m_x;
        m_y = previousCell.m_y;

        //判斷方向並更改當前 BaseCell 的位置
        switch (direction)
        {
        case 1:
            m_y++;
            break;

        case 2:
            m_y--;
            break;

        case 3:
            m_x--;
            break;

        case 4:
            m_x++;
            break;
        }

        //將 m_maze 的資料指向 MazeGenerator 的 BaseMaze
        m_maze = mazeGenerator.maze;

        //向 m_maze 傳當前 BaseCell 的資料
        m_maze.SetCell(m_x, m_y, this);

        //設定牆壁給予參數 方向
        SetupWalls(direction);

        //設定牆壁狀態
        SetupNeighbours();
    }