-
Notifications
You must be signed in to change notification settings - Fork 5
/
monster.cpp
41 lines (36 loc) · 1.24 KB
/
monster.cpp
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
#include "monster.h"
#include"map.h"
#include "tower.h"
Monster::Monster(int type, Map *thismap) {
if(type == 1) {
intHitPoint = 10;
monsterMoveSpeed = 1;
doubleEarn = 2;
}
else if(type == 2) {
intHitPoint = 20;
monsterMoveSpeed = 0.5;
doubleEarn = 5;
}
else {
intHitPoint = 50;
monsterMoveSpeed = 0.1;
doubleEarn = 15;
}
map = thismap;
locationOrder = 0;
doubleMoveDistance = 0;
}
double Monster::move() {
locationOrder += monsterMoveSpeed;
doubleMoveDistance += monsterMoveSpeed;
monsterLocation[0] = (map->roadLocation[(int)(locationOrder)][0]) * ((int)(locationOrder) + 1 - locationOrder) + (map->roadLocation[1 + (int)(locationOrder)][0]) * (locationOrder - (int)(locationOrder));
monsterLocation[1] = (map->roadLocation[(int)(locationOrder)][1]) * ((int)(locationOrder) + 1 - locationOrder) + (map->roadLocation[1 + (int)(locationOrder)][1]) * (locationOrder - (int)(locationOrder));
return (double(map->roadCellAmount) - locationOrder);
}
bool Monster::hitHome() {
return (locationOrder >= map->roadCellAmount);
}
double Monster::moneyobtain() {
return doubleEarn * doubleMoveDistance;
}