Update: CC - Before Render - Moorcow (autqzs1rvq.js) 1173 bytes modified

beta.r3js.org
-=yb4f310 2017-11-19 19:01:54 +01:00
parent 12785b484a
commit 8d70f2d5b5
1 changed files with 144 additions and 43 deletions

View File

@ -51,9 +51,31 @@
this.score = 0;
this.lives = 10;
if (this.enemies.length !== 0) {
this.enemies.map(
function(enemy) {
this.kill(enemy);
}.bind(this)
)
}
this.scene.meshes.map(
function(mesh) {
if (mesh.burningTreeParticleEngine) {
mesh.burningTreeParticleEngine.remove();
mesh.burningTreeParticleEngine = null;
}
}.bind(this)
)
this.enemies = [];
this.enemiesSpawned = 0;
this.leftLight.intensity = 0.3;
this.leftLight.updateInstance('intensity');
this.rightLight.intensity = 0.3;
this.rightLight.updateInstance('intensity');
GameLib.Event.Emit(
GameLib.Event.GET_GRAPHICS_IMPLEMENTATION,
@ -63,15 +85,6 @@
}.bind(this)
);
//this.getNextSpawnTime = function() {
/*return GameLib.Utils.GetRandomIntInclusive(
1,
1
);*/
//}
//this.nextSpawnTime = this.getNextSpawnTime();
this.setLevelProperties = function() {
this.prevLevel = this.level;
@ -79,14 +92,38 @@
this.level = Math.floor(this.enemiesSpawned / 10) + 1;
if (this.prevLevel !== this.level) {
this.spawnInterval -= 1 / (this.level);
}
var amount = 1 / this.level;
if (amount < 0.2) {
amount = 0.2;
}
this.spawnInterval -= amount;
if ((this.spawnInterval - amount) < 1) {
this.spawnInterval -= 1 / this.level;
} else {
this.spawnInterval -= amount;
}
console.log('level : ' + this.level +', spawn interval : ' + this.spawnInterval);
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
level : this.level,
spawnInterval : this.spawnInterval,
event : 'levelIncrease'
}
);
}
}
this.spawnEnemy = function() {
this.enemiesSpawned++;
this.setLevelProperties();
var enemyType = GameLib.Utils.GetRandomIntInclusive(1, 5);
@ -211,6 +248,15 @@
enemy.burnTime = 0;
enemy.explodingLife = 2;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
enemiesSpawned : this.enemiesSpawned,
enemy : enemy,
event : 'enemySpawned'
}
);
this.enemies.push(enemy);
}
@ -280,12 +326,22 @@
this.enemies.map(
function(enemy) {
if (enemy.mesh === mesh && !enemy.exploding) {
console.log('exploding enemy');
console.log('exploding enemy');
this.score += this.level * 100;
enemy.exploding = true;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
score : this.score,
enemy : enemy,
event : 'enemyExploded'
}
);
this.explodeMesh(mesh);
}
}.bind(this)
@ -308,6 +364,16 @@
this.score += this.level * 10;
console.log('burning enemy ' + mesh.name);
enemy.burning = true;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
score : this.score,
enemy : enemy,
event : 'enemyBurned'
}
);
var smokeParticleEngine = this.smokeParticleEngine.clone();
smokeParticleEngine.position = mesh.position.clone();
smokeParticleEngine.updateInstance('position');
@ -382,6 +448,13 @@
*/
} else {
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'treeBurned'
}
);
mesh.burning = true;
this.treesBurning++;
@ -395,28 +468,18 @@
this.leftLight.intensity = 1;
}
// this.leftLight.color.g -= 0.05;
// this.leftLight.color.b -= 0.05;
this.leftLight.updateInstance('intensity');
// this.leftLight.updateInstance('color');
} else {
} else {
this.rightLight.intensity += 0.07;
if (this.rightLight.intensity >= 1) {
this.rightLight.intensity = 1;
}
// this.rightLight.color.b -= 0.05;
this.rightLight.updateInstance('intensity');
// this.rightLight.updateInstance('color');
}
// 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,
@ -462,8 +525,26 @@
this.kanisterTime += data.delta;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
used : this.kanisterTime / this.kanisterLife,
event : 'fuelUsed'
percentage : Math.round((this.kanisterTime / this.kanisterLife) * 100) + '%'
}
);
if (this.kanisterTime > this.kanisterLife) {
this.fuelFinished = true;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'fuelFinished'
}
);
}
if (!this.fuelFinished) {
@ -549,20 +630,12 @@
mesh.life -= 0.2;
// Don't do the color instance
//mesh.materials[0].color.instance = mesh.instance.material.color;
if (mesh.life <= 0) {
this.burnTree(mesh);
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) {
// this.explode(mesh);
//}
}
}
@ -579,12 +652,6 @@
}
this.renderer.updateInstance('clearColor');
// this.fog.color.r -= 0.01;
// if (this.fog.color.r < 0.32) {
// this.fog.color.r = 0.32;
// }
// this.fog.updateInstance('color');
this.throwerLight.intensity -= 0.05;
if (this.throwerLight.intensity < 0) {
this.throwerLight.intensity = 0;
@ -612,6 +679,13 @@
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(
@ -642,11 +716,38 @@
if (enemy.lifeTime > enemy.life) {
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'enemyLifetimeReached',
enemy : enemy
}
);
if (!enemy.burning && !enemy.exploding) {
this.lives--;
this.lives--;
console.log('lives left: ' + this.lives);
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
livesLeft : this.lives,
event : 'lifeLost'
}
);
if (this.lives < 0) {
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'gameOver',
gameData : this
}
);
GameLib.Event.Emit(GameLib.Event.GAME_OVER);
}
}