-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelMap.cpp
More file actions
164 lines (148 loc) · 4.38 KB
/
LevelMap.cpp
File metadata and controls
164 lines (148 loc) · 4.38 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
* Authors: Alysha Aul, Nandhitha Krishnan, Paul Rodgers, Nouran Sakr, Chun Yang
* Date: November 28, 2023
* Purpose: To act as a 2D map and contains every information about it.
*/
#include "LevelMap.h"
/**
* Set the map when we need to have custom map.
* @param map: it is a matrix of Blocks which represent the 2D map information.
*/
void LevelMap::setMap(std::vector<std::vector<Block>> map)
{
this->map = map;
}
/**
* Return the map information.
* @return map: it is a matrix of Blocks which represent the 2D map information.
*/
std::vector<std::vector<Block>> LevelMap::getMap() {
return map;
}
/**
* Return the selected positioned node pointer reference.
* @return block: it is a block pointer related to a selected position.
*/
Block* LevelMap::getNode(int row, int col) {
return &map[row][col];
}
/**
* Set which floor this map represent.
* @param floor: it indicate which floor plan for the building this map is represent.
*/
void LevelMap::setFloor(int level){
floor = level;
}
/**
* Return the floor level this map represent.
* @return floor: it indicate which floor plan for the building this map is represent.
*/
int LevelMap::getFloor(){
return floor;
}
/**
* add the entrance node to the floor plan map.
* @param entrance: it indicate a pointer of which node is the entrance node in map.
*/
void LevelMap::addEntrance(Block* entrance){
entrances.push_back(entrance);
}
/**
* add the exit node to the floor plan map.
* @param exit: it indicate a pointer of which node is the exit node in map.
*/
void LevelMap::addExit(Block* exit){
exits.push_back(exit);
}
/**
* set the start point node to the 2D map.
* @param startPoint: it indicate a pointer of which node is the start point node in map.
*/
void LevelMap::setStartPoint(Block* startPoint)
{
this->startPoint = startPoint;
}
/**
* set the target point node to the 2D map.
* @param targetPoint: it indicate a pointer of which node is the target point node in map.
*/
void LevelMap::setTargetPoint(Block* targetPoint)
{
this->targetPoint = targetPoint;
}
/**
* set the start point node to the 2D map based on its row and column.
* @param row: it indicate which row the start point is in map.
* @param col: it indicate which column the start point is in map.
*/
void LevelMap::setStartPoint(int row, int col)
{
startPoint = &map[row][col];
}
/**
* set the target point node to the 2D map based on its row and column.
* @param row: it indicate which row the target point is in map.
* @param col: it indicate which column the target point is in map.
*/
void LevelMap::setTargetPoint(int row, int col)
{
targetPoint = &map[row][col];
}
/**
* get the start point node to the 2D map.
* @return startPoint: it indicate a pointer of which node is the start point node in map.
*/
Block* LevelMap::getStartPoint()
{
return startPoint;
}
/**
* get the target point node to the 2D map.
* @return target: it indicate a pointer of which node is the target point node in map.
*/
Block* LevelMap::getTargetPoint()
{
return targetPoint;
}
/**
* find the node pointer reference on the 2D map based on its row and column.
* @param row: it indicate which row the node is in map.
* @param col: it indicate which column the node is in map.
* @return block: it is the pointer reference of selected node.
*/
Block* LevelMap::findBlockInMap(int row, int col)
{
return &map[row][col];
}
/**
* find the walls information on the map.
* @return walls: it is a list of walls location on map.
*/
std::vector<std::pair<int, int>> LevelMap::getWallsInfo() {
std::vector<std::pair<int, int>> walls;
for(int i = 0; i < map.size(); i++) {
for(int j = 0; j < map[i].size(); j++) {
Block node = map[i][j];
if(node.getType() == 5) {
std::pair<int, int> wall(i, j);
walls.push_back(wall);
}
}
}
return walls;
}
/**
* It reset the map's blocks settings after run the algorithm.
*/
void LevelMap::resetMapBlocks() {
for(int row = 0; row < 20; row++) {
for(int col = 0; col < 52; col++) {
Block* currNode = &map[row][col];
currNode->setInQueue(false);
currNode->setMinDistance(10000);
currNode->setWeight(1);
currNode->setPrevBlock(nullptr);
currNode->setVisit(false);
}
}
}