private void SetConsoleSymbolForCell(RogueSharp.Cell cell)
    {
        if (!cell.IsExplored)
        {
            return;
        }

        if (IsInFov(cell.X, cell.Y))
        {
            if (cell.IsWalkable)
            {
                Display.CellAt(0, cell.X, cell.Y).SetContent(".", Colors.FloorBackgroundFov, Colors.FloorFov);
            }
            else
            {
                Display.CellAt(0, cell.X, cell.Y).SetContent("#", Colors.WallBackgroundFov, Colors.WallFov);
            }
        }
        else
        {
            if (cell.IsWalkable)
            {
                Display.CellAt(0, cell.X, cell.Y).SetContent(".", Colors.FloorBackground, Colors.Floor);
            }
            else
            {
                Display.CellAt(0, cell.X, cell.Y).SetContent("#", Colors.WallBackground, Colors.Wall);
            }
        }
    }
    private bool IsPotentialDoor(RogueSharp.Cell cell)
    {
        if (!cell.IsWalkable)
        {
            return(false);
        }

        RogueSharp.Cell right  = _map.GetCell(cell.X + 1, cell.Y);
        RogueSharp.Cell left   = _map.GetCell(cell.X - 1, cell.Y);
        RogueSharp.Cell top    = _map.GetCell(cell.X, cell.Y - 1);
        RogueSharp.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);
    }
        private Vector2 CenteredPosition(Cell cell, bool clampToMap = false) {
            var cameraPosition = new Vector2(cell.X * Global.SpriteWidth, cell.Y * Global.SpriteHeight);
            var cameraCenteredOnTilePosition = new Vector2(cameraPosition.X + Global.SpriteWidth / 2,
                                                            cameraPosition.Y + Global.SpriteHeight / 2);
            if (clampToMap) {
                return MapClampedPosition(cameraCenteredOnTilePosition);
            }

            return cameraCenteredOnTilePosition;
        }
Exemple #4
0
 public void MoveMonster(Monster monster, RogueSharp.Cell cell)
 {
     if (!Game.DungeonMap.SetActorPosition(monster, cell.X, cell.Y))
     {
         if (Game.Player.X == cell.X && Game.Player.Y == cell.Y)
         {
             Attack(monster, Game.Player);
         }
     }
 }
Exemple #5
0
    public bool Act(Monster monster, CommandSystem commandSystem)
    {
        DungeonMap map = Game.DungeonMap;

        // Ooze only splits when wounded
        if (monster.Health >= monster.MaxHealth)
        {
            return(false);
        }

        int halfHealth = monster.MaxHealth / 2;

        if (halfHealth <= 0)
        {
            // Health would be too low so bail out
            return(false);
        }

        RogueSharp.Cell cell = FindClosestUnoccupiedCell(map, monster.X, monster.Y);

        if (cell == null)
        {
            // No empty cells so bail out
            return(false);
        }

        // Make a new ooze with half the health of the old one
        Ooze newOoze = Monster.Clone(monster) as Ooze;

        if (newOoze != null)
        {
            newOoze.TurnsAlerted = 1;
            newOoze.X            = cell.X;
            newOoze.Y            = cell.Y;
            newOoze.MaxHealth    = halfHealth;
            newOoze.Health       = halfHealth;
            map.AddMonster(newOoze);
            Game.MessageLog.Add(string.Format("{0} splits itself in two", monster.Name));
        }
        else
        {
            // Not an ooze so bail out
            return(false);
        }

        // Halve the original ooze's health too
        monster.MaxHealth = halfHealth;
        monster.Health    = halfHealth;

        return(true);
    }
Exemple #6
0
 /// <summary>
 /// Returns an ordered IEnumerable of Cells representing the shortest path from a specified source Cell to a destination Cell
 /// </summary>
 /// <param name="source">The Cell which is at the start of the path</param>
 /// <param name="destination">The Cell which is at the end of the path</param>
 /// <returns>Returns an ordered IEnumerable of Cells representing the shortest path from a specified source Cell to a destination Cell</returns>
 public IEnumerable<Cell> ShortestPath( Cell source, Cell destination )
 {
     var dsp = new DijkstraShortestPath( _graph, IndexFor( source ) );
      IEnumerable<DirectedEdge> path = dsp.PathTo( IndexFor( destination ) );
      if ( path == null )
      {
     yield return null;
      }
      else
      {
     foreach ( DirectedEdge edge in path )
     {
        yield return CellFor( edge.To );
     }
      }
 }
    protected override bool UseItem()
    {
        DungeonMap map       = Game.DungeonMap;
        Player     player    = Game.Player;
        Point      edgePoint = GetRandomEdgePoint(map);

        Game.MessageLog.Add(string.Format("{0} uses a {1} and chaotically unleashes a void beam", player.Name, Name));
        Actor voidAttackActor = new Actor
        {
            Attack       = 6,
            AttackChance = 90,
            Name         = "The Void"
        };

        RogueSharp.Cell previousCell = null;
        foreach (RogueSharp.Cell 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);
    }
        /// <summary>
        /// Returns an ordered IEnumerable of Cells representing the shortest path from a specified source Cell to a destination Cell
        /// </summary>
        /// <param name="source">The Cell which is at the start of the path</param>
        /// <param name="destination">The Cell which is at the end of the path</param>
        /// <exception cref="ArgumentNullException">Thrown when source or destination is null</exception>
        /// <exception cref="PathNotFoundException">Thrown when there is not a path from the source to the destination</exception>
        /// <returns>Returns an ordered IEnumerable of Cells representing the shortest path from a specified source Cell to a destination Cell</returns>
        public Path ShortestPath( Cell source, Cell destination )
        {
            if ( source == null )
             {
            throw new ArgumentNullException( "source" );
             }

             if ( destination == null )
             {
            throw new ArgumentNullException( "destination" );
             }

             var cells = ShortestPathCells( source, destination ).ToList();
             if ( cells[0] == null )
             {
            throw new PathNotFoundException( string.Format( "Path from ({0}, {1}) to ({2}, {3}) not found", source.X, source.Y, destination.X, destination.Y ) );
             }
             return new Path( cells );
        }
    public void MoveMonster(Monster monster, RogueSharp.Cell cell)
    {
        if (cell.X > monster.X)
        {
            monster.go.transform.localScale = new Vector3(-1, 1, 1);
        }
        else if (cell.X < monster.X)
        {
            monster.go.transform.localScale = new Vector3(1, 1, 1);
        }

        if (!Game.DungeonMap.SetActorPosition(monster, cell.X, cell.Y))
        {
            if (Game.Player.X == cell.X && Game.Player.Y == cell.Y)
            {
                Attack(monster, Game.Player);
            }
        }
    }
 public void SetIsWalkable(int x, int y, bool isWalkable)
 {
     RogueSharp.Cell cell = GetCell(x, y);
     SetCellProperties(cell.X, cell.Y, cell.IsTransparent, isWalkable, cell.IsExplored);
 }
Exemple #11
0
 // Center the camera on a specific cell in the map
 internal void CenterOn( Cell cell )
 {
     Position = CenteredPosition( cell, true );
 }
 private int IndexFor( Cell cell )
 {
     return ( cell.Y * _map.Width ) + cell.X;
 }
Exemple #13
0
 /// <summary>
 /// Determines whether two Cell instances are equal
 /// </summary>
 /// <param name="other">The Cell to compare this instance to</param>
 /// <returns>True if the instances are equal; False otherwise</returns>
 /// <exception cref="NullReferenceException">Thrown if .Equals is invoked on null Cell</exception>
 protected bool Equals( Cell other )
 {
     if ( other == null )
      {
     return false;
      }
      return X == other.X && Y == other.Y && IsTransparent.Equals( other.IsTransparent ) && IsWalkable.Equals( other.IsWalkable ) && IsInFov.Equals( other.IsInFov ) && IsExplored.Equals( other.IsExplored );
 }
Exemple #14
0
 private bool AddToHashSet( HashSet<int> hashSet, int x, int y, out Cell cell )
 {
     cell = GetCell( x, y );
      return hashSet.Add( IndexFor( cell ) );
 }
Exemple #15
0
        /// <summary>
        /// Get the single dimensional array index for the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the index for</param>
        /// <returns>An index for the Cell which is useful if storing Cells in a single dimensional array</returns>
        /// <exception cref="ArgumentNullException">Thrown on null cell</exception>
        public int IndexFor( Cell cell )
        {
            if ( cell == null )
             {
            throw new ArgumentNullException( "cell", "Cell cannot be null" );
             }

             return ( cell.Y * Width ) + cell.X;
        }
Exemple #16
0
 // Center the camera on a specific cell in the map
 public void CenterOn(Cell cell)
 {
     Position = CenteredPosition(cell, true);
 }
 private void addPlayer(Cell startingCell) {
     _player = new Player {
         X = startingCell.X,
         Y = startingCell.Y,
         Scale = 1f,
         Sprite = this.Content.Load<Texture2D>("character"),
         speed = 1,
         ArmorClass = 15,
         AttackBonus = 1,
         Damage = Dice.Parse("2d4"),
         Health = 50,
         Name = "Mr. Rogue"
     };
 }