1 | // |
---|
2 | // TowerDefenseEnemy.cc |
---|
3 | // Orxonox |
---|
4 | // |
---|
5 | // Created by Jonas Erb on 22.10.14. |
---|
6 | |
---|
7 | /** |
---|
8 | @brief |
---|
9 | See TowerDefenseReadme.txt for Information. |
---|
10 | |
---|
11 | @ingroup TowerDefense |
---|
12 | */ |
---|
13 | #include "TowerDefenseEnemy.h" |
---|
14 | |
---|
15 | #include "core/CoreIncludes.h" |
---|
16 | //#include "core/XMLPort.h" |
---|
17 | |
---|
18 | namespace orxonox |
---|
19 | { |
---|
20 | RegisterClass(TowerDefenseEnemy); |
---|
21 | |
---|
22 | /** |
---|
23 | @brief |
---|
24 | Constructor. Registers and initializes the object. |
---|
25 | */ |
---|
26 | TowerDefenseEnemy::TowerDefenseEnemy(Context* context) : SpaceShip(context) |
---|
27 | { |
---|
28 | RegisterObject(TowerDefenseEnemy); |
---|
29 | |
---|
30 | this->setCollisionType(WorldEntity::Dynamic); |
---|
31 | |
---|
32 | } |
---|
33 | |
---|
34 | void TowerDefenseEnemy::addWaypoint(TDCoordinate* coord) |
---|
35 | { |
---|
36 | this->Waypointsvector_.push_back(coord); |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | void TowerDefenseEnemy::tick(float dt) |
---|
41 | { |
---|
42 | SUPER(TowerDefenseEnemy, tick, dt); |
---|
43 | |
---|
44 | //ArtificialController* controller = (ArtificialController*)this->getController(); |
---|
45 | Vector3 ship = this->getRVWorldPosition(); |
---|
46 | Vector3* endpoint = new Vector3(500, 700, 150); |
---|
47 | |
---|
48 | float distance = ship.distance(*endpoint); |
---|
49 | |
---|
50 | //orxout() << "distance" << distance << endl; |
---|
51 | if(distance <50){ |
---|
52 | orxout() << "ENEMY KILLED!!!!" << endl; |
---|
53 | this->destroy(); } |
---|
54 | } |
---|
55 | |
---|
56 | /* |
---|
57 | void TowerDefenseEnemy::popWaypoint() |
---|
58 | { |
---|
59 | if(Waypointsvector_.size()>0) |
---|
60 | Waypointsvector_.pop_back(); |
---|
61 | } |
---|
62 | |
---|
63 | TDCoordinate TowerDefenseEnemy::peekWaypoint() |
---|
64 | { |
---|
65 | if(Waypointsvector_.size()<=0){ |
---|
66 | TDCoordinate* coord = TDCoordinate(-1,-1); |
---|
67 | return coord; |
---|
68 | }else{ |
---|
69 | return Waypointsvector_.at(Waypointsvector_.size()-1); |
---|
70 | |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | } |
---|
75 | */ |
---|
76 | |
---|
77 | } |
---|