-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.cpp
43 lines (36 loc) · 933 Bytes
/
Token.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
42
43
//
// Created by Kevin Gaffney on 4/12/18.
//
#include "Token.h"
#include <iostream>
using namespace Enki;
using namespace std;
Token::Token() {
dryFrictionCoefficient = 10;
setColor(Color(0, 0, 1));
setCylindric(3, 3, 10);
}
void Token::collisionEvent(PhysicalObject *o) {
PhysicalObject::collisionEvent(o);
auto bot = dynamic_cast<Bot*>(o);
if (bot) {
if (!initialBotCollided) {
initialBotCollided = bot;
if (bot->getShouldShareToken()) {
status = shared;
setColor(Color(0, 1, 0));
} else {
status = kept;
setColor(Color(1, 0, 0));
}
} else if (bot != initialBotCollided) {
// TODO: handle collision by different bot
}
}
}
TokenStatus Token::getStatus() {
return status;
}
Bot *Token::getInitialBotCollided() {
return initialBotCollided;
}