Example #1
0
        // Create the doors for each room
        private void CreateDoors(Rectangle room)
        {
            // The the boundries of the room
            int xMin = room.Left;
            int xMax = room.Right;
            int yMin = room.Top;
            int yMax = room.Bottom;

            // Put the rooms border cells into a list
            List <Cell> borderCells = _map.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList();

            borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMin, xMin, yMax));
            borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMax, xMax, yMax));
            borderCells.AddRange(_map.GetCellsAlongLine(xMax, yMin, xMax, yMax));

            // Go through each of the rooms border cells and look for locations to place doors.
            foreach (Cell cell in borderCells)
            {
                if (IsPotentialDoor(cell))
                {
                    // A door must block field-of-view when it is closed.
                    _map.SetCellProperties(cell.X, cell.Y, false, true);
                    _map.Doors.Add(new Door
                    {
                        X      = cell.X,
                        Y      = cell.Y,
                        IsOpen = false
                    });
                }
            }
        }
Example #2
0
        //Create Doors
        private void CreateDoors(Rectangle room)
        {
            //the boundaries of the room
            int xMin = room.Left;
            int xMax = room.Right;
            int yMin = room.Top;
            int yMax = room.Bottom;

            //put the room border cells into a list
            List <ICell> borderCells = _map.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList();

            borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMin, xMin, yMax));
            borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMax, xMax, yMax));
            borderCells.AddRange(_map.GetCellsAlongLine(xMax, yMin, xMax, yMax));

            //Go through each room of the border cells and look for locations too place doors
            foreach (Cell cell in borderCells)
            {
                if (IsPotentialDoor(cell))
                {
                    //if door is closed it must block te field of view
                    //done at the start because all doors will start off closed
                    _map.SetCellProperties(cell.X, cell.Y, false, true);

                    //add door at this position and check that the door is closed
                    _map.Doors.Add(new Door
                    {
                        X      = cell.X,
                        Y      = cell.Y,
                        IsOpen = false
                    });;
                }
            }
        }
        private void CreateDoors(Rectangle room)
        {
            int xMin = room.Left;
            int xMax = room.Right;
            int yMin = room.Top;
            int yMax = room.Bottom;

            List <Cell> borderCells = _map.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList();

            borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMin, xMin, yMax));
            borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMax, xMax, yMax));
            borderCells.AddRange(_map.GetCellsAlongLine(xMax, yMin, xMax, yMax));

            foreach (Cell cell in borderCells)
            {
                if (IsPotentialDoor(cell))
                {
                    _map.SetCellProperties(cell.X, cell.Y, false, true);
                    _map.Doors.Add(new Door {
                        X      = cell.X,
                        Y      = cell.Y,
                        IsOpen = false
                    });
                }
            }
        }
Example #4
0
        private void CreateDoors(Rectangle room)
        {
            int xMin = room.Left;
            int xMax = room.Right;
            int yMin = room.Top;
            int yMax = room.Bottom;

            List <ICell> borderCells = map.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList();

            borderCells.AddRange(map.GetCellsAlongLine(xMin, yMin, xMin, yMax));
            borderCells.AddRange(map.GetCellsAlongLine(xMin, yMax, xMax, yMax));
            borderCells.AddRange(map.GetCellsAlongLine(xMax, yMin, xMax, yMax));

            foreach (ICell cell in borderCells)
            {
                if (IsPotentialDoor(cell))
                {
                    // A door must block field-of-view when it is closed.
                    map.SetCellProperties(cell.X, cell.Y, false, true);
                    map.Doors.Add(new Door
                    {
                        X      = cell.X,
                        Y      = cell.Y,
                        IsOpen = false
                    });
                }
            }
        }
Example #5
0
        private void CreateDoors(Rectangle room)
        {
            // Los límites de la habitación.
            int xMin = room.Left;
            int xMax = room.Right;
            int yMin = room.Top;
            int yMax = room.Bottom;

            // Colocamos las celdas que se encuentran en los bordes de
            // la habitación dentro de una lista.
            List <Cell> borderCells = _mazmorra.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList();

            borderCells.AddRange(_mazmorra.GetCellsAlongLine(xMin, yMin, xMin, yMax));
            borderCells.AddRange(_mazmorra.GetCellsAlongLine(xMin, yMax, xMax, yMax));
            borderCells.AddRange(_mazmorra.GetCellsAlongLine(xMax, yMin, xMax, yMax));

            // Examinamos cada una de las celdas de la habitación que
            // se encuentra en los bordes y buscamos lo lugares idelas para
            // colocar una puerta.
            foreach (Cell cell in borderCells)
            {
                if (IsPotencialDoor(cell))
                {
                    // Una puerta debe bloquear el campo-de-visión cuando está cerrada.
                    _mazmorra.SetCellProperties(cell.X, cell.Y, false, true);
                    _mazmorra.Doors.Add(new Door
                    {
                        X      = cell.X,
                        Y      = cell.Y,
                        IsOpen = false
                    });
                }
            }
        }
    private void CreateDoors(Rectangle room)
    {
        int xMin = room.Left;
        int xMax = room.Right;
        int yMin = room.Top;
        int yMax = room.Bottom;

        List <Cell> borderCells = _map.GetCellsAlongLine(xMin, yMin, xMax, yMin).ToList();

        borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMin, xMin, yMax));
        borderCells.AddRange(_map.GetCellsAlongLine(xMin, yMax, xMax, yMax));
        borderCells.AddRange(_map.GetCellsAlongLine(xMax, yMin, xMax, yMax));

        foreach (Cell cell in borderCells)
        {
            if (IsPotentialDoor(cell))
            {
                _map.SetCellProperties(cell.X, cell.Y, false, true);
                var door     = new Entry();
                var instance = GameObject.Instantiate <GameObject>(Game.Items["Door"], new Vector2(cell.X, cell.Y), Quaternion.identity);
                door.Stat = "close";
                door.go   = instance;
                instance.transform.SetParent(Game.itemsHolder);
                instance.GetComponent <Renderer>().enabled = false;
                Game.ItemsTiles[cell.X, cell.Y]            = door;
                _map.Doors.Add(door);
            }
        }
    }
 public void Draw()
 {
     if (IsPlayerTargeting)
     {
         DungeonMap map    = Game.DungeonMap;
         Player     player = Game.Player;
         if (_selectionType == SelectionType.Area)
         {
             foreach (Cell cell in map.GetCellsInArea(_cursorPosition.X, _cursorPosition.Y, _area))
             {
                 var instance = GameObject.Instantiate <GameObject>(Game.Items["Effect"], new Vector2(cell.X, cell.Y),
                                                                    Quaternion.identity);
                 instance.transform.SetParent(Game.effectsHolder);
             }
         }
         else if (_selectionType == SelectionType.Line)
         {
             foreach (Cell cell in map.GetCellsAlongLine(player.X, player.Y, _cursorPosition.X, _cursorPosition.Y))
             {
                 var instance = GameObject.Instantiate <GameObject>(Game.Items["Effect"], new Vector2(cell.X, cell.Y),
                                                                    Quaternion.identity);
                 instance.transform.SetParent(Game.effectsHolder);
             }
         }
         var go = GameObject.Instantiate <GameObject>(Game.Items["Effect"], new Vector2(_cursorPosition.X, _cursorPosition.Y),
                                                      Quaternion.identity);
         go.transform.SetParent(Game.effectsHolder);
     }
 }
        protected override bool UseItem()
        {
            DungeonMap map       = Game.DungeonMap;
            Player     player    = Game.Player;
            Point      edgePoint = GetRandomEdgePoint(map);

            Game.MessageLog.Add($"You use a {Name} and chaotically unleashes a void beam");
            Actor voidAttackActor = new Actor
            {
                Attack       = 12,
                AttackChance = 90,
                Name         = "The Void"
            };

            ICell previousCell = null;

            foreach (ICell cell in map.GetCellsAlongLine(player.X, player.Y, edgePoint.X, edgePoint.Y))
            {
                if (cell.X == player.X && cell.Y == player.Y)
                {
                    continue;
                }

                Monster monster = map.GetMonsterAt(cell.X, cell.Y);
                if (monster != null)
                {
                    Game.CommandSystem.Attack(voidAttackActor, monster);
                }
                else
                {
                    map.SetCellProperties(cell.X, cell.Y, true, true, true);
                    if (previousCell != null)
                    {
                        if (cell.X != previousCell.X || cell.Y != previousCell.Y)
                        {
                            map.SetCellProperties(cell.X + 1, cell.Y, true, true, true);
                        }
                    }
                    previousCell = cell;
                }
            }

            RemainingUses--;

            return(true);
        }
        public void SelectTarget(Point target)
        {
            DungeonMap map    = Game.DungeonMap;
            Player     player = Game.Player;

            Game.MessageLog.Add($"{player.Name} casts a {Name}");

            Actor lightningBoltActor = new Actor {
                Attack       = _attack,
                AttackChance = _attackChance,
                Name         = Name
            };

            foreach (ICell cell in map.GetCellsAlongLine(player.X, player.Y, target.X, target.Y))
            {
                if (cell.IsWalkable)
                {
                    continue;
                }

                if (cell.X == player.X && cell.Y == player.Y)
                {
                    continue;
                }

                Monster monster = map.GetMonsterAt(cell.X, cell.Y);
                if (monster != null)
                {
                    Game.CommandSystem.Attack(lightningBoltActor, monster);
                    if (Dice.Roll("1D100") < _poisonChance)
                    {
                        if (monster.IsPoisonedImmune == false && _poisonDamage != 0)
                        {
                            monster.State = new MonsterAbnormalState(monster, _poisonLength, "Poisoned", -2, -2, _poisonDamage);
                        }
                    }
                }
                else
                {
                    return;
                }
            }
        }
Example #10
0
    public void SelectTarget(Point target)
    {
        DungeonMap map    = Game.DungeonMap;
        Player     player = Game.Player;

        Game.MessageLog.Add(string.Format("{0} casts a {1}", player.Name, Name));

        Actor lightningBoltActor = new Actor
        {
            Attack       = _attack,
            AttackChance = _attackChance,
            Name         = Name
        };

        foreach (RogueSharp.Cell cell in map.GetCellsAlongLine(player.X, player.Y, target.X, target.Y))
        {
            if (cell.IsWalkable)
            {
                continue;
            }

            if (cell.X == player.X && cell.Y == player.Y)
            {
                continue;
            }

            Monster monster = map.GetMonsterAt(cell.X, cell.Y);
            if (monster != null)
            {
                Game.CommandSystem.Attack(lightningBoltActor, monster);
            }
            else
            {
                // We hit a wall so stop the bolt
                // TODO: consider having bolts and fireballs destroy walls and leave rubble
                return;
            }
        }
    }
Example #11
0
        public void Draw(RLConsole mapConsole)
        {
            if (IsPlayerTargeting)
            {
                DungeonMap map    = Game.DungeonMap;
                Player     player = Game.Player;
                if (_selectionType == SelectionType.Area)
                {
                    foreach (Cell cell in map.GetCellsInSquare(_cursorPosition.X, _cursorPosition.Y, _area))
                    {
                        mapConsole.SetBackColor(cell.X, cell.Y, Palette.DbSun);
                    }
                }
                else if (_selectionType == SelectionType.Line)
                {
                    foreach (Cell cell in map.GetCellsAlongLine(player.X, player.Y, _cursorPosition.X, _cursorPosition.Y))
                    {
                        mapConsole.SetBackColor(cell.X, cell.Y, Palette.DbSun);
                    }
                }

                mapConsole.SetBackColor(_cursorPosition.X, _cursorPosition.Y, Palette.DbLight);
            }
        }
Example #12
0
        public void Draw(Console mapConsole)
        {
            if (IsPlayerTargeting)
            {
                DungeonMap map    = RogueGame.DungeonMap;
                Player     player = RogueGame.Player;
                if (_selectionType == SelectionType.Area)
                {
                    foreach (Cell cell in map.GetCellsInArea(_cursorPosition.X, _cursorPosition.Y, _area))
                    {
                        mapConsole.CellData.SetBackground(cell.X, cell.Y, Swatch.DbSun);
                    }
                }
                else if (_selectionType == SelectionType.Line)
                {
                    foreach (Cell cell in map.GetCellsAlongLine(player.X, player.Y, _cursorPosition.X, _cursorPosition.Y))
                    {
                        mapConsole.CellData.SetBackground(cell.X, cell.Y, Swatch.DbSun);
                    }
                }

                mapConsole.CellData.SetBackground(_cursorPosition.X, _cursorPosition.Y, Swatch.DbLight);
            }
        }
    public void Draw()
    {
        if (IsPlayerTargeting)
        {
            DungeonMap map    = Game.DungeonMap;
            Player     player = Game.Player;
            if (_selectionType == SelectionType.Area)
            {
                foreach (RogueSharp.Cell cell in map.GetCellsInArea(_cursorPosition.X, _cursorPosition.Y, _area))
                {
                    Display.CellAt(0, cell.X, cell.Y).SetContent(" ", Colors.FloorBackground, Swatch.DbSun);
                }
            }
            else if (_selectionType == SelectionType.Line)
            {
                foreach (RogueSharp.Cell cell in map.GetCellsAlongLine(player.X, player.Y, _cursorPosition.X, _cursorPosition.Y))
                {
                    Display.CellAt(0, cell.X, cell.Y).SetContent(" ", Colors.FloorBackground, Swatch.DbSun);
                }
            }

            Display.CellAt(0, _cursorPosition.X, _cursorPosition.Y).SetContent(" ", Colors.FloorBackground, Swatch.DbLight);
        }
    }