-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacter.cpp
More file actions
57 lines (50 loc) · 1.09 KB
/
Copy pathCharacter.cpp
File metadata and controls
57 lines (50 loc) · 1.09 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
// ---------------------------------------------------------------------------
#pragma hdrstop
#include "Character.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
Character::Character(int x, int y, std::wstring name, Map* map) {
this->x = x;
this->y = y;
this->name = name;
this->map = map->GetMap();
this->cols = map->GetColsCount();
this->rows = map->GetRowsCount();
PathFinder = new PathFinder2D(cols, rows, this->map);
}
Character::~Character() {
delete PathFinder;
}
int Character::GetX() {
return x;
}
int Character::GetY() {
return y;
}
std::wstring Character::GetName()
{
return name;
}
void Character::SetName(std::wstring name)
{
this->name = name;
}
void Character::Move() {
if (vPath.size()>0)
{
int x,y;
x = vPath[vPath.size()-1].x;
y = vPath[vPath.size()-1].y;
SetXY(x,y);
vPath.erase(vPath.end()-1);
}
};
void Character::CalculatePathTo(int x, int y)
{
if (x>0 && x<cols && y>0 && y<rows)
vPath = PathFinder->FindPath(this->x,this->y,x,y);
}
void Character::SetXY(int x, int y) {
this->x = x;
this->y = y;
}