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

@ -61,15 +61,8 @@ 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.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.toBlack = new THREE.Color(data.delta, data.delta, data.delta);
this.toRed = new THREE.Color(data.delta, 0, 0);
this.treesBurning = 0;
this.treesBurningToStart = GameLib.Utils.GetRandomIntInclusive(1, 3);
@ -238,9 +231,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
null
);
if (meshType == 1) {
}
return mesh;
}
this.spawnEnemy = function(kanister) {
@ -251,6 +242,14 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
if (kanister) {
meshType = 6;
} else {
var mesh = this.getNextMesh(meshType);
if (!mesh) {
console.warn('re-attempt to spawn');
return this.spawnEnemy(false);
}
this.enemiesSpawned++;
this.setLevelProperties();
}
@ -259,51 +258,33 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
var speed = 1;
var score = 10;
var score = 0;
var material = null;
var mesh = this.getNextMesh(meshType);
var mesh = null;
if (meshType === 1) {
mesh = this.bull.clone();
material = this.bull.materials[0].clone();
score = 10;
speed = 0.3;
} else if (meshType === 2) {
mesh = this.star.clone();
score = 20;
material = this.star.materials[0].clone();
speed = 0.4;
} else if (meshType === 3) {
mesh = this.burger.clone();
score = 50;
material = this.burger.materials[0].clone();
speed = 0.45;
} else if (meshType === 4) {
mesh = this.parcel.clone();
score = 75;
material = this.parcel.materials[0].clone();
speed = 0.5;
} else if (meshType === 5) {
mesh = this.santa.clone();
score = 100;
material = this.santa.materials[0].clone();
speed = 0.6;
} else if (meshType === 6) {
mesh = this.kanister.clone();
score = 100;
material = this.kanister.materials[0].clone();
score = 0;
speed = 0.7;
}
else {
console.log('unknown mesh type : ' + meshType);
}
mesh.materials = [material];
mesh.updateInstance();
mesh.instance.visible = true;
var velocity = null;
var axis = new GameLib.API.Vector3(
@ -449,11 +430,12 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
}
);
var explodeParticleEngine = this.explodeParticleEngine.clone();
explodeParticleEngine.position = mesh.position.clone();
mesh.explodeParticleEngine.position.x = mesh.position.x;
mesh.explodeParticleEngine.position.y = mesh.position.y;
mesh.explodeParticleEngine.position.z = mesh.position.z;
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();
smokeParticleEngine.position = mesh.position.clone();
smokeParticleEngine.updateInstance('position');
smokeParticleEngine.enabled = true;
mesh.smokeParticleEngine = smokeParticleEngine;
mesh.smokeParticleEngine.position.x = mesh.position.x;
mesh.smokeParticleEngine.position.y = mesh.position.y;
mesh.smokeParticleEngine.position.z = mesh.position.z;
mesh.smokeParticleEngine.updateInstance('position');
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.PLAY_AUDIO,
@ -567,12 +555,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
name : 'Audio - Burning'
}
);
var fireParticleEngine = this.fireParticleEngine.clone();
fireParticleEngine.position = mesh.position.clone();
fireParticleEngine.updateInstance('position');
fireParticleEngine.enabled = true;
mesh.fireParticleEngine = fireParticleEngine;
}
}.bind(this)
);
@ -582,7 +564,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
this.kill = function(enemy) {
if (!enemy.isKanister) {
this.meshes[enemy.meshType].map(
function(object) {
if (object.mesh === enemy.mesh) {
@ -592,7 +573,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
}
}
)
}
/**
* We only remove the things we cloned
*/
@ -618,18 +599,15 @@ GameLib.Event.Emit(
//enemy.mesh.instance.material.dispose();
if (enemy.mesh.smokeParticleEngine) {
enemy.mesh.smokeParticleEngine.remove();
enemy.mesh.smokeParticleEngine = null;
enemy.mesh.smokeParticleEngine.enabled = false;
}
if (enemy.mesh.fireParticleEngine) {
enemy.mesh.fireParticleEngine.remove();
enemy.mesh.fireParticleEngine = null;
enemy.mesh.fireParticleEngine.enabled = false;
}
if (enemy.mesh.explodeParticleEngine) {
enemy.mesh.explodeParticleEngine.remove();
enemy.mesh.explodeParticleEngine = null;
enemy.mesh.explodeParticleEngine.enabled = false;
}
};
@ -970,17 +948,22 @@ this.enemies = this.enemies.reduce(
enemy.burnTime += data.delta;
if (enemy.burnTime > enemy.burnLife) {
enemy.mesh.smokeParticleEngine.remove();
enemy.mesh.fireParticleEngine.remove();
enemy.mesh.smokeParticleEngine.enabled = false;
enemy.mesh.fireParticleEngine.enabled = false;
enemy.lifeTime = enemy.life + 1;
} 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.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.materials[0].opacity -= 0.005;
enemy.mesh.materials[0].opacity -= 0.05 * data.delta;
enemy.mesh.materials[0].updateInstance('opacity');
}