Update: CC - Before Render - Moorcow (080g209iov.js) 420 bytes modified
parent
2bcec8d627
commit
138a1bd95c
169
080g209iov.js
169
080g209iov.js
|
@ -14,7 +14,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
this.santa = this.entityLoaded.santa;
|
this.santa = this.entityLoaded.santa;
|
||||||
this.renderer = this.entityLoaded.renderer;
|
this.renderer = this.entityLoaded.renderer;
|
||||||
this.raycaster = this.entityLoaded.raycaster;
|
this.raycaster = this.entityLoaded.raycaster;
|
||||||
this.canister = this.entityLoaded.canister;
|
this.kanister = this.entityLoaded.kanister;
|
||||||
this.scene = this.entityLoaded.scene;
|
this.scene = this.entityLoaded.scene;
|
||||||
this.leftLight = this.entityLoaded.leftLight;
|
this.leftLight = this.entityLoaded.leftLight;
|
||||||
this.rightLight = this.entityLoaded.rightLight;
|
this.rightLight = this.entityLoaded.rightLight;
|
||||||
|
@ -42,8 +42,9 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
*/
|
*/
|
||||||
this.totalTime = 0;
|
this.totalTime = 0;
|
||||||
this.spawnTime = 0;
|
this.spawnTime = 0;
|
||||||
this.canisterTime = 0;
|
this.kanisterTime = 0;
|
||||||
this.canisterLife = 16344;
|
this.kanisterLife = 16344;
|
||||||
|
this.fuelFinished = false;
|
||||||
|
|
||||||
this.enemies = [];
|
this.enemies = [];
|
||||||
|
|
||||||
|
@ -184,6 +185,62 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
this.enemies.push(enemy);
|
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.explode = function(mesh) {
|
||||||
|
|
||||||
this.enemies.map(
|
this.enemies.map(
|
||||||
|
@ -192,53 +249,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
console.log('exploding enemy');
|
console.log('exploding enemy');
|
||||||
enemy.exploding = true;
|
enemy.exploding = true;
|
||||||
|
|
||||||
var sound = GameLib.Utils.GetRandomIntInclusive(1,3);
|
this.explodeMesh(mesh);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.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.burn = function(mesh) {
|
||||||
|
|
||||||
this.enemies.map(
|
this.enemies.map(
|
||||||
|
@ -392,23 +408,34 @@ this.scene.meshes.map(
|
||||||
|
|
||||||
if (this.mouseIsDown) {
|
if (this.mouseIsDown) {
|
||||||
|
|
||||||
this.fog.color.r += 0.01;
|
this.kanisterTime += data.delta;
|
||||||
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.kanisterTime > this.kanisterLife) {
|
||||||
if (this.renderer.clearColor.r > 0.6) {
|
this.fuelFinished = true;
|
||||||
this.renderer.clearColor.r = 0.6;
|
}
|
||||||
}
|
|
||||||
this.renderer.updateInstance('clearColor');
|
|
||||||
|
|
||||||
this.throwerLight.intensity += 0.05;
|
if (!this.fuelFinished) {
|
||||||
if (this.throwerLight.intensity > 2) {
|
/**
|
||||||
this.throwerLight.intensity = 2;
|
* Light up the scene
|
||||||
}
|
*/
|
||||||
this.throwerLight.updateInstance('instensity');
|
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.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);
|
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
|
||||||
intersects.map(
|
intersects.map(
|
||||||
|
@ -416,6 +443,11 @@ if (this.mouseIsDown) {
|
||||||
|
|
||||||
var mesh = intersect.mesh;
|
var mesh = intersect.mesh;
|
||||||
|
|
||||||
|
if (mesh.name.indexOf('Kanister') !== -1) {
|
||||||
|
this.explodeKanister();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mesh.name.indexOf('Tree - Medium') !== -1 || //tree medium
|
mesh.name.indexOf('Tree - Medium') !== -1 || //tree medium
|
||||||
mesh.name.indexOf('Hamburger') !== -1 || //burger
|
mesh.name.indexOf('Hamburger') !== -1 || //burger
|
||||||
|
@ -509,6 +541,11 @@ if (this.spawnTime > this.nextSpawnTime) {
|
||||||
this.spawnEnemy();
|
this.spawnEnemy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.kanisterTime > (this.kanisterLife / 2)) {
|
||||||
|
this.kanister.visible = true;
|
||||||
|
this.kanister.updateInstance('visible');
|
||||||
|
}
|
||||||
|
|
||||||
this.enemies = this.enemies.reduce(
|
this.enemies = this.enemies.reduce(
|
||||||
function(result, enemy) {
|
function(result, enemy) {
|
||||||
|
|
||||||
|
@ -519,8 +556,6 @@ this.enemies = this.enemies.reduce(
|
||||||
*/
|
*/
|
||||||
if (GameLib.Utils.UndefinedOrNull(enemy.waiting)) {
|
if (GameLib.Utils.UndefinedOrNull(enemy.waiting)) {
|
||||||
enemy.waiting = true;
|
enemy.waiting = true;
|
||||||
enemy.mesh.visible = false;
|
|
||||||
enemy.mesh.updateInstance('visible');
|
|
||||||
result.push(enemy);
|
result.push(enemy);
|
||||||
} else {
|
} else {
|
||||||
this.kill(enemy);
|
this.kill(enemy);
|
||||||
|
|
Loading…
Reference in New Issue