12 return POIMap.mapSize / POIMap.cellSize + 1;
17 public void Init(
int _mapSize,
int _cellSize)
19 POIMap.cellSize = _cellSize;
20 POIMap.mapSize = _mapSize;
21 this.cells =
new POIMap.
Cell[this.length, this.length];
28 for (
int i = 0; i < this.length; i++)
30 for (
int j = 0; j < this.length; j++)
42 public Point GetCenterOfEmptyCell(
int tries = 100)
45 for (
int i = 0; i < tries; i++)
47 int num =
EClass.rnd(this.length - 2) + 1;
48 int num2 =
EClass.rnd(this.length - 2) + 1;
49 if (!this.cells[num, num2].occupied)
51 return this.cells[num, num2].GetCenter();
60 return this.cells[this.length / 2 - radius +
EClass.rnd(radius * 2), this.length / 2 - radius +
EClass.rnd(radius * 2)];
67 for (
int i = 0; i < 100; i++)
69 int num =
EClass.rnd(this.length - 2) + 1;
70 int num2 =
EClass.rnd(this.length - 2) + 1;
71 if (this.cells[num, num2] ==
null)
73 return this.cells[num, num2];
80 public void ForeachCenterOfEmptyCell(Action<Point> action)
82 for (
int i = 1; i < this.length - 2; i++)
84 for (
int j = 1; j < this.length - 2; j++)
86 if (!this.cells[i, j].occupied)
88 action(this.cells[i, j].GetCenter());
95 public void OccyupyPOI(
Point p,
int radius = 0)
97 this.OccyupyPOI(p.x, p.z, radius);
101 public void OccyupyPOI(
int _x,
int _z,
int radius)
103 int num = _x /
POIMap.cellSize;
104 int num2 = _z /
POIMap.cellSize;
105 this.cells[num, num2].occupied =
true;
108 for (
int i = num - radius; i < num + radius + 1; i++)
110 if (i >= 0 && i < this.length)
112 for (
int j = num2 - radius; j < num2 + radius + 1; j++)
114 if (j >= 0 && j < this.length)
116 this.cells[i, j].occupied =
true;
125 public static int cellSize;
128 public static int mapSize;
137 public Point GetCenter()
149 public bool occupied;