forked from hwauck/statue-puzzle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtower.cc
executable file
·156 lines (125 loc) · 3.23 KB
/
tower.cc
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
#include <string>
#include "tower.h"
#include <cmath>
#include "drawFunctions.h"
Tower::Tower() {
this->name = "Tower";
this->damage = 0;
this->range = 0;
this->attackDelay = 0;
this->type = type;
this->location = location;
this->canAttack = true;
this->colorA = "black";
this->colorB = "white";
this->delayCount = 0;
this->cost = 0;
}
Tower::Tower(std::string name, int damage, int range, int attackDelay, int cost, Type type, Square location, std::string colorA, std::string colorB) {
this->name = name;
this->damage = damage;
this->range = range;
this->attackDelay = attackDelay;
this->type = type;
this->location = location;
this->canAttack = true;
this->colorA = colorA;
this->colorB = colorB;
this->delayCount = 0;
this->cost = cost;
}
std::string Tower::getName() const {
return this->name;
}
int Tower::getDamage() const {
return this->damage;
}
int Tower::getRange() const {
return this->range;
}
int Tower::getAttackDelay() const {
return this->attackDelay;
}
Type Tower::getType() const {
return this->type;
}
Square Tower::getLocation() const {
return this->location;
}
int Tower::getCost() const {
return this->cost;
}
bool Tower::getCanAttack() const {
return this->canAttack;
}
std::string Tower::getColorA() const {
return this->colorA;
}
std::string Tower::getColorB() const {
return this->colorB;
}
int Tower::getDelayCount () const {
return this->delayCount;
}
void Tower::setName(std::string name) {
this->name = name;
}
void Tower::setDamage(int damage) {
this->damage = damage;
}
void Tower::setRange(int range) {
this->range = range;
}
void Tower::setType(Type type) {
this->type = type;
}
void Tower::setAttackDelay(int attackDelay) {
this->attackDelay = attackDelay;
}
void Tower::setLocation(Square location) {
this->location = location;
}
void Tower::setCanAttack(bool canAttack) {
this->canAttack = canAttack;
}
void Tower::setColorA(std::string color) {
this->colorA = color;
}
void Tower::setColorB(std::string color) {
this->colorB = color;
}
void Tower::setDelayCount(int delayCount) {
this->delayCount = delayCount;
}
void Tower::setCost(int cost) {
this->cost = cost;
}
void Tower::attack(Square square) {
double adjustedX = location.get_location().get_x() + 0.0 * SQUARE_SIZE;
double adjustedY = location.get_location().get_y() + 0.0 * SQUARE_SIZE;
Point adjustedLoc = Point(adjustedX,adjustedY);
drawMapTower(SQUARE_SIZE * 0.8, adjustedLoc, "white", colorB);
Point target (square.get_location().get_x() + 0.4, square.get_location().get_y() + 0.4, colorA);
cwin << target;
usleep(100000);
draw();
}
//unused?
void Tower::draw() {
double adjustedX = location.get_location().get_x() + 0.0 * SQUARE_SIZE;
double adjustedY = location.get_location().get_y() + 0.0 * SQUARE_SIZE;
Point adjustedLoc = Point(adjustedX,adjustedY);
drawMapTower(SQUARE_SIZE * 0.8, adjustedLoc, colorA, colorB);
}
bool Tower::inRange(Square occupiedSquare) {
double xDistance = abs (location.get_location().get_x() - occupiedSquare.get_location().get_x());
double yDistance = abs (location.get_location().get_y() - occupiedSquare.get_location().get_y());
double totalDistance = xDistance + yDistance;
if (totalDistance <= range) {
return true;
}
return false;
}
void Tower::countDelay() {
delayCount++;
}