Update: CC - Before Render - Moorcow (a2ow5l92js.js) 223 bytes modified

beta.r3js.org
-=yb4f310 2017-11-24 14:00:24 +01:00
parent e45783651c
commit 7e5b09f50d
1 changed files with 44 additions and 27 deletions

View File

@ -106,34 +106,39 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
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;
}
this.enemySpawnInterval -= amount;
console.log('level : ' + this.level +', spawn interval : ' + this.enemySpawnInterval);
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
level : this.level,
enemySpawnInterval : this.enemySpawnInterval,
event : 'levelIncrease'
}
);
if (this.level === 1) {
this.enemySpawnInterval = 4;
}
if (this.level === 2) {
this.enemySpawnInterval = 3;
}
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,
enemySpawnInterval : this.enemySpawnInterval,
event : 'levelIncrease'
}
);
};
this.spawnEnemy = function() {
this.enemiesSpawned++;
//this.setLevelProperties();
this.setLevelProperties();
var enemyType = GameLib.Utils.GetRandomIntInclusive(1, 5);
var meshType = GameLib.Utils.GetRandomIntInclusive(1, 5);
@ -142,6 +147,8 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
var speed = 1;
var score = 10;
var material = null;
var mesh = null;
@ -151,18 +158,22 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
speed = 0.2;
} else if (meshType === 2) {
mesh = this.star.clone();
score = 20;
material = this.star.materials[0].clone();
speed = 0.3;
} else if (meshType === 3) {
mesh = this.burger.clone();
score = 50;
material = this.burger.materials[0].clone();
speed = 0.4;
} 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 {
@ -257,6 +268,7 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
enemy.burnTime = 0;
enemy.explodingLife = 2;
enemy.meshType = meshType;
enemy.score = score;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
@ -339,14 +351,22 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
console.log('exploding enemy');
this.score += this.level * 100;
this.score += enemy.score;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
event : 'scoreUpdate',
score : this.score
}
);
enemy.exploding = true;
GameLib.Event.Emit(
GameLib.Event.GAME_DATA,
{
score : this.score,
enemy : enemy,
event : 'enemyExploded'
}
@ -356,8 +376,6 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
}
}.bind(this)
);
};
this.explodeKanister = function() {
@ -371,14 +389,13 @@ if (GameLib.Utils.UndefinedOrNull(this.initialized)) {
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'
}