Beispiel #1
0
    // Returns true if this passage cell can be removed from the map (i.e. not shown)
    public bool IsPassageRemovable(CellLocation l)
    {
        VirtualCell cell = this.GetCell(l);

        if (cell.IsWall() || cell.IsEmpty())
        {
            // We count how many valid neighs are floors, and how many are nones
            int validNeigh = 0;
            int floorCount = 0;
            int noneCount  = 0;

            CellLocation n;
            foreach (DirectionType dir in directions)
            {
                n = GetNeighbourCellLocation(l, dir);
                if (!LocationIsOutsideBounds(n))
                {
                    validNeigh++;
                    VirtualCell neigh_cell = GetCell(n);
                    if (neigh_cell.IsFloor())
                    {
                        floorCount++;
                    }
                    else if (neigh_cell.IsNone() || neigh_cell.IsRock())
                    {
                        noneCount++;
                    }
                }
            }
            //Debug.Log(l + " Valid neighs: " + validNeigh + " floorCount: " + floorCount + " noneCount: " + noneCount);
            return(floorCount == 0);
        }
        return(false);
    }
    protected void ConvertFake3DEffect(VirtualMap map, VirtualCell conversion_cell)
    {
        CellLocation below_loc = map.GetNeighbourCellLocation(conversion_cell.location, VirtualMap.DirectionType.South);

        if ((conversion_cell.IsColumn() || conversion_cell.IsWall()))
        {
            // If we have a wall below and this is a wall, we transform this to a special wall
            bool        isAbove    = false;
            VirtualCell below_cell = null;
            if (!map.LocationIsOutsideBounds(below_loc))
            {
                below_cell = map.GetCell(below_loc);
                if (below_cell.IsColumn() || below_cell.IsWall() || below_cell.IsRock())
                {
                    isAbove = true;
                }
                else
                {
                    isAbove = false;
                }
            }
            else
            {
                isAbove = true;
            }

            if (isAbove)
            {
                if (conversion_cell.IsRoom())
                {
                    conversion_cell.Type = VirtualCell.CellType.Fake3D_Room_WallAbove;
                }
                else
                {
                    conversion_cell.Type = VirtualCell.CellType.Fake3D_Corridor_WallAbove;
                }
            }
            else
            {
                if (conversion_cell.IsRoom())
                {
                    conversion_cell.Type = VirtualCell.CellType.Fake3D_Room_WallFront;

//					// Also, we add this to make sure the doors work correctly
//					if (below_cell.IsDoor()){
//						conversion_cell.AddCellInstance(VirtualCell.CellType.DoorHorizontalTop,below_cell.Orientation);
//					}
                }
                else
                {
                    conversion_cell.Type = VirtualCell.CellType.Fake3D_Corridor_WallFront;
                }
            }

            conversion_cell.Orientation = VirtualMap.DirectionType.West;             // Force orientation
        }
        else if (conversion_cell.IsDoor())
        {
            if (conversion_cell.IsHorizontal())
            {
                conversion_cell.Type = VirtualCell.CellType.DoorHorizontalBottom;
            }
            else
            {
                conversion_cell.Type = VirtualCell.CellType.DoorVertical;
            }
        }
    }
Beispiel #3
0
    // Returns true if this 'none' (i.e. column) cell can be removed from the map (i.e. not shown)
    public bool IsColumnRemovable(CellLocation l, bool drawCorners = true, bool createColumnsInRooms = false)
    {
        VirtualCell cell = this.GetCell(l);

        if (cell.IsNone())  // Should be performed only on a NONE
        {
            int validNeigh = 0;
            int wallCount  = 0;
            int emptyCount = 0;

            CellLocation n;
            foreach (DirectionType dir in directions)
            {
                n = GetNeighbourCellLocation(l, dir);
                if (!LocationIsOutsideBounds(n))
                {
                    validNeigh++;
                    VirtualCell neigh_cell = GetCell(n);
                    //Debug.Log(neigh_cell.Type);
                    if (neigh_cell.IsEmpty() || neigh_cell.IsRock())
                    {
                        emptyCount++;
                    }
                    else
                    {
                        wallCount++;

                        // HACK: we need to do this or the columns won't know if the walls have been made removable during this step!
                        if (IsPassageRemovable(n))
                        {
                            wallCount--;
                            emptyCount++;
                        }
                    }
                    //Debug.Log("Neigh " + n + " is " + GetCell(n).Type);
                }
            }

            //Debug.Log("Cell " + l + " W " + wallCount + " ,  E " + emptyCount + " ,  V " + validNeigh);
            if (!drawCorners)
            {
                // We do not draw corners of rooms (corner = two walls and adjacent)
                if (wallCount == 2)
                {
                    // We check whether the two walls are adjacent (also doors)
                    // At least one neigh wall need not be removable as well for this to be a corner (and not an isolated None cell)
                    bool lastWasWall = false;
                    foreach (DirectionType dir in directions)
                    {
                        n = GetNeighbourCellLocation(l, dir);
                        //Debug.Log(n);
                        if (!LocationIsOutsideBounds(n) && (GetCell(n).IsWall() || GetCell(n).IsDoor()))
                        {
                            //Debug.Log("WALL!");
                            if (lastWasWall)
                            {
                                return(true);               // Adjacent!
                            }
                            lastWasWall = true;
                        }
                        else
                        {
                            lastWasWall = false;
                        }
                    }
                }
            }


            // HACK: check if we are in a room (as in the standardmap a roomcolumn is in fact surrounded by empties!)
            if (IsInRoom(l) && createColumnsInRooms)
            {
                return(false);
            }

            return(wallCount == 0);
        }
        return(false);
    }