private static void CleanUpRoomPlacement(ref Cell[,] map, ref int width, ref int height, CellType floorCell = CellType.Floor)
    {
        CleanUpCells cleaner      = CleanUpCells.None;
        int          byteCounter  = 1;
        int          debugCounter = 0;

        for (int mapX = 1; mapX < width - 3; mapX++)
        {
            for (int mapY = 1; mapY < height - 3; mapY++)
            {
                byteCounter = 1;
                cleaner     = CleanUpCells.None;
                debugCounter++;
                for (int x = mapX; x < mapX + 3; x++)
                {
                    for (int y = mapY; y < mapY + 3; y++)
                    {
                        if (map[x, y].cellType == floorCell)
                        {
                            cleaner |= (CleanUpCells)byteCounter; //OR operator for each Floor Tile
                        }
                        byteCounter *= 2;
                    }
                }

                //if (cleaner == (CleanUpCells.TopLeft | CleanUpCells.TopRight))
                if ((cleaner & (CleanUpCells.TopLeft | CleanUpCells.TopRight)) == (CleanUpCells.TopLeft | CleanUpCells.TopRight) && (cleaner & CleanUpCells.TopCenter) == CleanUpCells.None)
                {
                    map[mapX + 1, mapY + 2] = Cell.CreateCell(floorCell);
                }

                //if (cleaner == (CleanUpCells.TopLeft | CleanUpCells.BottomLeft))
                if ((cleaner & (CleanUpCells.TopLeft | CleanUpCells.BottomLeft)) == (CleanUpCells.TopLeft | CleanUpCells.BottomLeft) && (cleaner & CleanUpCells.MiddleLeft) == CleanUpCells.None)
                {
                    map[mapX, mapY + 1] = Cell.CreateCell(floorCell);
                }

                //if ((cleaner == (CleanUpCells.TopCenter | CleanUpCells.BottomCenter)) || (cleaner == (CleanUpCells.MiddleLeft | CleanUpCells.MiddleRight)))
                if (((cleaner & (CleanUpCells.TopCenter | CleanUpCells.BottomCenter)) == (CleanUpCells.TopCenter | CleanUpCells.BottomCenter)) || ((cleaner & (CleanUpCells.MiddleLeft | CleanUpCells.MiddleRight)) == (CleanUpCells.MiddleLeft | CleanUpCells.MiddleRight)) && (cleaner & CleanUpCells.MiddleCenter) == CleanUpCells.None)
                {
                    map[mapX + 1, mapY + 1] = Cell.CreateCell(floorCell);
                }

                //if (cleaner == (CleanUpCells.BottomRight | CleanUpCells.TopRight))
                if ((cleaner & (CleanUpCells.BottomRight | CleanUpCells.TopRight)) == (CleanUpCells.BottomRight | CleanUpCells.TopRight) && (cleaner & CleanUpCells.MiddleRight) == CleanUpCells.None)
                {
                    map[mapX + 2, mapY + 1] = Cell.CreateCell(floorCell);
                }

                //if (cleaner == (CleanUpCells.BottomRight | CleanUpCells.BottomLeft))
                if ((cleaner & (CleanUpCells.BottomRight | CleanUpCells.BottomLeft)) == (CleanUpCells.BottomRight | CleanUpCells.BottomLeft) && (cleaner & CleanUpCells.BottomCenter) == CleanUpCells.None)
                {
                    map[mapX + 1, mapY] = Cell.CreateCell(floorCell);
                }
            }
        }
    }
Пример #2
0
    public bool DoesPrefabHaveAWall(ref char prefab, CleanUpCells pos)
    {
        switch (pos)
        {
        case CleanUpCells.TopLeft:
            return(hasTopLeftWall.Contains(prefab));

        case CleanUpCells.TopCenter:
            return(hasTopCenterWall.Contains(prefab));

        //return false;

        case CleanUpCells.TopRight:
            return(hasTopRightWall.Contains(prefab));

        //return false;

        case CleanUpCells.MiddleLeft:
            return(hasMiddleLeftWall.Contains(prefab));

        //return false;

        case CleanUpCells.MiddleCenter:
            return(hasMiddleCenterWall.Contains(prefab));

        //return false;

        case CleanUpCells.MiddleRight:
            return(hasMiddleRightWall.Contains(prefab));

        //return false;

        case CleanUpCells.BottomLeft:
            return(hasBottomLeftWall.Contains(prefab));

        //return false;

        case CleanUpCells.BottomCenter:
            return(hasBottomCenterWall.Contains(prefab));

        //return false;

        case CleanUpCells.BottomRight:
            return(hasBottomRightWall.Contains(prefab));

        //return false;

        case CleanUpCells.None:
            return(false);

        default:
            Debug.LogError("Wrong CleanUpCell type");
            return(false);
        }
    }