Update: CC - Before Render - Moorcow (qi81k80v08.js) 332 bytes modified
parent
bddaac924d
commit
6623a7a544
|
@ -2,10 +2,19 @@ if (!this.entityLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (GameLib.Utils.UndefinedOrNull(this.loaded)) {
|
||||||
GameLib.Utils.UndefinedOrNull(this.totalTime) ||
|
|
||||||
GameLib.Utils.UndefinedOrNull(this.spawnTime)
|
this.loaded = true;
|
||||||
) {
|
|
||||||
|
this.bull = this.entityLoaded.bull;
|
||||||
|
this.star = this.entityLoaded.star;
|
||||||
|
this.burger = this.entityLoaded.burger;
|
||||||
|
this.parcel = this.entityLoaded.parcel;
|
||||||
|
|
||||||
|
this.bull.instance.visible = false;
|
||||||
|
this.star.instance.visible = false;
|
||||||
|
this.burger.instance.visible = false;
|
||||||
|
this.parcel.instance.visible = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component is initializing - set the total time to 0
|
* This component is initializing - set the total time to 0
|
||||||
|
@ -13,12 +22,6 @@ if (
|
||||||
this.totalTime = 0;
|
this.totalTime = 0;
|
||||||
this.spawnTime = 0;
|
this.spawnTime = 0;
|
||||||
|
|
||||||
var cow = GameLib.EntityManager.Instance.findComponentById('bvgbmo4bt1');
|
|
||||||
var burger = GameLib.EntityManager.Instance.findComponentById('c6pem3i8dt');
|
|
||||||
|
|
||||||
cow.instance.visible = false;
|
|
||||||
burger.instance.visible = false;
|
|
||||||
|
|
||||||
this.enemies = [];
|
this.enemies = [];
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
|
@ -36,32 +39,39 @@ if (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scene = GameLib.EntityManager.Instance.findComponentById('q1f5n01iqk');
|
|
||||||
|
|
||||||
this.nextSpawnTime = this.getNextSpawnTime();
|
this.nextSpawnTime = this.getNextSpawnTime();
|
||||||
|
|
||||||
this.spawnEnemy = function() {
|
this.spawnEnemy = function() {
|
||||||
|
|
||||||
var enemyType = Math.floor((Math.random() * 5) + 1);
|
var enemyType = GameLib.Utils.GetRandomIntInclusive(1, 5);
|
||||||
var meshType = Math.floor((Math.random() * 2) + 1);
|
var meshType = GameLib.Utils.GetRandomIntInclusive(1, 4);
|
||||||
|
|
||||||
var y = Math.floor((Math.random() * 10) + 2);
|
var y = GameLib.Utils.GetRandomIntInclusive(2, 10));
|
||||||
|
|
||||||
var apiBox = new GameLib.D3.API.Mesh();
|
var apiBox = new GameLib.D3.API.Mesh();
|
||||||
|
|
||||||
apiBox.materials = [this.boxMaterial];
|
apiBox.materials = [this.boxMaterial];
|
||||||
|
|
||||||
var speed = 0.5;
|
var speed = 1;
|
||||||
|
|
||||||
var box = null;
|
var mesh = null;
|
||||||
if (meshType === 1) {
|
if (meshType === 1) {
|
||||||
box = cow.clone();
|
mesh = this.bull.clone();
|
||||||
} else {
|
speed = 0.2;
|
||||||
box = burger.clone();
|
} else if (meshType === 2) {
|
||||||
|
mesh = this.star.clone();
|
||||||
speed = 0.3;
|
speed = 0.3;
|
||||||
|
} else if (meshType === 3) {
|
||||||
|
mesh = this.burger.clone();
|
||||||
|
speed = 0.4;
|
||||||
|
} else if (meshType === 4) {
|
||||||
|
mesh = this.parcel.clone();
|
||||||
|
speed = 0.5;
|
||||||
|
} else {
|
||||||
|
console.log('unknown mesh type : ' + meshType);
|
||||||
}
|
}
|
||||||
|
|
||||||
box.instance.visible = true;
|
mesh.instance.visible = true;
|
||||||
|
|
||||||
var velocity = null;
|
var velocity = null;
|
||||||
|
|
||||||
|
@ -73,10 +83,8 @@ if (
|
||||||
|
|
||||||
var rotation = {x : rotX, y: rotY, z: rotZ};
|
var rotation = {x : rotX, y: rotY, z: rotZ};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var enemy = {
|
var enemy = {
|
||||||
mesh : box
|
mesh : mesh
|
||||||
};
|
};
|
||||||
|
|
||||||
if (enemyType === 1) {
|
if (enemyType === 1) {
|
||||||
|
@ -114,6 +122,8 @@ if (
|
||||||
enemy.mesh.updateInstancePosition();
|
enemy.mesh.updateInstancePosition();
|
||||||
|
|
||||||
enemy.velocity = velocity;
|
enemy.velocity = velocity;
|
||||||
|
enemy.rotation = rotation;
|
||||||
|
|
||||||
enemy.lifeTime = 0;
|
enemy.lifeTime = 0;
|
||||||
enemy.life = 15;
|
enemy.life = 15;
|
||||||
|
|
||||||
|
@ -134,6 +144,8 @@ this.enemies = this.enemies.reduce(
|
||||||
function(result, enemy) {
|
function(result, enemy) {
|
||||||
enemy.mesh.position.add(enemy.velocity);
|
enemy.mesh.position.add(enemy.velocity);
|
||||||
enemy.mesh.updateInstancePosition();
|
enemy.mesh.updateInstancePosition();
|
||||||
|
|
||||||
|
enemy.mesh.rotation.add(enemy.rotation);
|
||||||
enemy.lifeTime += data.delta;
|
enemy.lifeTime += data.delta;
|
||||||
if (enemy.lifeTime > enemy.life) {
|
if (enemy.lifeTime > enemy.life) {
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
|
|
Loading…
Reference in New Issue