Description:
Add iterators to TileMap.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r10:7bbb2fda7731 -

@@ -445,8 +445,8
445 batch.DrawString(font, camera.position.ToString(), new Vector2(190, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
445 batch.DrawString(font, camera.position.ToString(), new Vector2(190, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
446 batch.DrawString(font, camera.position.ToString(), new Vector2(189, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
446 batch.DrawString(font, camera.position.ToString(), new Vector2(189, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
447
447
448 batch.DrawString(font, this.map.trees.ToString(), new Vector2(330, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
448 batch.DrawString(font, this.map.tree_count.ToString(), new Vector2(330, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
449 batch.DrawString(font, this.map.trees.ToString(), new Vector2(329, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
449 batch.DrawString(font, this.map.tree_count.ToString(), new Vector2(329, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
450
450
451 batch.End();
451 batch.End();
452
452
@@ -15,20 +15,14
15 public int MapWidth = 50;
15 public int MapWidth = 50;
16 public int MapHeight = 50;
16 public int MapHeight = 50;
17
17
18 public int trees
18 public int tree_count
19 {
19 {
20 get
20 get
21 {
21 {
22 int count = 0;
22 int count = 0;
23 foreach (List<Cell> row in cells)
23 foreach (Cell cell in this.tree_cells())
24 {
24 {
25 foreach (Cell cell in row)
25 count++;
26 {
27 if (cell.hasTree)
28 {
29 count++;
30 }
31 }
32 }
26 }
33 return count;
27 return count;
34 }
28 }
@@ -59,7 +53,32
59
53
60 }
54 }
61
55
62
56 public System.Collections.IEnumerable tree_cells()
57 {
58 foreach (List<Cell> row in cells)
59 {
60 foreach (Cell cell in row)
61 {
62 if (cell.hasTree)
63 {
64 yield return cell;
65 }
66 }
67 }
68 }
69
70 public System.Collections.IEnumerable iterate_cells()
71 {
72 foreach (List<Cell> row in cells)
73 {
74 foreach (Cell cell in row)
75 {
76 yield return cell;
77 }
78 }
79 }
80
81
63 }
82 }
64
83
65 public class Cell
84 public class Cell
You need to be logged in to leave comments. Login now