This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
trap_tile.js
67 lines (60 loc) · 1.52 KB
/
trap_tile.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
59
60
61
62
63
64
65
66
67
function TrapTile() {
this.passible = true;
this.frost_ = new Frost();
this.melting = false;
this.world = null;
this.time = Math.random();
this.frozen = false;
}
TrapTile.prototype.tick = function(delta) {
this.time += delta;
if (this.frost_.finished && this.frost_.freezing) {
this.frost_.stopFreezing();
}
if (this.frost_.finishedMelting && this.fire_.melting) {
this.fire_.stopMelting();
}
if (!this.frozen) {
var something = Utils.getAnimationStep(this.time, C.animStep, 15) + 1;
if (something > 8) {
something = 16 - something;
}
this.node.src = "gfx/spike" + something + ".png";
} else {
this.node.src = "gfx/spike-frozen.png";
}
this.frost_.tick(delta, this.x, this.y, this.world);
}
TrapTile.prototype.draw = function(container, x, y, world) {
Tile.draw(this, container, x, y, "spike1.png");
this.world = world
}
TrapTile.prototype.actorAction = function(actor) {
if (this.frozen) {
return;
}
var name = Utils.getObjectClass(actor);
if (name != "Scientist" && name != "Magician") return;
actor.die();
}
TrapTile.prototype.freeze = function() {
if (this.frozen) {
return;
}
this.passible = true;
this.frozen = true;
this.node.src = "gfx/spike-frozen.png";
this.frost_.startFreezing();
}
TrapTile.prototype.fire = function() {
this.melt();
}
TrapTile.prototype.melt = function() {
if (!this.frozen) {
return true;
}
this.frost_.startMelting();
this.frozen = false;
this.passible = true;
this.node.src = "gfx/spike1.png";
}