Update: CC - Before Render - Moorcow (orfy8cilgg.js) 772 bytes modified
parent
b945f5c714
commit
d147ab304c
344
orfy8cilgg.js
344
orfy8cilgg.js
|
@ -1,3 +1,4 @@
|
|||
|
||||
if (!this.entityLoaded) {
|
||||
return;
|
||||
}
|
||||
|
@ -60,15 +61,17 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
|
||||
this.minimumRendererRed = 0.1;
|
||||
|
||||
this.toBlack = new THREE.Color(0.05, 0.05, 0.05);
|
||||
this.toRed = new THREE.Color(0.02, 0, 0);
|
||||
this.toBlack = new THREE.Color(
|
||||
data.delta * 3,
|
||||
data.delta * 3,
|
||||
data.delta * 3
|
||||
);
|
||||
|
||||
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.toRed = new THREE.Color(
|
||||
data.delta * 1.2,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
this.treesBurning = 0;
|
||||
this.treesBurningToStart = GameLib.Utils.GetRandomIntInclusive(1, 3);
|
||||
|
@ -159,7 +162,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
function(mesh) {
|
||||
if (mesh.burningTreeParticleEngine) {
|
||||
mesh.burning = false;
|
||||
mesh.life = 1.2;
|
||||
mesh.burnLife = 1;
|
||||
mesh.burningTreeParticleEngine.remove();
|
||||
mesh.burningTreeParticleEngine = null;
|
||||
}
|
||||
|
@ -278,10 +281,13 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
}
|
||||
|
||||
mesh.materials = [material];
|
||||
|
||||
mesh.updateInstance('materials');
|
||||
|
||||
mesh.instance.visible = true;
|
||||
mesh.visible = true;
|
||||
mesh.updateInstance('visible');
|
||||
|
||||
mesh.burnLife = 1;
|
||||
mesh.explodeLife = 1;
|
||||
|
||||
var velocity = null;
|
||||
|
||||
|
@ -306,6 +312,11 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
mesh : mesh
|
||||
};
|
||||
|
||||
/**
|
||||
* Link the enemy to the mesh
|
||||
*/
|
||||
mesh.enemy = enemy;
|
||||
|
||||
var distance = 100;
|
||||
var angledistance = distance * Math.sin(Math.PI / 4);
|
||||
|
||||
|
@ -402,6 +413,32 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
this.spawnEnemy(true);
|
||||
};
|
||||
|
||||
this.drawScore = function(enemy) {
|
||||
|
||||
this.scoreMesh.materials[0].opacity = 1.0;
|
||||
this.scoreMesh.materials[0].updateInstance('opacity');
|
||||
|
||||
this.scoreMesh.position = enemy.mesh.position.clone();
|
||||
this.scoreMesh.updateInstance('position');
|
||||
|
||||
this.scoreMesh.instance.quaternion.copy(this.camera.instance.quaternion);
|
||||
|
||||
var context = this.scoreCanvas.instance.getContext('2d');
|
||||
|
||||
context.textBaseline = "middle";
|
||||
|
||||
context.clearRect(0,0,this.scoreCanvas.width, this.scoreCanvas.height);
|
||||
|
||||
/**
|
||||
* Write text
|
||||
*/
|
||||
context.fillStyle = '#e0b899';
|
||||
context.font = '230pt BkBold';
|
||||
context.fillText(enemy.score, 0, this.scoreCanvas.height/2);
|
||||
|
||||
this.scoreTexture.instance.needsUpdate = true;
|
||||
|
||||
}.bind(this)
|
||||
|
||||
this.explodeMesh = function(mesh) {
|
||||
|
||||
|
@ -421,6 +458,12 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
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,
|
||||
{
|
||||
|
@ -428,138 +471,92 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
}
|
||||
);
|
||||
|
||||
var explodeParticleEngine = this.explodeParticleEngine.clone();
|
||||
explodeParticleEngine.position = mesh.position.clone();
|
||||
explodeParticleEngine.updateInstance('position');
|
||||
explodeParticleEngine.enabled = true;
|
||||
mesh.explodeParticleEngine = explodeParticleEngine;
|
||||
|
||||
};
|
||||
|
||||
this.drawScore = function(enemy) {
|
||||
|
||||
this.scoreMesh.materials[0].opacity = 1.0;
|
||||
this.scoreMesh.materials[0].updateInstance('opacity');
|
||||
|
||||
this.scoreMesh.position = enemy.mesh.position.clone();
|
||||
this.scoreMesh.updateInstance('position');
|
||||
|
||||
this.scoreMesh.instance.quaternion.copy(this.camera.instance.quaternion);
|
||||
|
||||
var context = this.scoreCanvas.instance.getContext('2d');
|
||||
|
||||
context.textBaseline = "middle";
|
||||
|
||||
context.clearRect(0,0,this.scoreCanvas.width, this.scoreCanvas.height);
|
||||
|
||||
/**
|
||||
* Write text
|
||||
*/
|
||||
context.fillStyle = '#e0b899';
|
||||
context.font = '230pt BkBold';
|
||||
context.fillText(enemy.score, 0, this.scoreCanvas.height/2);
|
||||
|
||||
this.scoreTexture.instance.needsUpdate = true;
|
||||
|
||||
}.bind(this)
|
||||
|
||||
|
||||
this.explode = function(mesh) {
|
||||
|
||||
this.enemies.map(
|
||||
function(enemy) {
|
||||
if (enemy.mesh === mesh && !enemy.exploding) {
|
||||
mesh.enemy.exploding = true;
|
||||
|
||||
enemy.exploding = true;
|
||||
if (mesh.enemy.isKanister) {
|
||||
|
||||
if (enemy.isKanister) {
|
||||
this.kanisters += 1;
|
||||
console.log('exploding kanister');
|
||||
|
||||
if (this.kanisters > 9) {
|
||||
this.kanisters = 9;
|
||||
}
|
||||
this.kanisters += 1;
|
||||
|
||||
console.log('exploding kanister');
|
||||
} else {
|
||||
if (this.kanisters > 9) {
|
||||
this.kanisters = 9;
|
||||
}
|
||||
|
||||
console.log('exploding enemy');
|
||||
} else {
|
||||
|
||||
this.score += enemy.score;
|
||||
console.log('exploding enemy');
|
||||
|
||||
this.drawScore(enemy);
|
||||
this.score += mesh.enemy.score;
|
||||
|
||||
console.log('score : ' + this.score);
|
||||
this.drawScore(mesh.enemy);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'scoreUpdate',
|
||||
score : this.score
|
||||
}
|
||||
);
|
||||
console.log('score : ' + this.score);
|
||||
|
||||
if (this.score > this.kanisterSpawnScore) {
|
||||
this.spawnKanister();
|
||||
}
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
enemy : enemy,
|
||||
event : 'enemyExploded'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.explodeMesh(mesh);
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'scoreUpdate',
|
||||
score : this.score
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
);
|
||||
|
||||
if (this.score > this.kanisterSpawnScore) {
|
||||
this.spawnKanister();
|
||||
}
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
enemy : mesh.enemy,
|
||||
event : 'enemyExploded'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.explodeMesh(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.GAME_DATA,
|
||||
{
|
||||
enemy : enemy,
|
||||
event : 'enemyBurned'
|
||||
}
|
||||
);
|
||||
|
||||
var smokeParticleEngine = this.smokeParticleEngine.clone();
|
||||
smokeParticleEngine.position = mesh.position.clone();
|
||||
smokeParticleEngine.updateInstance('position');
|
||||
smokeParticleEngine.enabled = true;
|
||||
mesh.smokeParticleEngine = smokeParticleEngine;
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.PLAY_AUDIO,
|
||||
{
|
||||
name : 'Audio - Burning'
|
||||
}
|
||||
);
|
||||
|
||||
var fireParticleEngine = this.fireParticleEngine.clone();
|
||||
fireParticleEngine.position = mesh.position.clone();
|
||||
fireParticleEngine.updateInstance('position');
|
||||
fireParticleEngine.enabled = true;
|
||||
mesh.fireParticleEngine = fireParticleEngine;
|
||||
}
|
||||
}.bind(this)
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
enemy : mesh.enemy,
|
||||
event : 'enemyBurned'
|
||||
}
|
||||
);
|
||||
|
||||
var smokeParticleEngine = this.smokeParticleEngine.clone();
|
||||
smokeParticleEngine.position = mesh.position.clone();
|
||||
smokeParticleEngine.updateInstance('position');
|
||||
smokeParticleEngine.enabled = true;
|
||||
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.PLAY_AUDIO,
|
||||
{
|
||||
name : 'Audio - Burning'
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
this.kill = function(enemy) {
|
||||
|
||||
/**
|
||||
* We only remove the things we cloned
|
||||
*/
|
||||
|
@ -644,7 +641,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
this.fog.updateInstance('density');
|
||||
|
||||
if (mesh.position.x < 0) {
|
||||
this.leftLight.intensity += 0.07;
|
||||
this.leftLight.intensity += data.delta * 2.5;
|
||||
|
||||
if (this.leftLight.intensity >= 1) {
|
||||
this.leftLight.intensity = 1;
|
||||
|
@ -653,7 +650,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
|||
this.leftLight.updateInstance('intensity');
|
||||
|
||||
} else {
|
||||
this.rightLight.intensity += 0.07;
|
||||
this.rightLight.intensity += data.delta * 2.5;
|
||||
|
||||
if (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();
|
||||
burningTreeParticleEngine.position = mesh.position.clone();
|
||||
burningTreeParticleEngine.position.y += mesh.dimensions.y + 5;
|
||||
burningTreeParticleEngine.updateInstance('position');
|
||||
burningTreeParticleEngine.enabled = true;
|
||||
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) {
|
||||
|
||||
mesh.instance.material.color.sub(this.toBlack);
|
||||
if (!mesh.enemy.burning) {
|
||||
|
||||
mesh.materials[0].color.r = mesh.instance.material.color.r;
|
||||
mesh.materials[0].color.g = mesh.instance.material.color.g;
|
||||
mesh.materials[0].color.b = mesh.instance.material.color.b;
|
||||
mesh.burnLife -= data.delta * 2.5;
|
||||
|
||||
mesh.materials[0].color.instance = mesh.instance.material.color;
|
||||
if (mesh.burnLife < 0) {
|
||||
mesh.burnLife = 0;
|
||||
this.burn(mesh);
|
||||
}
|
||||
|
||||
if (mesh.instance.material.color.r <= 0) {
|
||||
mesh.instance.material.color.setRGB(
|
||||
mesh.burnLife,
|
||||
mesh.burnLife,
|
||||
mesh.burnLife
|
||||
);
|
||||
|
||||
this.burn(mesh);
|
||||
} else {
|
||||
|
||||
if (mesh.instance.material.emissive) {
|
||||
mesh.instance.material.emissive.add(this.toRed);
|
||||
mesh.instance.material.emissive.add(this.toRed);
|
||||
|
||||
if (mesh.instance.material.emissive.r >= 0.8) {
|
||||
if (!mesh.enemy.exploding) {
|
||||
mesh.explodeLife -= data.delta * 2.5;
|
||||
if (mesh.explodeLife < 0) {
|
||||
mesh.explodeLife = 0;
|
||||
this.explode(mesh);
|
||||
}
|
||||
|
||||
if (mesh.instance.material.emissive) {
|
||||
mesh.instance.material.emissive.setRGB(
|
||||
1 - mesh.explodeLife,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* This happens to trees
|
||||
*/
|
||||
if (GameLib.Utils.UndefinedOrNull(mesh.life)) {
|
||||
mesh.life = 1.2;
|
||||
if (GameLib.Utils.UndefinedOrNull(mesh.burnLife)) {
|
||||
mesh.burnLife = 1;
|
||||
}
|
||||
|
||||
mesh.life -= 0.2;
|
||||
if (!mesh.burning) {
|
||||
|
||||
if (mesh.life <= 0) {
|
||||
this.burnTree(mesh);
|
||||
mesh.burnLife -= data.delta * 2;
|
||||
|
||||
if (mesh.instance.material.emissive) {
|
||||
mesh.instance.material.emissive.add(this.toRed);
|
||||
mesh.instance.material.emissive.add(this.toRed);
|
||||
if (mesh.burnLife <= 0) {
|
||||
|
||||
this.burnTree(mesh);
|
||||
|
||||
if (mesh.instance.material.emissive) {
|
||||
mesh.instance.material.emissive.setRGB(
|
||||
1 - mesh.burnLife,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -809,13 +827,13 @@ else
|
|||
{
|
||||
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) {
|
||||
this.renderer.clearColor.r = this.minimumRendererRed;
|
||||
}
|
||||
this.renderer.updateInstance('clearColor');
|
||||
|
||||
this.throwerLight.intensity -= 0.05;
|
||||
this.throwerLight.intensity -= data.delta * 3;
|
||||
if (this.throwerLight.intensity < 0) {
|
||||
this.throwerLight.intensity = 0;
|
||||
}
|
||||
|
@ -861,30 +879,6 @@ if (this.enemySpawnTime > this.enemySpawnInterval && this.running) {
|
|||
this.enemySpawnTime = 0;
|
||||
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(
|
||||
function(result, enemy) {
|
||||
|
@ -904,10 +898,12 @@ this.enemies = this.enemies.reduce(
|
|||
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.quaternion.angle += enemy.rotation.angle;
|
||||
enemy.mesh.quaternion.angle += enemy.rotation.angle * data.delta;
|
||||
enemy.mesh.updateInstance('quaternion');
|
||||
|
||||
enemy.lifeTime += data.delta;
|
||||
|
@ -946,7 +942,7 @@ this.enemies = this.enemies.reduce(
|
|||
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');
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue