1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brains.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
namespace ZuneDemo.Renderer
{
public class DrawableWorld : World
{
public static Texture2D pointTexture;
public DrawableWorld(ContentManager content)
{
pointTexture = content.Load<Texture2D>("Textures/point");
}
public void Render(SpriteBatch batch)
{
for (int x = 0; x < this.Map.ClusterGrid.Cols; x++)
{
for (int y = 0; y < this.Map.ClusterGrid.Rows; y++)
{
this.DrawGrid(batch, this.Map.ClusterGrid.Grids[this.Map.ClusterGrid.GetGridIndex(x, y)]);
}
}
foreach (var item in this.Actors)
{
((DrawableAgent)item).Render(batch);
}
}
private void DrawGrid(SpriteBatch batch, Brains.Framework.Map.Grid grid)
{
for (int x = 0; x < grid.Cols; x++)
{
Rectangle rect = new Rectangle(0, 0, 1, 1);
rect.Height= grid.Height;
rect.X = x * grid.CellSize;
rect.Y = 0;
batch.Draw(pointTexture, rect, Color.White);
for (int y = 0; y < grid.Rows; y++)
{
rect = new Rectangle(0, 0, 1, 1);
rect.Width = grid.Width;
rect.X = 0;
rect.Y = y * grid.CellSize;
batch.Draw(pointTexture, rect, Color.White);
}
}
}
}
} |