Update: CC - Before Render - Moorcow (zo950m57cc.js) 8652 bytes modified

beta.r3js.org
-=yb4f310 2017-11-26 22:38:46 +01:00
parent 5b84693ba7
commit 34526b795c
1 changed files with 859 additions and 876 deletions

View File

@ -1,8 +1,8 @@
if (!this.entityLoaded) { if (!this.entityLoaded) {
return; return;
} }
if (GameLib.Utils.UndefinedOrNull(this.initialized)) { if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.initialized = true; this.initialized = true;
@ -61,15 +61,8 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.minimumRendererRed = 0.1; this.minimumRendererRed = 0.1;
this.toBlack = new THREE.Color(0.05, 0.05, 0.05); this.toBlack = new THREE.Color(data.delta, data.delta, data.delta);
this.toRed = new THREE.Color(0.02, 0, 0); this.toRed = new THREE.Color(data.delta, 0, 0);
this.bull.instance.visible = false;
this.star.instance.visible = false;
this.burger.instance.visible = false;
this.parcel.instance.visible = false;
this.santa.instance.visible = false;
this.kanister.instance.visible = false;
this.treesBurning = 0; this.treesBurning = 0;
this.treesBurningToStart = GameLib.Utils.GetRandomIntInclusive(1, 3); this.treesBurningToStart = GameLib.Utils.GetRandomIntInclusive(1, 3);
@ -238,9 +231,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
null null
); );
if (meshType == 1) { return mesh;
}
} }
this.spawnEnemy = function(kanister) { this.spawnEnemy = function(kanister) {
@ -251,6 +242,14 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
if (kanister) { if (kanister) {
meshType = 6; meshType = 6;
} else { } else {
var mesh = this.getNextMesh(meshType);
if (!mesh) {
console.warn('re-attempt to spawn');
return this.spawnEnemy(false);
}
this.enemiesSpawned++; this.enemiesSpawned++;
this.setLevelProperties(); this.setLevelProperties();
} }
@ -259,51 +258,33 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
var speed = 1; var speed = 1;
var score = 10; var score = 0;
var material = null; var mesh = this.getNextMesh(meshType);
var mesh = null;
if (meshType === 1) { if (meshType === 1) {
mesh = this.bull.clone(); score = 10;
material = this.bull.materials[0].clone();
speed = 0.3; speed = 0.3;
} else if (meshType === 2) { } else if (meshType === 2) {
mesh = this.star.clone();
score = 20; score = 20;
material = this.star.materials[0].clone();
speed = 0.4; speed = 0.4;
} else if (meshType === 3) { } else if (meshType === 3) {
mesh = this.burger.clone();
score = 50; score = 50;
material = this.burger.materials[0].clone();
speed = 0.45; speed = 0.45;
} else if (meshType === 4) { } else if (meshType === 4) {
mesh = this.parcel.clone();
score = 75; score = 75;
material = this.parcel.materials[0].clone();
speed = 0.5; speed = 0.5;
} else if (meshType === 5) { } else if (meshType === 5) {
mesh = this.santa.clone();
score = 100; score = 100;
material = this.santa.materials[0].clone();
speed = 0.6; speed = 0.6;
} else if (meshType === 6) { } else if (meshType === 6) {
mesh = this.kanister.clone(); score = 0;
score = 100;
material = this.kanister.materials[0].clone();
speed = 0.7; speed = 0.7;
} }
else { else {
console.log('unknown mesh type : ' + meshType); console.log('unknown mesh type : ' + meshType);
} }
mesh.materials = [material];
mesh.updateInstance();
mesh.instance.visible = true;
var velocity = null; var velocity = null;
var axis = new GameLib.API.Vector3( var axis = new GameLib.API.Vector3(
@ -449,11 +430,12 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
} }
); );
var explodeParticleEngine = this.explodeParticleEngine.clone(); mesh.explodeParticleEngine.position.x = mesh.position.x;
explodeParticleEngine.position = mesh.position.clone(); mesh.explodeParticleEngine.position.y = mesh.position.y;
mesh.explodeParticleEngine.position.z = mesh.position.z;
explodeParticleEngine.updateInstance('position'); explodeParticleEngine.updateInstance('position');
explodeParticleEngine.enabled = true;
mesh.explodeParticleEngine = explodeParticleEngine; mesh.explodeParticleEngine.enabled = true;
}; };
@ -555,11 +537,17 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
} }
); );
var smokeParticleEngine = this.smokeParticleEngine.clone(); mesh.smokeParticleEngine.position.x = mesh.position.x;
smokeParticleEngine.position = mesh.position.clone(); mesh.smokeParticleEngine.position.y = mesh.position.y;
smokeParticleEngine.updateInstance('position'); mesh.smokeParticleEngine.position.z = mesh.position.z;
smokeParticleEngine.enabled = true; mesh.smokeParticleEngine.updateInstance('position');
mesh.smokeParticleEngine = smokeParticleEngine; mesh.smokeParticleEngine.enabled = true;
mesh.fireParticleEngine.position.x = mesh.position.x;
mesh.fireParticleEngine.position.y = mesh.position.y;
mesh.fireParticleEngine.position.z = mesh.position.z;
mesh.fireParticleEngine.updateInstance('position');
mesh.fireParticleEngine.enabled = true;
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.PLAY_AUDIO, GameLib.Event.PLAY_AUDIO,
@ -567,12 +555,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
name : 'Audio - Burning' name : 'Audio - Burning'
} }
); );
var fireParticleEngine = this.fireParticleEngine.clone();
fireParticleEngine.position = mesh.position.clone();
fireParticleEngine.updateInstance('position');
fireParticleEngine.enabled = true;
mesh.fireParticleEngine = fireParticleEngine;
} }
}.bind(this) }.bind(this)
); );
@ -582,7 +564,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.kill = function(enemy) { this.kill = function(enemy) {
if (!enemy.isKanister) {
this.meshes[enemy.meshType].map( this.meshes[enemy.meshType].map(
function(object) { function(object) {
if (object.mesh === enemy.mesh) { if (object.mesh === enemy.mesh) {
@ -592,12 +573,12 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
} }
} }
) )
}
/** /**
* We only remove the things we cloned * We only remove the things we cloned
*/ */
/* /*
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.REMOVE_COMPONENT, GameLib.Event.REMOVE_COMPONENT,
{ {
component : enemy.mesh.materials[0] component : enemy.mesh.materials[0]
@ -610,7 +591,7 @@ GameLib.Event.Emit(
component : enemy.mesh component : enemy.mesh
} }
); );
*/ */
/** /**
* Also dispose of the THREE.js objects * Also dispose of the THREE.js objects
*/ */
@ -618,18 +599,15 @@ GameLib.Event.Emit(
//enemy.mesh.instance.material.dispose(); //enemy.mesh.instance.material.dispose();
if (enemy.mesh.smokeParticleEngine) { if (enemy.mesh.smokeParticleEngine) {
enemy.mesh.smokeParticleEngine.remove(); enemy.mesh.smokeParticleEngine.enabled = false;
enemy.mesh.smokeParticleEngine = null;
} }
if (enemy.mesh.fireParticleEngine) { if (enemy.mesh.fireParticleEngine) {
enemy.mesh.fireParticleEngine.remove(); enemy.mesh.fireParticleEngine.enabled = false;
enemy.mesh.fireParticleEngine = null;
} }
if (enemy.mesh.explodeParticleEngine) { if (enemy.mesh.explodeParticleEngine) {
enemy.mesh.explodeParticleEngine.remove(); enemy.mesh.explodeParticleEngine.enabled = false;
enemy.mesh.explodeParticleEngine = null;
} }
}; };
@ -719,18 +697,18 @@ GameLib.Event.Emit(
game : this game : this
} }
); );
} }
this.totalTime += data.delta; this.totalTime += data.delta;
this.enemySpawnTime += data.delta; this.enemySpawnTime += data.delta;
this.scoreMesh.materials[0].opacity -= data.delta * 0.5; this.scoreMesh.materials[0].opacity -= data.delta * 0.5;
if (this.scoreMesh.materials[0].opacity < 0) { if (this.scoreMesh.materials[0].opacity < 0) {
this.scoreMesh.materials[0].opacity = 0; this.scoreMesh.materials[0].opacity = 0;
} }
this.scoreMesh.materials[0].updateInstance('opacity'); this.scoreMesh.materials[0].updateInstance('opacity');
this.scene.meshes.map( this.scene.meshes.map(
function(mesh) { function(mesh) {
if (mesh.instance.material instanceof Array) { if (mesh.instance.material instanceof Array) {
mesh.instance.material.map( mesh.instance.material.map(
@ -746,10 +724,10 @@ this.scene.meshes.map(
} }
} }
}.bind(this) }.bind(this)
); );
if (this.mouseIsDown) if (this.mouseIsDown)
{ {
this.kanisterTime += data.delta; this.kanisterTime += data.delta;
this.renderer.clearColor.r += 0.01; this.renderer.clearColor.r += 0.01;
@ -838,9 +816,9 @@ if (this.mouseIsDown)
}.bind(this) }.bind(this)
); );
} }
else else
{ {
this.kanisterTime += (data.delta * this.kanisterLeakTime); this.kanisterTime += (data.delta * this.kanisterLeakTime);
this.renderer.clearColor.r -= 0.01; this.renderer.clearColor.r -= 0.01;
@ -854,11 +832,11 @@ else
this.throwerLight.intensity = 0; this.throwerLight.intensity = 0;
} }
this.throwerLight.updateInstance('intensity'); this.throwerLight.updateInstance('intensity');
} }
var used = this.kanisterTime / this.kanisterLife; var used = this.kanisterTime / this.kanisterLife;
GameLib.Event.Emit( GameLib.Event.Emit(
GameLib.Event.GAME_DATA, GameLib.Event.GAME_DATA,
{ {
event : 'fuelUsed', event : 'fuelUsed',
@ -866,9 +844,9 @@ GameLib.Event.Emit(
percentage : Math.round(used * 100) + '%', percentage : Math.round(used * 100) + '%',
kanisters : this.kanisters kanisters : this.kanisters
} }
); );
if (this.kanisterTime > this.kanisterLife) { if (this.kanisterTime > this.kanisterLife) {
this.kanisterTime = 0; this.kanisterTime = 0;
this.kanisters -= 1; this.kanisters -= 1;
@ -889,12 +867,12 @@ if (this.kanisterTime > this.kanisterLife) {
} }
); );
} }
} }
if (this.enemySpawnTime > this.enemySpawnInterval && this.running) { if (this.enemySpawnTime > this.enemySpawnInterval && this.running) {
this.enemySpawnTime = 0; this.enemySpawnTime = 0;
this.spawnEnemy(); this.spawnEnemy();
} }
// //
// if (this.kanister.explodeParticleEngine) { // if (this.kanister.explodeParticleEngine) {
@ -920,7 +898,7 @@ if (this.enemySpawnTime > this.enemySpawnInterval && this.running) {
// ); // );
// } // }
this.enemies = this.enemies.reduce( this.enemies = this.enemies.reduce(
function(result, enemy) { function(result, enemy) {
if (enemy.exploding === true) { if (enemy.exploding === true) {
@ -970,17 +948,22 @@ this.enemies = this.enemies.reduce(
enemy.burnTime += data.delta; enemy.burnTime += data.delta;
if (enemy.burnTime > enemy.burnLife) { if (enemy.burnTime > enemy.burnLife) {
enemy.mesh.smokeParticleEngine.remove(); enemy.mesh.smokeParticleEngine.enabled = false;
enemy.mesh.fireParticleEngine.remove(); enemy.mesh.fireParticleEngine.enabled = false;
enemy.lifeTime = enemy.life + 1; enemy.lifeTime = enemy.life + 1;
} else { } else {
enemy.mesh.smokeParticleEngine.position = enemy.mesh.position.clone(); enemy.mesh.smokeParticleEngine.position.x = enemy.mesh.position.x;
enemy.mesh.smokeParticleEngine.position.y = enemy.mesh.position.y;
enemy.mesh.smokeParticleEngine.position.z = enemy.mesh.position.z;
enemy.mesh.smokeParticleEngine.updateInstance('position'); enemy.mesh.smokeParticleEngine.updateInstance('position');
enemy.mesh.fireParticleEngine.position = enemy.mesh.position.clone();
enemy.mesh.fireParticleEngine.position.x = enemy.mesh.position.x;
enemy.mesh.fireParticleEngine.position.y = enemy.mesh.position.y;
enemy.mesh.fireParticleEngine.position.z = enemy.mesh.position.z;
enemy.mesh.fireParticleEngine.updateInstance('position'); enemy.mesh.fireParticleEngine.updateInstance('position');
} }
enemy.mesh.materials[0].opacity -= 0.005; enemy.mesh.materials[0].opacity -= 0.05 * data.delta;
enemy.mesh.materials[0].updateInstance('opacity'); enemy.mesh.materials[0].updateInstance('opacity');
} }
@ -991,7 +974,7 @@ this.enemies = this.enemies.reduce(
}.bind(this), }.bind(this),
[] []
); );
return null; return null;
//# sourceURL=beforeRender.js //# sourceURL=beforeRender.js