2018-02-13 08:48:32 +01:00
|
|
|
if (!this.entityLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-18 12:34:02 +01:00
|
|
|
if (this.entityLoaded.gameOver) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-13 08:48:32 +01:00
|
|
|
if (!this.initialized) {
|
2018-02-18 12:34:02 +01:00
|
|
|
|
2018-02-13 08:48:32 +01:00
|
|
|
this.totalTime = 0;
|
2018-02-18 12:34:02 +01:00
|
|
|
|
2018-02-18 18:25:07 +01:00
|
|
|
/**
|
|
|
|
* Waiting means - this block is on top of some blocks which are busy disappearing
|
|
|
|
* - so wait for the fall to complete
|
|
|
|
*/
|
2018-02-13 08:48:32 +01:00
|
|
|
this.waiting = false;
|
2018-02-18 12:34:02 +01:00
|
|
|
|
2018-02-18 18:25:07 +01:00
|
|
|
this.animation = this.entityLoaded.animation;
|
|
|
|
|
|
|
|
this.translationSpeed = this.animation.translationSpeed;
|
|
|
|
|
2018-02-18 12:36:48 +01:00
|
|
|
this.drop = false;
|
2018-02-18 12:59:30 +01:00
|
|
|
|
2018-02-13 08:48:32 +01:00
|
|
|
this.moveQueue = [];
|
|
|
|
|
|
|
|
this.initialized = true;
|
|
|
|
}
|
|
|
|
|
2018-02-18 12:36:48 +01:00
|
|
|
var moved = true;
|
|
|
|
var fall = false;
|
2018-02-13 08:48:32 +01:00
|
|
|
|
|
|
|
if (this.waiting) {
|
|
|
|
fall = true;
|
|
|
|
} else {
|
|
|
|
this.totalTime += data.delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.drop) {
|
|
|
|
|
2018-02-18 18:25:07 +01:00
|
|
|
this.animation.translationSpeed = 70;
|
|
|
|
|
2018-02-13 08:48:32 +01:00
|
|
|
fall = true;
|
|
|
|
|
|
|
|
if (this.moveQueue && this.moveQueue.length > 0) {
|
|
|
|
|
|
|
|
var tryMove = function () {
|
|
|
|
if (this.moveQueue.length > 0) {
|
|
|
|
|
|
|
|
var move = this.moveQueue[0];
|
|
|
|
|
2018-02-18 12:34:02 +01:00
|
|
|
if (this.moveBlock(null, move, 1, true)) {
|
2018-02-13 08:48:32 +01:00
|
|
|
this.moveQueue.splice(0, 1);
|
|
|
|
tryMove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.bind(this);
|
|
|
|
|
|
|
|
tryMove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.totalTime > this.entityLoaded.speed) {
|
|
|
|
this.totalTime = 0;
|
|
|
|
fall = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fall) {
|
2018-02-18 12:34:02 +01:00
|
|
|
moved = this.moveBlock(null, {down: true}, 1, true);
|
2018-02-13 08:48:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (moved === null) {
|
|
|
|
this.waiting = true;
|
|
|
|
} else {
|
|
|
|
this.waiting = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moved === false) {
|
2018-02-18 12:34:02 +01:00
|
|
|
|
2018-02-13 08:48:32 +01:00
|
|
|
this.drop = false;
|
|
|
|
|
|
|
|
this.moveQueue = [];
|
2018-02-18 18:25:07 +01:00
|
|
|
|
2018-02-18 12:59:30 +01:00
|
|
|
this.stopBlock();
|
2018-02-18 18:25:07 +01:00
|
|
|
|
|
|
|
this.animation.translationSpeed = this.translationSpeed;
|
2018-02-13 08:48:32 +01:00
|
|
|
}
|
|
|
|
|
2018-02-18 12:07:12 +01:00
|
|
|
//@ sourceURL=beforeRender.js
|