private bool IsPotentialDoor(Cell cell)
        {
            if (!cell.IsWalkable)
            {
                return(false);
            }

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

            if (_map.GetDoor(cell.X, cell.Y) != null ||
                _map.GetDoor(right.X, right.Y) != null ||
                _map.GetDoor(left.X, left.Y) != null ||
                _map.GetDoor(top.X, top.Y) != null ||
                _map.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);
        }
Esempio n. 2
0
    /// <summary>
    /// Checks to see if a cell is a good candidate for placement of a door.
    /// </summary>
    /// <param name="cell"></param>
    /// <returns></returns>
    private bool IsPotentialDoor(Cell cell)
    {
        if (!cell.IsWalkable)                                                           // If the cell is not walkable then it is a wall and not a good place for a door
        {
            return(false);
        }

        Cell right  = (Cell)map.GetCell(cell.X + 1, cell.Y);                            // Store references to all of the neighboring cells
        Cell left   = (Cell)map.GetCell(cell.X - 1, cell.Y);
        Cell top    = (Cell)map.GetCell(cell.X, cell.Y - 1);
        Cell bottom = (Cell)map.GetCell(cell.X, cell.Y + 1);

        if (map.GetDoor(cell.X, cell.Y) != null ||
            map.GetDoor(right.X, right.Y) != null ||
            map.GetDoor(left.X, left.Y) != null ||
            map.GetDoor(top.X, top.Y) != null ||
            map.GetDoor(bottom.X, bottom.Y) != null)                                    // Make sure there is not already a door here
        {
            return(false);
        }

        if (right.IsWalkable && left.IsWalkable && !top.IsWalkable && !bottom.IsWalkable)// This is a good place for a door on the left or right side of the room
        {
            return(true);
        }

        if (!right.IsWalkable && !left.IsWalkable && top.IsWalkable && bottom.IsWalkable)// This is a good place for a door on the top or bottom of the room
        {
            return(true);
        }
        return(false);
    }
Esempio n. 3
0
        //Checks to see if a cell is a candidate for door placement
        private bool IsPotentialDoor(Cell cell)
        {
            //If cell is a wall it is not a good place for a door
            if (!cell.IsWalkable)
            {
                return(false);
            }

            //Store references to all of the neighboring cells
            Cell right  = _map.GetCell(cell.X + 1, cell.Y);
            Cell left   = _map.GetCell(cell.X - 1, cell.Y);
            Cell top    = _map.GetCell(cell.X, cell.Y - 1);
            Cell bottom = _map.GetCell(cell.X, cell.Y + 1);

            //Check that there is not already a door there
            if (_map.GetDoor(cell.X, cell.Y) != null ||
                _map.GetDoor(right.X, right.Y) != null ||
                _map.GetDoor(left.X, left.Y) != null ||
                _map.GetDoor(top.X, top.Y) != null ||
                _map.GetDoor(bottom.X, bottom.Y) != null)
            {
                return(false);
            }
            //Check if the left or right side is a good spot for the door
            if (right.IsWalkable && left.IsWalkable && !top.IsWalkable && !bottom.IsWalkable)
            {
                return(true);
            }
            //Check if the top or bottom is a good spot for the door
            if (!right.IsWalkable && !left.IsWalkable && top.IsWalkable && bottom.IsWalkable)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        // Revisamos si una celda es una buena candidata para colocar una puerta.
        private bool IsPotencialDoor(Cell cell)
        {
            // Si la celda es no transitable entonces es un pared y no es
            // un buen lugar para colocar una puerta.
            if (!cell.IsWalkable)
            {
                return(false);
            }

            // Almacenamos las referencias a todas las celdas vecinas.
            Cell right = _mazmorra.GetCell(cell.X + 1, cell.Y);
            Cell left  = _mazmorra.GetCell(cell.X - 1, cell.Y);
            Cell top   = _mazmorra.GetCell(cell.X, cell.Y - 1);
            Cell botom = _mazmorra.GetCell(cell.X, cell.Y + 1);

            // Nos aseguramos de que no haya una puerta aquí.
            if (_mazmorra.GetDoor(cell.X, cell.Y) != null ||
                _mazmorra.GetDoor(right.X, right.Y) != null ||
                _mazmorra.GetDoor(left.X, left.Y) != null ||
                _mazmorra.GetDoor(top.X, top.Y) != null ||
                _mazmorra.GetDoor(botom.X, botom.Y) != null)
            {
                return(false);
            }

            // Este es un buen lugar para una puerta y es en la
            // izquierda o derecha de la habitación.
            if (right.IsWalkable && left.IsWalkable && !top.IsWalkable && !botom.IsWalkable)
            {
                return(true);
            }

            // Este es un buen lugar para una puerta y es en la
            // parte de arriba o de abajo de la habitación.
            if (!right.IsWalkable && !left.IsWalkable && top.IsWalkable && botom.IsWalkable)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        //Checks to see if a cell is a good place for a door
        private bool IsPotentialDoor(ICell cell)
        {
            //If the cell is not walkable
            //then it is a wall and not a good place for a door
            if (!cell.IsWalkable)
            {
                return(false);
            }

            //check all of the neighbouring cells
            ICell right  = _map.GetCell(cell.X + 1, cell.Y);
            ICell left   = _map.GetCell(cell.X - 1, cell.Y);
            ICell top    = _map.GetCell(cell.X, cell.Y - 1);
            ICell bottom = _map.GetCell(cell.X + 1, cell.Y + 1);

            //make sure that a door is not already there
            if (_map.GetDoor(cell.X, cell.Y) != null ||
                _map.GetDoor(right.X, right.Y) != null ||
                _map.GetDoor(left.X, left.Y) != null ||
                _map.GetDoor(top.X, top.Y) != null ||
                _map.GetDoor(bottom.X, bottom.Y) != null)
            {
                return(false);
            }

            //good place for a door on the right or left of the room
            if (right.IsWalkable && left.IsWalkable && !top.IsWalkable && !bottom.IsWalkable)
            {
                return(true);
            }

            //good place for a door on the top or bottom of the room
            if (!right.IsWalkable && !left.IsWalkable && top.IsWalkable && bottom.IsWalkable)
            {
                return(true);
            }
            return(false);
        }
        private void GenerateMap()
        {
            // Create the map
            //RogueSharp.MapCreation.IMapCreationStrategy<RogueSharp.Map> mapCreationStrategy
            //    = new RogueSharp.MapCreation.RandomRoomsMapCreationStrategy<RogueSharp.Map>(Width, Height, 100, 20, 7);
            //rogueMap = RogueSharp.Map.Create(mapCreationStrategy);
            MapGenerator mapGenerator = new MapGenerator(Width, Height, 50, 12, 6);

            // TODO: I don't think I should have two maps
            detailedMap = mapGenerator.CreateMap();
            rogueMap    = detailedMap;

            rogueFOV = new RogueSharp.FieldOfView(rogueMap);
            mapData  = new MapObjects.MapObjectBase[Width, Height];

            // Loop through the map information generated by RogueSharp and create our cached visuals of that data
            foreach (var cell in rogueMap.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    if (detailedMap.GetDoor(cell.X, cell.Y) == null)
                    {
                        mapData[cell.X, cell.Y] = new Floor();
                    }
                    else
                    {
                        mapData[cell.X, cell.Y] = new Door('+');
                    }
                    mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], false, false);
                }
                else
                {
                    //rogueMap.SetCellProperties(cell.X, cell.Y, false, false);
                    mapData[cell.X, cell.Y] = new MapObjects.Wall();
                    mapData[cell.X, cell.Y].RenderToCell(this[cell.X, cell.Y], false, false);

                    // We're a wall, so we block LOS
                    rogueMap.SetCellProperties(cell.X, cell.Y, false, cell.IsWalkable);
                }
            }


            Monsters = detailedMap.getMonsters(Position - textSurface.RenderArea.Location);
            PositionPlayer();
        }