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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Brains.Framework.Utility;
namespace Brains.Framework.Map
{
/// <summary>
/// Stores values about a cell within a grid.
/// </summary>
/// <remarks>Used for pathfinding and other positioning techniques</remarks>
public class GridCell
{
private int _x;
private int _y;
private int _type;
private Vector2 _position;
/// <summary>
/// Gets or sets the annotation labels on the cell
/// </summary>
public Dictionary<uint, int> Labels;
/// <summary>
/// Gets the agents currently occupying this cell
/// </summary>
public List<Agent> Agents;
/// <summary>
/// The Col index of the Grid Cell
/// </summary>
public int X { get { return _x; } }
/// <summary>
/// The Row index of the Grid Cell
/// </summary>
public int Y { get { return _y; } }
/// <summary>
/// The center position of the Grid Cell
/// </summary>
public Vector2 Position { get { return _position; } }
/// <summary>
/// Type value of the Grid Cell.
/// </summary>
/// <remarks>1 = Empty, 0 = Blocked</remarks>
public int Type
{
get { return _type; }
set
{
_type = value;
Labels[AIConsts.BLOCKED_TILE] = _type == 0 ? 1 : 0;
}
}
/// <summary>
/// The Parent Grid
/// </summary>
public Grid Parent { get; set; }
/// <summary>
/// Default Constructor
/// </summary>
public GridCell()
{
Agents = new List<Agent>();
}
/// <summary>
/// Initializes a new instance of the GridCell class with the specified x and y position and its position in world coordinates
/// </summary>
/// <param name="x">The X index of the GridCell</param>
/// <param name="y">The Y index of the GridCell</param>
/// <param name="position">The world coordinates of the gridcell</param>
public GridCell(int x, int y, Vector2 position)
{
Labels = new Dictionary<uint, int>();
Labels.Add(AIConsts.BLOCKED_TILE, 0);
Labels.Add(AIConsts.RESERVED, 0);
Labels.Add(AIConsts.CLEARANCEVALUE,0);
Labels.Add(AIConsts.COLORR, 0);
Labels.Add(AIConsts.COLORG, 0);
Labels.Add(AIConsts.COLORB, 0);
Labels.Add(AIConsts.COLORA, 0);
_x = x;
_y = y;
_position = position;
Agents = new List<Agent>();
}
}
} |