-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathc-power-up.js
58 lines (51 loc) · 1.4 KB
/
c-power-up.js
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
class PowerUp
{
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Setup
constructor(game)
{
this.game_ = game;
this.wallTimeout = undefined;
this.wall_inactive_for_ = 0;
this.used = false;
}
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Methods
sendMessageWallInactive()
{
if(this.used == false)
{
let message_content = {
player: this.game_.players_local_[0].id_,
duration: 7000
};
this.game_.communicator_.sendMessage('WallInactiveTime', 'Global', message_content);
this.used = true;
}
}
addWallInactiveTime(message)
{
this.game_.ui_handler_.updateWallUsed(message.player);
this.wall_inactive_for_ += message.duration;
this.game_.drawer_.clearBorder();
this.checkTime(message.duration);
}
checkTime(seconds)
{
if(this.wallTimeout == undefined)
{
let that = this;
this.wallTimeout = setTimeout(function(){
that.wall_inactive_for_ -= seconds;
if(that.wall_inactive_for_ > 0)
{
that.wallTimeout = undefined;
that.checkTime(that.wall_inactive_for_);
} else {
that.game_.drawer_.drawBorder();
that.wallTimeout = undefined;
}
}, seconds);
}
}
}