-
Notifications
You must be signed in to change notification settings - Fork 0
/
Effect.js
53 lines (44 loc) · 1.24 KB
/
Effect.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
RFall.Effect = function () {
this.isCoolDown = false
this.coolDownTime = null
}
RFall.Effect.prototype.startEffect = function () {
// Overwrite me!
}
RFall.Effect.prototype.stopEffect = function () {
// Overwrite me!
}
RFall.Effect.prototype.getIsCoolDown = function () {
return this.isCoolDown
}
RFall.Effect.prototype.setIsCoolDown = function ( b ) {
if ( b == true ) {
this.isCoolDown = true
// Turn off the cool down later
setTimeout( $.proxy( this.setIsCoolDown, this, false ), this.coolDownTime )
}
if ( b == false )
this.isCoolDown = false
}
RFall.SlowTime = function () {
this.isCoolDown = false
this.coolDownTime = 9000 // milliseconds
this.slowMoFactor = 2
this.slowMoTime = 3000 // milliseconds
}
RFall.SlowTime.prototype = new RFall.Effect()
RFall.SlowTime.prototype.startEffect = function () {
if (!this.isCoolDown){
this.setIsCoolDown(true)
// Change the game speed (and later back to normal)
RFall.setGameSpeed( RFall.gameSpeed * this.slowMoFactor )
setTimeout( $.proxy(
RFall.effectsManager.stop,
RFall.effectsManager,
"slowTime"),
this.slowMoTime )
}
}
RFall.SlowTime.prototype.stopEffect = function () {
RFall.setGameSpeed(RFall.gameSpeed0)
}