Ejemplo n.º 1
0
    bool IsPotentialDoor(Cell cell)
    {
        if (!cell.IsWalkable)
        {
            return(false);
        }

        Cell right  = GroundMap.GetCell(cell.X + 1, cell.Y);
        Cell left   = GroundMap.GetCell(cell.X - 1, cell.Y);
        Cell top    = GroundMap.GetCell(cell.X, cell.Y - 1);
        Cell bottom = GroundMap.GetCell(cell.X, cell.Y + 1);

        if (GetDoor(cell.X, cell.Y) != null ||
            GetDoor(right.X, right.Y) != null ||
            GetDoor(left.X, left.Y) != null ||
            GetDoor(top.X, top.Y) != null ||
            GetDoor(bottom.X, bottom.Y) != null)
        {
            return(false);
        }

        if (right.IsWalkable && left.IsWalkable && !top.IsWalkable && !bottom.IsWalkable)
        {
            return(true);
        }
        if (!right.IsWalkable && !left.IsWalkable && top.IsWalkable && bottom.IsWalkable)
        {
            return(true);
        }
        return(false);
    }