diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -445,8 +445,8 @@ batch.DrawString(font, camera.position.ToString(), new Vector2(190, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); batch.DrawString(font, camera.position.ToString(), new Vector2(189, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f); - batch.DrawString(font, this.map.trees.ToString(), new Vector2(330, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); - batch.DrawString(font, this.map.trees.ToString(), new Vector2(329, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f); + batch.DrawString(font, this.map.tree_count.ToString(), new Vector2(330, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); + batch.DrawString(font, this.map.tree_count.ToString(), new Vector2(329, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f); batch.End(); diff --git a/isometric-park-fna/TileMap.cs b/isometric-park-fna/TileMap.cs --- a/isometric-park-fna/TileMap.cs +++ b/isometric-park-fna/TileMap.cs @@ -15,20 +15,14 @@ public int MapWidth = 50; public int MapHeight = 50; - public int trees + public int tree_count { get { int count = 0; - foreach (List row in cells) + foreach (Cell cell in this.tree_cells()) { - foreach (Cell cell in row) - { - if (cell.hasTree) - { - count++; - } - } + count++; } return count; } @@ -59,7 +53,32 @@ } - + public System.Collections.IEnumerable tree_cells() + { + foreach (List row in cells) + { + foreach (Cell cell in row) + { + if (cell.hasTree) + { + yield return cell; + } + } + } + } + + public System.Collections.IEnumerable iterate_cells() + { + foreach (List row in cells) + { + foreach (Cell cell in row) + { + yield return cell; + } + } + } + + } public class Cell