-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBulldozer.cpp
More file actions
57 lines (48 loc) · 1.3 KB
/
Bulldozer.cpp
File metadata and controls
57 lines (48 loc) · 1.3 KB
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
#include "Bulldozer.h"
const int lastMudTileIndex = 438;
const int lastRockTileIndex = 1205;
const int dozedMudTileIndex = 414;
const int dozedRockTileIndex = 921;
const int dozedSandTileIndex = 1670;
bool IsDozeable(const LOCATION &location)
{
int currentCellType = GameMap::GetCellType(location);
return
currentCellType == CellTypes::cellFastPassible1 ||
currentCellType == CellTypes::cellFastPassible2 ||
currentCellType == CellTypes::cellMediumPassible1 ||
currentCellType == CellTypes::cellMediumPassible2 ||
currentCellType == CellTypes::cellSlowPassible1 ||
currentCellType == CellTypes::cellSlowPassible2;
}
void Doze(const LOCATION& loc)
{
if (!IsDozeable(loc)) {
return;
}
int originalTileIndex = GameMap::GetTile(loc);
if (originalTileIndex <= lastMudTileIndex)
{
GameMap::SetTile(loc, dozedMudTileIndex);
}
else if (originalTileIndex <= lastRockTileIndex)
{
GameMap::SetTile(loc, dozedRockTileIndex);
}
else
{
GameMap::SetTile(loc, dozedSandTileIndex);
}
GameMap::SetCellType(loc, CellTypes::cellDozedArea);
}
void Doze(const MAP_RECT &mapRect)
{
for (int y = 0; y < mapRect.Height(); ++y)
{
for (int x = 0; x < mapRect.Width(); ++x)
{
LOCATION dozeLoc(mapRect.x1 + x, mapRect.y1 + y);
Doze(dozeLoc);
}
}
}