Update: CC - Before Render - Moorcow (080g209iov.js) 420 bytes modified

beta.r3js.org
-=yb4f310 2017-11-18 08:19:02 +01:00
parent 2bcec8d627
commit 138a1bd95c
1 changed files with 102 additions and 67 deletions

View File

@ -14,7 +14,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.santa = this.entityLoaded.santa;
this.renderer = this.entityLoaded.renderer;
this.raycaster = this.entityLoaded.raycaster;
this.canister = this.entityLoaded.canister;
this.kanister = this.entityLoaded.kanister;
this.scene = this.entityLoaded.scene;
this.leftLight = this.entityLoaded.leftLight;
this.rightLight = this.entityLoaded.rightLight;
@ -42,8 +42,9 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
*/
this.totalTime = 0;
this.spawnTime = 0;
this.canisterTime = 0;
this.canisterLife = 16344;
this.kanisterTime = 0;
this.kanisterLife = 16344;
this.fuelFinished = false;
this.enemies = [];
@ -184,6 +185,62 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.enemies.push(enemy);
}
this.explodeMesh = function(mesh) {
mesh.visible = false;
mesh.updateInstance('visible');
var sound = GameLib.Utils.GetRandomIntInclusive(1,3);
var name = 'Audio - Blast 1';
if (sound === 2) {
name = 'Audio - Blast 2';
}
if (sound === 3) {
name = 'Audio - Blast 3';
}
this.blastSubscription = GameLib.Event.Subscribe(
GameLib.Event.AUDIO_ENDED,
function(data) {
if (data.audio.name === name) {
if (this.blastSubscription) {
this.blastSubscription.remove();
this.blastSubscription = null;
GameLib.Event.Emit(
GameLib.Event.PLAY_AUDIO,
{
name : 'Audio - Ho ho ho'
}
);
}
}
}.bind(this)
);
GameLib.Event.Emit(
GameLib.Event.PLAY_AUDIO,
{
name : name
}
);
var explodeParticleEngine = this.explodeParticleEngine.clone();
explodeParticleEngine.position = mesh.position.clone();
explodeParticleEngine.updateInstance('position');
explodeParticleEngine.enabled = true;
enemy.explodeParticleEngine = explodeParticleEngine;
};
this.explode = function(mesh) {
this.enemies.map(
@ -192,53 +249,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
console.log('exploding enemy');
enemy.exploding = true;
var sound = GameLib.Utils.GetRandomIntInclusive(1,3);
var name = 'Audio - Blast 1';
if (sound === 2) {
name = 'Audio - Blast 2';
}
if (sound === 3) {
name = 'Audio - Blast 3';
}
this.blastSubscription = GameLib.Event.Subscribe(
GameLib.Event.AUDIO_ENDED,
function(data) {
if (data.audio.name === name) {
if (this.blastSubscription) {
this.blastSubscription.remove();
this.blastSubscription = null;
GameLib.Event.Emit(
GameLib.Event.PLAY_AUDIO,
{
name : 'Audio - Ho ho ho'
}
);
}
}
}.bind(this)
);
GameLib.Event.Emit(
GameLib.Event.PLAY_AUDIO,
{
name : name
}
);
var explodeParticleEngine = this.explodeParticleEngine.clone();
explodeParticleEngine.position = mesh.position.clone();
explodeParticleEngine.updateInstance('position');
explodeParticleEngine.enabled = true;
enemy.explodeParticleEngine = explodeParticleEngine;
this.explodeMesh(mesh);
}
}.bind(this)
);
@ -246,6 +257,11 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
}
this.explodeKanister = function() {
this.kanisterTime = 0;
this.explodeMesh(this.kanister);
}
this.burn = function(mesh) {
this.enemies.map(
@ -392,23 +408,34 @@ this.scene.meshes.map(
if (this.mouseIsDown) {
this.fog.color.r += 0.01;
if (this.fog.color.r > 0.5) {
this.fog.color.r = 0.5;
}
//this.fog.updateInstance('color');
this.kanisterTime += data.delta;
if (this.kanisterTime > this.kanisterLife) {
this.fuelFinished = true;
}
if (!this.fuelFinished) {
/**
* Light up the scene
*/
this.fog.color.r += 0.01;
if (this.fog.color.r > 0.5) {
this.fog.color.r = 0.5;
}
//this.fog.updateInstance('color');
this.renderer.clearColor.r += 0.01;
if (this.renderer.clearColor.r > 0.6) {
this.renderer.clearColor.r = 0.6;
}
this.renderer.updateInstance('clearColor');
this.renderer.clearColor.r += 0.01;
if (this.renderer.clearColor.r > 0.6) {
this.renderer.clearColor.r = 0.6;
}
this.renderer.updateInstance('clearColor');
this.throwerLight.intensity += 0.05;
if (this.throwerLight.intensity > 2) {
this.throwerLight.intensity = 2;
}
this.throwerLight.updateInstance('instensity');
this.throwerLight.intensity += 0.05;
if (this.throwerLight.intensity > 2) {
this.throwerLight.intensity = 2;
}
this.throwerLight.updateInstance('instensity');
}
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
intersects.map(
@ -416,6 +443,11 @@ if (this.mouseIsDown) {
var mesh = intersect.mesh;
if (mesh.name.indexOf('Kanister') !== -1) {
this.explodeKanister();
return;
}
if (
mesh.name.indexOf('Tree - Medium') !== -1 || //tree medium
mesh.name.indexOf('Hamburger') !== -1 || //burger
@ -509,6 +541,11 @@ if (this.spawnTime > this.nextSpawnTime) {
this.spawnEnemy();
}
if (this.kanisterTime > (this.kanisterLife / 2)) {
this.kanister.visible = true;
this.kanister.updateInstance('visible');
}
this.enemies = this.enemies.reduce(
function(result, enemy) {
@ -519,8 +556,6 @@ this.enemies = this.enemies.reduce(
*/
if (GameLib.Utils.UndefinedOrNull(enemy.waiting)) {
enemy.waiting = true;
enemy.mesh.visible = false;
enemy.mesh.updateInstance('visible');
result.push(enemy);
} else {
this.kill(enemy);