Update: CC - Before Render - Moorcow (autqzs1rvq.js) 2308 bytes modified
parent
e197c0bc4e
commit
f5f7a2a790
539
autqzs1rvq.js
539
autqzs1rvq.js
|
@ -1,28 +1,62 @@
|
|||
if (!this.entityLoaded) {
|
||||
if (!this.entityLoaded) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||
if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
GameLib.Event.Emit(GameLib.Event.STOP_ALL_AUDIO);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.PLAY_AUDIO,
|
||||
{
|
||||
name : 'Audio - Xmas'
|
||||
}
|
||||
);
|
||||
|
||||
if (this.blastSubscription) {
|
||||
this.blastSubscription.remove();
|
||||
}
|
||||
|
||||
this.blastSubscription = GameLib.Event.Subscribe(
|
||||
GameLib.Event.AUDIO_ENDED,
|
||||
function(data) {
|
||||
if (data.audio.name.indexOf('Blast') !== -1) {
|
||||
var play = GameLib.Utils.GetRandomIntInclusive(1,5);
|
||||
if (play === 1) {
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.PLAY_AUDIO,
|
||||
{
|
||||
name : 'Audio - Ho ho ho'
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
this.fog = this.entityLoaded.fog;
|
||||
this.bull = this.entityLoaded.bull;
|
||||
this.star = this.entityLoaded.star;
|
||||
this.santa = this.entityLoaded.santa;
|
||||
this.scene = this.entityLoaded.scene;
|
||||
this.camera = this.entityLoaded.camera;
|
||||
this.burger = this.entityLoaded.burger;
|
||||
this.parcel = this.entityLoaded.parcel;
|
||||
this.santa = this.entityLoaded.santa;
|
||||
this.renderer = this.entityLoaded.renderer;
|
||||
this.raycaster = this.entityLoaded.raycaster;
|
||||
this.kanister = this.entityLoaded.kanister;
|
||||
this.scene = this.entityLoaded.scene;
|
||||
this.leftLight = this.entityLoaded.leftLight;
|
||||
this.rightLight = this.entityLoaded.rightLight;
|
||||
this.scoreCanvas = this.entityLoaded.scoreCanvas;
|
||||
this.scoreTexture = this.entityLoaded.scoreTexture;
|
||||
this.scoreMesh = this.entityLoaded.scoreMesh;
|
||||
this.throwerLight = this.entityLoaded.throwerLight;
|
||||
this.smokeParticleEngine = this.entityLoaded.smokeParticleEngine;
|
||||
this.fireParticleEngine = this.entityLoaded.fireParticleEngine;
|
||||
this.burningTreeParticleEngine = this.entityLoaded.burningTreeParticleEngine;
|
||||
this.smokeParticleEngine = this.entityLoaded.smokeParticleEngine;
|
||||
this.explodeParticleEngine = this.entityLoaded.explodeParticleEngine;
|
||||
this.burningTreeParticleEngine = this.entityLoaded.burningTreeParticleEngine;
|
||||
|
||||
this.minimumRendererRed = 0.1;
|
||||
|
||||
|
@ -34,22 +68,84 @@
|
|||
this.burger.instance.visible = false;
|
||||
this.parcel.instance.visible = false;
|
||||
this.santa.instance.visible = false;
|
||||
this.kanister.instance.visible = false;
|
||||
|
||||
this.treesBurning = 0;
|
||||
this.treesBurningToStart = GameLib.Utils.GetRandomIntInclusive(1, 3);
|
||||
|
||||
this.running = false;
|
||||
|
||||
/**
|
||||
* This component is initializing - set the total time to 0
|
||||
*/
|
||||
this.totalTime = 0;
|
||||
this.spawnTime = 0;
|
||||
|
||||
this.kanisters = 3;
|
||||
this.kanisterTime = 0;
|
||||
this.kanisterLife = 16.344;
|
||||
this.kanisterLeakTime = 0.1;
|
||||
this.kanisterSpawnScore = 50;
|
||||
|
||||
this.setNextKanisterSpawnScore = function() {
|
||||
|
||||
this.kanisterSpawnScore = this.score + 100;
|
||||
|
||||
if (this.score > 200) {
|
||||
this.kanisterSpawnScore = this.score + 200;
|
||||
}
|
||||
|
||||
if (this.score > 500) {
|
||||
this.kanisterSpawnScore = this.score + 300;
|
||||
}
|
||||
|
||||
if (this.score > 800) {
|
||||
this.kanisterSpawnScore = this.score + 400;
|
||||
}
|
||||
|
||||
if (this.score > 1100) {
|
||||
this.kanisterSpawnScore = this.score + 500;
|
||||
}
|
||||
|
||||
if (this.score > 1400) {
|
||||
this.kanisterSpawnScore = this.score + 600;
|
||||
}
|
||||
|
||||
if (this.score > 1800) {
|
||||
this.kanisterSpawnScore = this.score + 700;
|
||||
}
|
||||
|
||||
if (this.score > 2500) {
|
||||
this.kanisterSpawnScore = this.score + 800;
|
||||
}
|
||||
|
||||
if (this.score > 3200) {
|
||||
this.kanisterSpawnScore = this.score + 900;
|
||||
}
|
||||
|
||||
if (this.score > 4000) {
|
||||
this.kanisterSpawnScore = this.score + 1000;
|
||||
}
|
||||
|
||||
if (this.score > 5000) {
|
||||
this.kanisterSpawnScore = this.score + 1100;
|
||||
}
|
||||
|
||||
console.log('next kanister spawn score: ' + this.kanisterSpawnScore);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'nextKanisterSpawnScoreUpdate',
|
||||
kanisterSpawnScore : this.kanisterSpawnScore
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
this.fuelFinished = false;
|
||||
|
||||
this.level = 1;
|
||||
this.spawnInterval = 5;
|
||||
|
||||
this.enemySpawnInterval = 5;
|
||||
this.enemySpawnTime = this.enemySpawnInterval;
|
||||
|
||||
this.score = 0;
|
||||
this.lives = 10;
|
||||
|
||||
if (this.enemies instanceof Array && this.enemies.length !== 0) {
|
||||
this.enemies.map(
|
||||
|
@ -68,10 +164,12 @@
|
|||
mesh.burningTreeParticleEngine = null;
|
||||
}
|
||||
}.bind(this)
|
||||
)
|
||||
);
|
||||
|
||||
this.enemies = [];
|
||||
|
||||
this.scores = [];
|
||||
|
||||
this.enemiesSpawned = 0;
|
||||
|
||||
this.fog.density = 0.01;
|
||||
|
@ -81,14 +179,6 @@
|
|||
this.rightLight.intensity = 0.3;
|
||||
this.rightLight.updateInstance('intensity');
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'gameStarted',
|
||||
game : this
|
||||
}
|
||||
);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GET_GRAPHICS_IMPLEMENTATION,
|
||||
null,
|
||||
|
@ -103,72 +193,93 @@
|
|||
|
||||
this.level = Math.floor(this.enemiesSpawned / 10) + 1;
|
||||
|
||||
if (this.prevLevel !== this.level) {
|
||||
|
||||
var amount = 1 / this.level;
|
||||
|
||||
if (amount < 0.1) {
|
||||
amount = 0.1;
|
||||
if (this.level === 1) {
|
||||
this.enemySpawnInterval = 4;
|
||||
}
|
||||
|
||||
this.spawnInterval -= amount;
|
||||
if (this.level === 2) {
|
||||
this.enemySpawnInterval = 3;
|
||||
}
|
||||
|
||||
console.log('level : ' + this.level +', spawn interval : ' + this.spawnInterval);
|
||||
if (this.level === 3) {
|
||||
this.enemySpawnInterval = 2;
|
||||
}
|
||||
|
||||
if (this.level > 3) {
|
||||
this.enemySpawnInterval = 1.5;
|
||||
}
|
||||
|
||||
console.log('level : ' + this.level +', spawn interval : ' + this.enemySpawnInterval);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
level : this.level,
|
||||
spawnInterval : this.spawnInterval,
|
||||
enemySpawnInterval : this.enemySpawnInterval,
|
||||
event : 'levelIncrease'
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.spawnEnemy = function() {
|
||||
|
||||
this.enemiesSpawned++;
|
||||
|
||||
this.setLevelProperties();
|
||||
this.spawnEnemy = function(kanister) {
|
||||
|
||||
var enemyType = GameLib.Utils.GetRandomIntInclusive(1, 5);
|
||||
var meshType = GameLib.Utils.GetRandomIntInclusive(1, 5);
|
||||
|
||||
if (kanister) {
|
||||
meshType = 6;
|
||||
} else {
|
||||
this.enemiesSpawned++;
|
||||
this.setLevelProperties();
|
||||
}
|
||||
|
||||
var y = GameLib.Utils.GetRandomIntInclusive(2, 10);
|
||||
|
||||
var speed = 1;
|
||||
|
||||
var score = 10;
|
||||
|
||||
var material = null;
|
||||
|
||||
var mesh = null;
|
||||
if (meshType === 1) {
|
||||
mesh = this.bull.clone();
|
||||
material = this.bull.materials[0].clone();
|
||||
speed = 0.2;
|
||||
speed = 0.3;
|
||||
} else if (meshType === 2) {
|
||||
mesh = this.star.clone();
|
||||
score = 20;
|
||||
material = this.star.materials[0].clone();
|
||||
speed = 0.3;
|
||||
speed = 0.4;
|
||||
} else if (meshType === 3) {
|
||||
mesh = this.burger.clone();
|
||||
score = 50;
|
||||
material = this.burger.materials[0].clone();
|
||||
speed = 0.4;
|
||||
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.5;
|
||||
} else {
|
||||
speed = 0.6;
|
||||
} else if (meshType === 6) {
|
||||
mesh = this.kanister.clone();
|
||||
score = 100;
|
||||
material = this.kanister.materials[0].clone();
|
||||
speed = 0.7;
|
||||
}
|
||||
else {
|
||||
console.log('unknown mesh type : ' + meshType);
|
||||
}
|
||||
|
||||
mesh.materials = [material];
|
||||
|
||||
mesh.updateInstance();
|
||||
mesh.updateInstance('materials');
|
||||
|
||||
mesh.instance.visible = true;
|
||||
|
||||
|
@ -198,17 +309,17 @@
|
|||
var distance = 100;
|
||||
var angledistance = distance * Math.sin(Math.PI / 4);
|
||||
|
||||
var life = 2.5 / speed;
|
||||
var life = 5 / speed;
|
||||
|
||||
if (enemyType === 1) {
|
||||
position.x = -distance;
|
||||
life += 1.5 / speed;
|
||||
life += 3 / speed;
|
||||
velocity = {x:speed,y:0,z:0};
|
||||
}
|
||||
|
||||
if (enemyType === 2) {
|
||||
position.x = distance;
|
||||
life += 1.5 / speed;
|
||||
life += 3 / speed;
|
||||
velocity = {x:-speed,y:0,z:0};
|
||||
}
|
||||
|
||||
|
@ -233,14 +344,14 @@
|
|||
enemy.mesh.position.x = position.x;
|
||||
enemy.mesh.position.y = position.y;
|
||||
enemy.mesh.position.z = position.z;
|
||||
enemy.mesh.updateInstancePosition();
|
||||
enemy.mesh.updateInstance('position');
|
||||
|
||||
enemy.mesh.useQuaternion = true;
|
||||
enemy.mesh.quaternion.axis.x = rotation.axis.x;
|
||||
enemy.mesh.quaternion.axis.y = rotation.axis.y;
|
||||
enemy.mesh.quaternion.axis.z = rotation.axis.z;
|
||||
enemy.mesh.quaternion.angle = rotation.angle;
|
||||
enemy.mesh.updateInstanceRotation();
|
||||
enemy.mesh.updateInstance('quaternion');
|
||||
|
||||
enemy.velocity = velocity;
|
||||
enemy.rotation = rotation;
|
||||
|
@ -253,18 +364,44 @@
|
|||
enemy.burnLife = 3;
|
||||
enemy.burnTime = 0;
|
||||
enemy.explodingLife = 2;
|
||||
enemy.meshType = meshType;
|
||||
enemy.score = score;
|
||||
enemy.isKanister = false;
|
||||
|
||||
if (kanister) {
|
||||
enemy.isKanister = true;
|
||||
} else {
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
enemiesSpawned : this.enemiesSpawned,
|
||||
enemy : enemy,
|
||||
event : 'enemySpawned'
|
||||
enemiesSpawned: this.enemiesSpawned,
|
||||
enemy: enemy,
|
||||
event: 'enemySpawned'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.enemies.push(enemy);
|
||||
};
|
||||
|
||||
this.spawnKanister = function() {
|
||||
|
||||
console.log('spawning kanister');
|
||||
|
||||
this.setNextKanisterSpawnScore();
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'kanisterCountUpdate',
|
||||
kanisters : this.kanisters
|
||||
}
|
||||
);
|
||||
|
||||
this.enemies.push(enemy);
|
||||
}
|
||||
this.spawnEnemy(true);
|
||||
};
|
||||
|
||||
|
||||
this.explodeMesh = function(mesh) {
|
||||
|
||||
|
@ -284,34 +421,6 @@
|
|||
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;
|
||||
|
||||
var play = GameLib.Utils.GetRandomIntInclusive(1,3);
|
||||
|
||||
if (play === 1) {
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.PLAY_AUDIO,
|
||||
{
|
||||
name : 'Audio - Ho ho ho'
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.PLAY_AUDIO,
|
||||
{
|
||||
|
@ -327,54 +436,99 @@
|
|||
|
||||
};
|
||||
|
||||
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) {
|
||||
|
||||
enemy.exploding = true;
|
||||
|
||||
if (enemy.isKanister) {
|
||||
this.kanisters += 1;
|
||||
|
||||
if (this.kanisters > 9) {
|
||||
this.kanisters = 9;
|
||||
}
|
||||
|
||||
console.log('exploding kanister');
|
||||
} else {
|
||||
|
||||
console.log('exploding enemy');
|
||||
|
||||
this.score += this.level * 100;
|
||||
this.score += enemy.score;
|
||||
|
||||
enemy.exploding = true;
|
||||
this.drawScore(enemy);
|
||||
|
||||
console.log('score : ' + this.score);
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'scoreUpdate',
|
||||
score : this.score
|
||||
}
|
||||
);
|
||||
|
||||
if (this.score > this.kanisterSpawnScore) {
|
||||
this.spawnKanister();
|
||||
}
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
score : this.score,
|
||||
enemy : enemy,
|
||||
event : 'enemyExploded'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.explodeMesh(mesh);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.explodeKanister = function() {
|
||||
this.kanisterTime = 0;
|
||||
this.fuelFinished = false;
|
||||
this.explodeMesh(this.kanister);
|
||||
}
|
||||
};
|
||||
|
||||
this.burn = function(mesh) {
|
||||
|
||||
this.enemies.map(
|
||||
function(enemy) {
|
||||
if (enemy.mesh === mesh && !enemy.burning) {
|
||||
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'
|
||||
}
|
||||
|
@ -403,7 +557,7 @@
|
|||
);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
this.kill = function(enemy) {
|
||||
/**
|
||||
|
@ -458,11 +612,26 @@
|
|||
|
||||
this.treesBurning++;
|
||||
|
||||
if (
|
||||
(this.treesBurning > this.treesBurningToStart) &&
|
||||
!this.running
|
||||
) {
|
||||
this.running = true;
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'gameRunning',
|
||||
message : 'we have enough trees burning now to start - the enemy will spawn now'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'treeBurned',
|
||||
treesBurning : this.treesBurning
|
||||
treesBurning : this.treesBurning,
|
||||
treesBurningToStart : this.treesBurningToStart
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -508,15 +677,26 @@
|
|||
burningTreeParticleEngine.enabled = true;
|
||||
mesh.burningTreeParticleEngine = burningTreeParticleEngine;
|
||||
}
|
||||
};
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_STARTED,
|
||||
{
|
||||
game : this
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.spawnEnemy();
|
||||
}
|
||||
this.totalTime += data.delta;
|
||||
this.enemySpawnTime += data.delta;
|
||||
|
||||
this.totalTime += data.delta;
|
||||
this.spawnTime += data.delta;
|
||||
this.scoreMesh.materials[0].opacity -= data.delta * 0.5;
|
||||
if (this.scoreMesh.materials[0].opacity < 0) {
|
||||
this.scoreMesh.materials[0].opacity = 0;
|
||||
}
|
||||
this.scoreMesh.materials[0].updateInstance('opacity');
|
||||
|
||||
this.scene.meshes.map(
|
||||
this.scene.meshes.map(
|
||||
function(mesh) {
|
||||
if (mesh.instance.material instanceof Array) {
|
||||
mesh.instance.material.map(
|
||||
|
@ -532,36 +712,12 @@
|
|||
}
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
if (this.mouseIsDown) {
|
||||
);
|
||||
|
||||
if (this.mouseIsDown)
|
||||
{
|
||||
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) {
|
||||
|
||||
this.renderer.clearColor.r += 0.01;
|
||||
if (this.renderer.clearColor.r > 0.45) {
|
||||
this.renderer.clearColor.r = 0.45;
|
||||
|
@ -573,7 +729,6 @@
|
|||
this.throwerLight.intensity = 2;
|
||||
}
|
||||
this.throwerLight.updateInstance('intensity');
|
||||
}
|
||||
|
||||
var intersects = this.raycaster.getIntersectedObjects(this.scene.meshes);
|
||||
intersects.map(
|
||||
|
@ -582,7 +737,7 @@
|
|||
var mesh = intersect.mesh;
|
||||
|
||||
if (mesh.name.indexOf('Kanister') !== -1) {
|
||||
this.explodeKanister();
|
||||
this.explode(mesh);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -649,7 +804,10 @@
|
|||
}.bind(this)
|
||||
);
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.kanisterTime += (data.delta * this.kanisterLeakTime);
|
||||
|
||||
this.renderer.clearColor.r -= 0.01;
|
||||
if (this.renderer.clearColor.r < this.minimumRendererRed) {
|
||||
|
@ -662,38 +820,73 @@
|
|||
this.throwerLight.intensity = 0;
|
||||
}
|
||||
this.throwerLight.updateInstance('intensity');
|
||||
}
|
||||
|
||||
var used = this.kanisterTime / this.kanisterLife;
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'fuelUsed',
|
||||
used : used,
|
||||
percentage : Math.round(used * 100) + '%',
|
||||
kanisters : this.kanisters
|
||||
}
|
||||
);
|
||||
|
||||
if (this.spawnTime > this.spawnInterval) {
|
||||
this.spawnTime = 0;
|
||||
this.spawnEnemy();
|
||||
}
|
||||
if (this.kanisterTime > this.kanisterLife) {
|
||||
|
||||
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');
|
||||
this.kanisterTime = 0;
|
||||
this.kanisters -= 1;
|
||||
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_DATA,
|
||||
{
|
||||
event : 'kanisterAppeared'
|
||||
event : 'kanisterCountUpdate',
|
||||
kanisters : this.kanisters
|
||||
}
|
||||
);
|
||||
|
||||
if (this.kanisters < 0) {
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.GAME_OVER,
|
||||
{
|
||||
game : this
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.enemies = this.enemies.reduce(
|
||||
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) {
|
||||
|
||||
if (enemy.exploding === true) {
|
||||
|
@ -712,10 +905,10 @@
|
|||
}
|
||||
|
||||
enemy.mesh.position.add(enemy.velocity);
|
||||
enemy.mesh.updateInstancePosition();
|
||||
enemy.mesh.updateInstance('position');
|
||||
|
||||
enemy.mesh.quaternion.angle += enemy.rotation.angle;
|
||||
enemy.mesh.updateInstanceRotation();
|
||||
enemy.mesh.updateInstance('quaternion');
|
||||
|
||||
enemy.lifeTime += data.delta;
|
||||
|
||||
|
@ -729,47 +922,19 @@
|
|||
}
|
||||
);
|
||||
|
||||
if (!enemy.burning && !enemy.exploding) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We only remove the things we cloned
|
||||
*/
|
||||
this.kill(enemy);
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
} else {
|
||||
|
||||
if (enemy.burning) {
|
||||
|
||||
enemy.burnTime += data.delta;
|
||||
|
||||
if (enemy.burnTime > enemy.burnLife) {
|
||||
enemy.mesh.smokeParticleEngine.remove();
|
||||
enemy.mesh.fireParticleEngine.remove();
|
||||
|
@ -792,7 +957,7 @@
|
|||
|
||||
}.bind(this),
|
||||
[]
|
||||
);
|
||||
);
|
||||
|
||||
return null;
|
||||
return null;
|
||||
//# sourceURL=beforeRender.js
|
Loading…
Reference in New Issue