public override void InitGrid()
        {
            if (((RectTileGridBuilder)GridBuilder).GridShape != RectTileGridBuilder.Shape.Rectangle)
            {
                Debug.LogError("Shape must be Rectangle");

                return;
            }

            if ((GridBuilder.Dimensions.X % 2 != 1) && (GridBuilder.Dimensions.Y % 2 != 1))
            {
                Debug.LogError("Both dimensions must be even!");

                return;
            }

            foreach (var point in Grid)
            {
                var color = point.GetColor3() == 0 ? floorColor : wallColor;
                Grid[point].Color = color;
            }

            foreach (var point in MazeAlgorithms.GenerateMazeWalls((RectGrid <TileCell>)Grid))
            {
                Grid[point].Color = floorColor;
            }
        }
        public override void InitGrid()
        {
            if (((PointyHexTileGridBuilder)GridBuilder).GridShape != PointyHexTileGridBuilder.Shape.Hexagon)
            {
                Debug.LogError("Shape must be Hexagon");

                return;
            }

            if (GridBuilder.Size % 2 != 0)
            {
                Debug.LogError("The size must be even!");

                return;
            }

            foreach (var point in Grid)
            {
                int color = point.GetColor2_4();
                ((SpriteCell)Grid[point]).FrameIndex = color;
            }

            foreach (var point in MazeAlgorithms.GenerateMazeWalls <TileCell>((PointyHexGrid <TileCell>)Grid))
            {
                ((SpriteCell)Grid[point]).FrameIndex = 0;
            }
        }
示例#3
0
        public override void InitGrid()
        {
            var grid = (FlatTriGrid <TileCell>)Grid;

            var edgeGrid = grid.MakeEdgeGrid <MazeCell>();

            var edgeMap = new PointyRhombMap(cellDimensions)
                          .WithWindow(ExampleUtils.ScreenRect)
                          .AlignMiddleCenter(edgeGrid)
                          .To3DXY();

            foreach (var point in edgeGrid)
            {
                MazeCell cell = GridBuilderUtils.Instantiate(edgePrefab);
                cell.transform.parent        = transform;
                cell.transform.localScale    = Vector3.one;
                cell.transform.localPosition = edgeMap[point];
                cell.SetOrientation(point.I, false);
                cell.name       = "M";
                edgeGrid[point] = cell;
            }

            foreach (var point in MazeAlgorithms.GenerateMazeWalls(grid))
            {
                if (edgeGrid[point] != null)
                {
                    edgeGrid[point].SetOrientation(point.I, true);
                }
            }
        }