Update: CC - Before Render - Moorcow (a2ow5l92js.js) 616 bytes modified

beta.r3js.org
-=yb4f310 2017-11-24 14:42:52 +01:00
parent 7e5b09f50d
commit 0baaa0249b
1 changed files with 110 additions and 93 deletions

View File

@ -48,10 +48,40 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.totalTime = 0;
this.kanisters = 4;
this.kanisterTime = 0;
//this.kanisterTime = 0;
this.kanisterLife = 16.344;
this.kanisterLeakTime = 0.001;
this.kanisterSpawnInterval = 50;
this.kanisterSpawnScore = 50;
this.setNextKanisterSpawnScore = function() {
this.kanisterSpawnScore += 50;
if (this.kanisterSpawnScore > 150) {
this.kanisterSpawnScore += 50;
}
if (this.kanisterSpawnScore > 300) {
this.kanisterSpawnScore += 50;
}
if (this.kanisterSpawnScore > 500) {
this.kanisterSpawnScore += 50;
}
if (this.kanisterSpawnScore > 600) {
this.kanisterSpawnScore += 50;
}
console.log('next kanister spawn score: ' + this.kanisterSpawnScore);
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'nextKanisterSpawnScoreUpdate',
kanisterSpawnScore : this.kanisterSpawnScore
}
);
};
this.fuelFinished = false;
@ -134,6 +164,10 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
);
};
this.spawnKanister = function() {
console.log('spawning kanister');
};
this.spawnEnemy = function() {
this.enemiesSpawned++;
@ -349,10 +383,14 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
function(enemy) {
if (enemy.mesh === mesh && !enemy.exploding) {
enemy.exploding = true;
console.log('exploding enemy');
this.score += enemy.score;
console.log('score : ' + this.score);
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
@ -361,8 +399,10 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
}
);
enemy.exploding = true;
if (this.score > this.kanisterSpawnScore) {
this.setNextKanisterSpawnScore();
this.spawnKanister();
}
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
@ -379,8 +419,9 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
};
this.explodeKanister = function() {
this.kanisterTime = 0;
this.fuelFinished = false;
this.kanisters += 1;
// this.kanisterTime = 0;
// this.fuelFinished = false;
this.explodeMesh(this.kanister);
};
@ -575,45 +616,22 @@ this.scene.meshes.map(
}.bind(this)
);
if (this.mouseIsDown) {
if (this.mouseIsDown)
{
this.kanisterTime += data.delta;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
used : this.kanisterTime / this.kanisterLife,
event : 'fuelUsed',
percentage : Math.round((this.kanisterTime / this.kanisterLife) * 100) + '%'
}
);
if (this.kanisterTime > this.kanisterLife) {
this.fuelFinished = true;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'fuelFinished'
}
);
this.renderer.clearColor.r += 0.01;
if (this.renderer.clearColor.r > 0.45) {
this.renderer.clearColor.r = 0.45;
}
this.renderer.updateInstance('clearColor');
if (!this.fuelFinished) {
this.renderer.clearColor.r += 0.01;
if (this.renderer.clearColor.r > 0.45) {
this.renderer.clearColor.r = 0.45;
}
this.renderer.updateInstance('clearColor');
this.throwerLight.intensity += 0.05;
if (this.throwerLight.intensity > 2) {
this.throwerLight.intensity = 2;
}
this.throwerLight.updateInstance('intensity');
this.throwerLight.intensity += 0.05;
if (this.throwerLight.intensity > 2) {
this.throwerLight.intensity = 2;
}
this.throwerLight.updateInstance('intensity');
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
intersects.map(
@ -689,7 +707,10 @@ if (this.mouseIsDown) {
}.bind(this)
);
} else {
}
else
{
this.kanisterTime += (data.delta * this.kanisterLeakTime);
this.renderer.clearColor.r -= 0.01;
if (this.renderer.clearColor.r < this.minimumRendererRed) {
@ -704,34 +725,58 @@ if (this.mouseIsDown) {
this.throwerLight.updateInstance('intensity');
}
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
used : this.kanisterTime / this.kanisterLife,
event : 'fuelUsed',
percentage : Math.round((this.kanisterTime / this.kanisterLife) * 100) + '%'
}
);
if (this.kanisterTime > this.kanisterLife) {
this.kanisterTime = 0;
this.kanisters -= 1;
if (kanisters < 0) {
GameLib.Event.Emit(
GameLib.Event.GAME_OVER,
{
game : this
}
);
}
}
if (this.enemySpawnTime > this.enemySpawnInterval && this.running) {
this.enemySpawnTime = 0;
this.spawnEnemy();
}
//
if (this.kanister.explodeParticleEngine) {
if (GameLib.Utils.UndefinedOrNull(this.kanister.waiting)) {
this.kanister.waiting = true;
} else {
this.kanister.explodeParticleEngine.remove();
this.kanister.explodeParticleEngine = null;
delete this.kanister.waiting;
}
}
if (this.kanisterTime > (this.kanisterLife / 2)) {
this.kanister.visible = true;
this.kanister.updateInstance('visible');
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'kanisterAppeared'
}
);
}
// if (this.kanister.explodeParticleEngine) {
// if (GameLib.Utils.UndefinedOrNull(this.kanister.waiting)) {
// this.kanister.waiting = true;
// } else {
// this.kanister.explodeParticleEngine.remove();
// this.kanister.explodeParticleEngine = null;
// delete this.kanister.waiting;
// }
// }
//
// if (this.kanisterTime > (this.kanisterLife / 2)) {
//
// this.kanister.visible = true;
// this.kanister.updateInstance('visible');
//
// GameLib.Event.Emit(
// GameLib.Event.GAME_DATA,
// {
// event : 'kanisterAppeared'
// }
// );
// }
this.enemies = this.enemies.reduce(
function(result, enemy) {
@ -769,47 +814,19 @@ this.enemies = this.enemies.reduce(
}
);
if (!enemy.burning && !enemy.exploding) {
this.lives--;
console.log('lives left: ' + this.lives);
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
livesLeft : this.lives,
event : 'lifeLost'
}
);
if (this.lives < 0) {
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'gameOver',
gameData : this
}
);
GameLib.Event.Emit(GameLib.Event.GAME_OVER);
}
}
/**
* We only remove the things we cloned
*/
this.kill(enemy);
return result;
} else {
if (enemy.burning) {
enemy.burnTime += data.delta;
if (enemy.burnTime > enemy.burnLife) {
enemy.mesh.smokeParticleEngine.remove();
enemy.mesh.fireParticleEngine.remove();