示例#1
0
    private void CheckWallside(MazeCell cell, MazeDirection dir, int delta)
    {
        if (cell.GetEdge(dir + delta) is MazeWall)
        {
            if (closedTurnWallDecorPrefab != null && !cell.IsCornerInitialized(dir, delta))
            {
                cell.InitializeCorner(closedTurnWallDecorPrefab, dir, delta);
            }
            return;
        }

        if (ContainsCoordinates(cell.coordinates + (dir + delta).ToVector2i() + dir.ToVector2i()))
        {
            MazeCell otherCell = GetCell(cell.coordinates + (dir + delta).ToVector2i() + dir.ToVector2i());
            if (otherCell.GetEdge(dir - delta) is MazeWall)
            {
                if (openTurnWallDecorPrefab != null)
                {
                    if (!cell.IsCornerInitialized(dir, delta))
                    {
                        cell.InitializeCorner(openTurnWallDecorPrefab, dir, delta);
                    }

                    if (ContainsCoordinates(cell.coordinates + (dir + delta).ToVector2i()))
                    {
                        MazeCell sideCell = GetCell(cell.coordinates + (dir + delta).ToVector2i());
                        if (!sideCell.IsCornerInitialized(dir, -delta))
                        {
                            sideCell.InitializeCorner(openTurnWallDecorPrefab, dir, -delta);
                        }
                    }
                }
                return;
            }
        }

        if (ContainsCoordinates(cell.coordinates + (dir + delta).ToVector2i()))
        {
            MazeCell otherCell = GetCell(cell.coordinates + (dir + delta).ToVector2i());
            if (otherCell.GetEdge(dir) is MazeWall)
            {
                if (straightWallDecorPrefab != null && !cell.IsCornerInitialized(dir, delta))
                {
                    cell.InitializeCorner(straightWallDecorPrefab, dir, delta);
                }
                return;
            }
        }
    }