r3-custom-code/o4c478xpx3.js

89 lines
1.5 KiB
JavaScript

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