Update: CC - Before Render - Moorcow (orfy8cilgg.js) 772 bytes modified
parent
b945f5c714
commit
d147ab304c
256
orfy8cilgg.js
256
orfy8cilgg.js
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
if (!this.entityLoaded) {
|
if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -60,15 +61,17 @@ 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(
|
||||||
this.toRed = new THREE.Color(0.02, 0, 0);
|
data.delta * 3,
|
||||||
|
data.delta * 3,
|
||||||
|
data.delta * 3
|
||||||
|
);
|
||||||
|
|
||||||
this.bull.instance.visible = false;
|
this.toRed = new THREE.Color(
|
||||||
this.star.instance.visible = false;
|
data.delta * 1.2,
|
||||||
this.burger.instance.visible = false;
|
0,
|
||||||
this.parcel.instance.visible = false;
|
0
|
||||||
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);
|
||||||
|
@ -159,7 +162,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
function(mesh) {
|
function(mesh) {
|
||||||
if (mesh.burningTreeParticleEngine) {
|
if (mesh.burningTreeParticleEngine) {
|
||||||
mesh.burning = false;
|
mesh.burning = false;
|
||||||
mesh.life = 1.2;
|
mesh.burnLife = 1;
|
||||||
mesh.burningTreeParticleEngine.remove();
|
mesh.burningTreeParticleEngine.remove();
|
||||||
mesh.burningTreeParticleEngine = null;
|
mesh.burningTreeParticleEngine = null;
|
||||||
}
|
}
|
||||||
|
@ -278,10 +281,13 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.materials = [material];
|
mesh.materials = [material];
|
||||||
|
|
||||||
mesh.updateInstance('materials');
|
mesh.updateInstance('materials');
|
||||||
|
|
||||||
mesh.instance.visible = true;
|
mesh.visible = true;
|
||||||
|
mesh.updateInstance('visible');
|
||||||
|
|
||||||
|
mesh.burnLife = 1;
|
||||||
|
mesh.explodeLife = 1;
|
||||||
|
|
||||||
var velocity = null;
|
var velocity = null;
|
||||||
|
|
||||||
|
@ -306,6 +312,11 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
mesh : mesh
|
mesh : mesh
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link the enemy to the mesh
|
||||||
|
*/
|
||||||
|
mesh.enemy = enemy;
|
||||||
|
|
||||||
var distance = 100;
|
var distance = 100;
|
||||||
var angledistance = distance * Math.sin(Math.PI / 4);
|
var angledistance = distance * Math.sin(Math.PI / 4);
|
||||||
|
|
||||||
|
@ -402,40 +413,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
this.spawnEnemy(true);
|
this.spawnEnemy(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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';
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
mesh.explodeParticleEngine = explodeParticleEngine;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
this.drawScore = function(enemy) {
|
this.drawScore = function(enemy) {
|
||||||
|
|
||||||
this.scoreMesh.materials[0].opacity = 1.0;
|
this.scoreMesh.materials[0].opacity = 1.0;
|
||||||
|
@ -463,30 +440,60 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
var explodeParticleEngine = this.explodeParticleEngine.clone();
|
||||||
|
explodeParticleEngine.position = mesh.position.clone();
|
||||||
|
explodeParticleEngine.updateInstance('position');
|
||||||
|
explodeParticleEngine.enabled = true;
|
||||||
|
mesh.explodeParticleEngine = explodeParticleEngine;
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.PLAY_AUDIO,
|
||||||
|
{
|
||||||
|
name : name
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
this.explode = function(mesh) {
|
this.explode = function(mesh) {
|
||||||
|
|
||||||
this.enemies.map(
|
mesh.enemy.exploding = true;
|
||||||
function(enemy) {
|
|
||||||
if (enemy.mesh === mesh && !enemy.exploding) {
|
|
||||||
|
|
||||||
enemy.exploding = true;
|
if (mesh.enemy.isKanister) {
|
||||||
|
|
||||||
|
console.log('exploding kanister');
|
||||||
|
|
||||||
if (enemy.isKanister) {
|
|
||||||
this.kanisters += 1;
|
this.kanisters += 1;
|
||||||
|
|
||||||
if (this.kanisters > 9) {
|
if (this.kanisters > 9) {
|
||||||
this.kanisters = 9;
|
this.kanisters = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('exploding kanister');
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
console.log('exploding enemy');
|
console.log('exploding enemy');
|
||||||
|
|
||||||
this.score += enemy.score;
|
this.score += mesh.enemy.score;
|
||||||
|
|
||||||
this.drawScore(enemy);
|
this.drawScore(mesh.enemy);
|
||||||
|
|
||||||
console.log('score : ' + this.score);
|
console.log('score : ' + this.score);
|
||||||
|
|
||||||
|
@ -505,31 +512,25 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.GAME_DATA,
|
GameLib.Event.GAME_DATA,
|
||||||
{
|
{
|
||||||
enemy : enemy,
|
enemy : mesh.enemy,
|
||||||
event : 'enemyExploded'
|
event : 'enemyExploded'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.explodeMesh(mesh);
|
this.explodeMesh(mesh);
|
||||||
}
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.burn = function(mesh) {
|
this.burn = function(mesh) {
|
||||||
|
|
||||||
this.enemies.map(
|
|
||||||
function(enemy) {
|
|
||||||
if (enemy.mesh === mesh && !enemy.burning) {
|
|
||||||
|
|
||||||
console.log('burning enemy ' + mesh.name);
|
console.log('burning enemy ' + mesh.name);
|
||||||
enemy.burning = true;
|
|
||||||
|
mesh.enemy.burning = true;
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.GAME_DATA,
|
GameLib.Event.GAME_DATA,
|
||||||
{
|
{
|
||||||
enemy : enemy,
|
enemy : mesh.enemy,
|
||||||
event : 'enemyBurned'
|
event : 'enemyBurned'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -540,26 +541,22 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
smokeParticleEngine.enabled = true;
|
smokeParticleEngine.enabled = true;
|
||||||
mesh.smokeParticleEngine = smokeParticleEngine;
|
mesh.smokeParticleEngine = smokeParticleEngine;
|
||||||
|
|
||||||
|
var fireParticleEngine = this.fireParticleEngine.clone();
|
||||||
|
fireParticleEngine.position = mesh.position.clone();
|
||||||
|
fireParticleEngine.updateInstance('position');
|
||||||
|
fireParticleEngine.enabled = true;
|
||||||
|
mesh.fireParticleEngine = fireParticleEngine;
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.PLAY_AUDIO,
|
GameLib.Event.PLAY_AUDIO,
|
||||||
{
|
{
|
||||||
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)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.kill = function(enemy) {
|
this.kill = function(enemy) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We only remove the things we cloned
|
* We only remove the things we cloned
|
||||||
*/
|
*/
|
||||||
|
@ -644,7 +641,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
this.fog.updateInstance('density');
|
this.fog.updateInstance('density');
|
||||||
|
|
||||||
if (mesh.position.x < 0) {
|
if (mesh.position.x < 0) {
|
||||||
this.leftLight.intensity += 0.07;
|
this.leftLight.intensity += data.delta * 2.5;
|
||||||
|
|
||||||
if (this.leftLight.intensity >= 1) {
|
if (this.leftLight.intensity >= 1) {
|
||||||
this.leftLight.intensity = 1;
|
this.leftLight.intensity = 1;
|
||||||
|
@ -653,7 +650,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
this.leftLight.updateInstance('intensity');
|
this.leftLight.updateInstance('intensity');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.rightLight.intensity += 0.07;
|
this.rightLight.intensity += data.delta * 2.5;
|
||||||
|
|
||||||
if (this.rightLight.intensity >= 1) {
|
if (this.rightLight.intensity >= 1) {
|
||||||
this.rightLight.intensity = 1;
|
this.rightLight.intensity = 1;
|
||||||
|
@ -663,19 +660,19 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.PLAY_AUDIO,
|
|
||||||
{
|
|
||||||
name : 'Audio - Burning'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
var burningTreeParticleEngine = this.burningTreeParticleEngine.clone();
|
var burningTreeParticleEngine = this.burningTreeParticleEngine.clone();
|
||||||
burningTreeParticleEngine.position = mesh.position.clone();
|
burningTreeParticleEngine.position = mesh.position.clone();
|
||||||
burningTreeParticleEngine.position.y += mesh.dimensions.y + 5;
|
burningTreeParticleEngine.position.y += mesh.dimensions.y + 5;
|
||||||
burningTreeParticleEngine.updateInstance('position');
|
burningTreeParticleEngine.updateInstance('position');
|
||||||
burningTreeParticleEngine.enabled = true;
|
burningTreeParticleEngine.enabled = true;
|
||||||
mesh.burningTreeParticleEngine = burningTreeParticleEngine;
|
mesh.burningTreeParticleEngine = burningTreeParticleEngine;
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.PLAY_AUDIO,
|
||||||
|
{
|
||||||
|
name : 'Audio - Burning'
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -759,43 +756,64 @@ if (this.mouseIsDown)
|
||||||
|
|
||||||
if (mesh.materials[0].name.indexOf('Trees') === -1) {
|
if (mesh.materials[0].name.indexOf('Trees') === -1) {
|
||||||
|
|
||||||
mesh.instance.material.color.sub(this.toBlack);
|
if (!mesh.enemy.burning) {
|
||||||
|
|
||||||
mesh.materials[0].color.r = mesh.instance.material.color.r;
|
mesh.burnLife -= data.delta * 2.5;
|
||||||
mesh.materials[0].color.g = mesh.instance.material.color.g;
|
|
||||||
mesh.materials[0].color.b = mesh.instance.material.color.b;
|
|
||||||
|
|
||||||
mesh.materials[0].color.instance = mesh.instance.material.color;
|
|
||||||
|
|
||||||
if (mesh.instance.material.color.r <= 0) {
|
|
||||||
|
|
||||||
|
if (mesh.burnLife < 0) {
|
||||||
|
mesh.burnLife = 0;
|
||||||
this.burn(mesh);
|
this.burn(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
if (mesh.instance.material.emissive) {
|
mesh.instance.material.color.setRGB(
|
||||||
mesh.instance.material.emissive.add(this.toRed);
|
mesh.burnLife,
|
||||||
mesh.instance.material.emissive.add(this.toRed);
|
mesh.burnLife,
|
||||||
|
mesh.burnLife
|
||||||
|
);
|
||||||
|
|
||||||
if (mesh.instance.material.emissive.r >= 0.8) {
|
} else {
|
||||||
|
|
||||||
|
if (!mesh.enemy.exploding) {
|
||||||
|
mesh.explodeLife -= data.delta * 2.5;
|
||||||
|
if (mesh.explodeLife < 0) {
|
||||||
|
mesh.explodeLife = 0;
|
||||||
this.explode(mesh);
|
this.explode(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mesh.instance.material.emissive) {
|
||||||
|
mesh.instance.material.emissive.setRGB(
|
||||||
|
1 - mesh.explodeLife,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This happens to trees
|
* This happens to trees
|
||||||
*/
|
*/
|
||||||
if (GameLib.Utils.UndefinedOrNull(mesh.life)) {
|
if (GameLib.Utils.UndefinedOrNull(mesh.burnLife)) {
|
||||||
mesh.life = 1.2;
|
mesh.burnLife = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.life -= 0.2;
|
if (!mesh.burning) {
|
||||||
|
|
||||||
|
mesh.burnLife -= data.delta * 2;
|
||||||
|
|
||||||
|
if (mesh.burnLife <= 0) {
|
||||||
|
|
||||||
if (mesh.life <= 0) {
|
|
||||||
this.burnTree(mesh);
|
this.burnTree(mesh);
|
||||||
|
|
||||||
if (mesh.instance.material.emissive) {
|
if (mesh.instance.material.emissive) {
|
||||||
mesh.instance.material.emissive.add(this.toRed);
|
mesh.instance.material.emissive.setRGB(
|
||||||
mesh.instance.material.emissive.add(this.toRed);
|
1 - mesh.burnLife,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,13 +827,13 @@ else
|
||||||
{
|
{
|
||||||
this.kanisterTime += (data.delta * this.kanisterLeakTime);
|
this.kanisterTime += (data.delta * this.kanisterLeakTime);
|
||||||
|
|
||||||
this.renderer.clearColor.r -= 0.01;
|
this.renderer.clearColor.r -= data.delta;
|
||||||
if (this.renderer.clearColor.r < this.minimumRendererRed) {
|
if (this.renderer.clearColor.r < this.minimumRendererRed) {
|
||||||
this.renderer.clearColor.r = this.minimumRendererRed;
|
this.renderer.clearColor.r = this.minimumRendererRed;
|
||||||
}
|
}
|
||||||
this.renderer.updateInstance('clearColor');
|
this.renderer.updateInstance('clearColor');
|
||||||
|
|
||||||
this.throwerLight.intensity -= 0.05;
|
this.throwerLight.intensity -= data.delta * 3;
|
||||||
if (this.throwerLight.intensity < 0) {
|
if (this.throwerLight.intensity < 0) {
|
||||||
this.throwerLight.intensity = 0;
|
this.throwerLight.intensity = 0;
|
||||||
}
|
}
|
||||||
|
@ -861,30 +879,6 @@ if (this.enemySpawnTime > this.enemySpawnInterval && this.running) {
|
||||||
this.enemySpawnTime = 0;
|
this.enemySpawnTime = 0;
|
||||||
this.spawnEnemy();
|
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'
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.enemies = this.enemies.reduce(
|
this.enemies = this.enemies.reduce(
|
||||||
function(result, enemy) {
|
function(result, enemy) {
|
||||||
|
@ -904,10 +898,12 @@ this.enemies = this.enemies.reduce(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
enemy.mesh.position.add(enemy.velocity);
|
enemy.mesh.position.x = enemy.velocity.x * data.delta;
|
||||||
|
enemy.mesh.position.y = enemy.velocity.y * data.delta;
|
||||||
|
enemy.mesh.position.z = enemy.velocity.z * data.delta;
|
||||||
enemy.mesh.updateInstance('position');
|
enemy.mesh.updateInstance('position');
|
||||||
|
|
||||||
enemy.mesh.quaternion.angle += enemy.rotation.angle;
|
enemy.mesh.quaternion.angle += enemy.rotation.angle * data.delta;
|
||||||
enemy.mesh.updateInstance('quaternion');
|
enemy.mesh.updateInstance('quaternion');
|
||||||
|
|
||||||
enemy.lifeTime += data.delta;
|
enemy.lifeTime += data.delta;
|
||||||
|
@ -946,7 +942,7 @@ this.enemies = this.enemies.reduce(
|
||||||
enemy.mesh.fireParticleEngine.updateInstance('position');
|
enemy.mesh.fireParticleEngine.updateInstance('position');
|
||||||
}
|
}
|
||||||
|
|
||||||
enemy.mesh.materials[0].opacity -= 0.005;
|
enemy.mesh.materials[0].opacity -= data.delta;
|
||||||
enemy.mesh.materials[0].updateInstance('opacity');
|
enemy.mesh.materials[0].updateInstance('opacity');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue