Update: CC - Before Render - Moorcow (to6trvr3fj.js) 609 bytes modified

beta.r3js.org
-=yb4f310 2017-11-16 13:42:20 +01:00
parent 4678c5c4a9
commit 48a2edd832
1 changed files with 63 additions and 36 deletions

View File

@ -18,6 +18,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.smokeParticleEngine = this.entityLoaded.smokeParticleEngine; this.smokeParticleEngine = this.entityLoaded.smokeParticleEngine;
this.fireParticleEngine = this.entityLoaded.fireParticleEngine; this.fireParticleEngine = this.entityLoaded.fireParticleEngine;
this.burningTreeParticleEngine = this.entityLoaded.burningTreeParticleEngine; this.burningTreeParticleEngine = this.entityLoaded.burningTreeParticleEngine;
this.explodeParticleEngine = this.entityLoaded.explodeParticleEngine;
this.toBlack = new THREE.Color(0.05, 0.05, 0.05); this.toBlack = new THREE.Color(0.05, 0.05, 0.05);
this.toRed = new THREE.Color(0.02, 0, 0); this.toRed = new THREE.Color(0.02, 0, 0);
@ -193,17 +194,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
name = 'Audio - Blast 3'; name = 'Audio - Blast 3';
} }
//if (this.blastSubscription) {
// GameLib.Event.Emit(
// GameLib.Event.PLAY_AUDIO,
// {
// name : 'Audio - Ho ho ho'
// }
// );
// this.blastSubscription.remove();
// this.blastSubscription = null;
//}
this.blastSubscription = GameLib.Event.Subscribe( this.blastSubscription = GameLib.Event.Subscribe(
GameLib.Event.AUDIO_ENDED, GameLib.Event.AUDIO_ENDED,
function(data) { function(data) {
@ -234,12 +224,11 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
} }
); );
var explodeParticleEngine = this.explodeParticleEngine.clone();
// var particleEngine = this.smokeParticleEngine.clone(); explodeParticleEngine.position = mesh.position.clone();
// particleEngine.position = mesh.position.clone(); explodeParticleEngine.updateInstance('position');
// particleEngine.updateInstance('position'); explodeParticleEngine.enabled = true;
// particleEngine.enabled = true; enemy.explodeParticleEngine = explodeParticleEngine;
// enemy.smokeParticleEngine = particleEngine;
} }
}.bind(this) }.bind(this)
); );
@ -279,6 +268,41 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
} }
this.kill = function(enemy) {
/**
* We only remove the things we cloned
*/
GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT,
{
component : enemy.mesh.materials[0]
}
);
GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT,
{
component : enemy.mesh
}
);
if (enemy.smokeParticleEngine) {
enemy.smokeParticleEngine.remove();
enemy.smokeParticleEngine = null;
}
if (enemy.fireParticleEngine) {
enemy.fireParticleEngine.remove();
enemy.fireParticleEngine = null;
}
if (enemy.explodeParticleEngine) {
enemy.explodeParticleEngine.remove();
enemy.explodeParticleEngine = null;
}
};
this.burnTree = function(mesh) { this.burnTree = function(mesh) {
if (mesh.burning) { if (mesh.burning) {
@ -442,6 +466,24 @@ if (this.spawnTime > this.nextSpawnTime) {
this.enemies = this.enemies.reduce( this.enemies = this.enemies.reduce(
function(result, enemy) { function(result, enemy) {
if (enemy.exploding === true) {
/**
* We need to wait one render cycle for the smoke explode particle engine
* and then kill the enemy
*/
if (GameLib.Utils.UndefinedOrNull(enemy.waiting)) {
enemy.waiting = true;
enemy.mesh.visible = false;
enemy.mesh.updateInstance('visible');
result.push(enemy);
} else {
this.kill(enemy);
}
return result;
}
enemy.mesh.position.add(enemy.velocity); enemy.mesh.position.add(enemy.velocity);
enemy.mesh.updateInstancePosition(); enemy.mesh.updateInstancePosition();
@ -454,25 +496,9 @@ this.enemies = this.enemies.reduce(
/** /**
* We only remove the things we cloned * We only remove the things we cloned
*/ */
GameLib.Event.Emit( this.kill(enemy);
GameLib.Event.REMOVE_COMPONENT,
{
component : enemy.mesh.materials[0]
}
);
GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT,
{
component : enemy.mesh
}
);
if (enemy.burning) { return result;
enemy.smokeParticleEngine.remove();
enemy.fireParticleEngine.remove();
enemy.burning = false;
}
} else { } else {
@ -496,8 +522,9 @@ this.enemies = this.enemies.reduce(
} }
result.push(enemy); result.push(enemy);
return result;
} }
return result;
}, },
[] []
); );