Update: CC - Entity Loaded - Moorcow (v6a7eh2o29.js) 725 bytes modified

beta.r3js.org
-=yb4f310 2017-11-26 22:39:46 +01:00
parent 34526b795c
commit 0190ec32b9
1 changed files with 53 additions and 31 deletions

View File

@ -7,14 +7,14 @@ if (this.parentEntity === data.entity) {
this.enemies = [];
/**
* Min and max spawn time is in seconds
*/
* Min and max spawn time is in seconds
*/
GameLib.D3.CustomCode.MIN_SPAWN_TIME = 1;
GameLib.D3.CustomCode.MAX_SPAWN_TIME = 4;
/**
* Create references to all our 'in game' objects
*/
* Create references to all our 'in game' objects
*/
this.fog = GameLib.EntityManager.Instance.findComponentById('v8r4pl37b0')
this.bull = GameLib.EntityManager.Instance.findComponentById('vff1tr1qyr');
this.star = GameLib.EntityManager.Instance.findComponentById('bjm2i7hmvh');
@ -28,7 +28,6 @@ this.dom = GameLib.EntityManager.Instance.findComponentById('5wo9ve6emu');
this.renderer = GameLib.EntityManager.Instance.findComponentById('hat9imrjl1');
this.thrower = GameLib.EntityManager.Instance.findComponentById('fn4ywfqnho');
//this.renderer = GameLib.EntityManager.Instance.findComponentById('e4xb4aw01w');
this.treeSmall = GameLib.EntityManager.Instance.findComponentById('xcmk2jzxwa');
this.treeMedium = GameLib.EntityManager.Instance.findComponentById('wxc9hpu4vx');
this.treeLarge = GameLib.EntityManager.Instance.findComponentById('rio8uzlafp');
@ -72,9 +71,9 @@ GameLib.Event.Subscribe(
GameLib.Event.WINDOW_RESIZE,
function(data) {
var aspect = (data.width / data.height);
this.camera.aspect = aspect;
this.camera.updateInstance('aspect');
this.renderer.setSize(
this.camera.aspect = aspect;
this.camera.updateInstance('aspect');
this.renderer.setSize(
data.width,
data.height
);
@ -82,44 +81,67 @@ GameLib.Event.Subscribe(
);
/**
* Tell all our custom code components that we loaded
*/
* Tell all our custom code components that we loaded
*/
GameLib.Event.Subscribe(
GameLib.Event.CUSTOM_GAME_START,
function() {
delete this.beforeRender.initialized;
this.beforeRender.entityLoaded = this;
this.mouseUp.entityLoaded = this;
this.mouseDown.entityLoaded = this;
this.mouseDown.entityLoaded = this;
this.mouseMove.entityLoaded = this;
this.touchMove.entityLoaded = this;
GameLib.Event.Emit(GameLib.Event.WINDOW_RESIZE, {width : window.innerWidth, height:window.innerHeight});
this.camera.lookAt.x = 0;
this.camera.lookAt.y = 0;
this.camera.lookAt.z = 0;
this.camera.updateInstance('lookAt');
this.mouse.x = 0;
this.mouse.y = 0;
}.bind(this)
);
var mesh = null;
var material = null;
var smokeParticleEngine = null;
var explodeParticleEngine = null;
var fireParticleEngine = null;
this.meshes = {};
this.createMesh = function(meshType, type) {
var mesh = this[type].clone();
var material = this[type].materials[0].clone();
mesh = this[type].clone();
material = this[type].materials[0].clone();
mesh.materials = [material];
mesh.updateInstance();
explodeParticleEngine = this.explodeParticleEngine.clone();
explodeParticleEngine.position = mesh.position.clone();
explodeParticleEngine.updateInstance('position');
mesh.explodeParticleEngine = explodeParticleEngine;
smokeParticleEngine = this.smokeParticleEngine.clone();
smokeParticleEngine.position = mesh.position.clone();
smokeParticleEngine.updateInstance('position');
mesh.smokeParticleEngine = smokeParticleEngine;
fireParticleEngine = this.fireParticleEngine.clone();
fireParticleEngine.position = mesh.position.clone();
fireParticleEngine.updateInstance('position');
mesh.fireParticleEngine = fireParticleEngine;
if (typeof this.meshes[meshType] === 'undefined') {
this.meshes[meshType] = [];
}
this.meshes[meshType].push(
{
inUse : false,
@ -128,30 +150,33 @@ this.createMesh = function(meshType, type) {
);
};
for (var n = 0; n < 5; n++) {
for (var n = 0; n < 5; n++) {
this.createMesh(1, 'bull');
}
for (var n = 0; n < 5; n++) {
for (var n = 0; n < 5; n++) {
this.createMesh(2, 'star');
}
for (var n = 0; n < 5; n++) {
for (var n = 0; n < 5; n++) {
this.createMesh(3, 'burger');
}
for (var n = 0; n < 5; n++) {
for (var n = 0; n < 5; n++) {
this.createMesh(4, 'parcel');
}
for (var n = 0; n < 5; n++) {
for (var n = 0; n < 5; n++) {
this.createMesh(5, 'santa');
}
for (var n = 0; n < 5; n++) {
this.createMesh(6, 'kanister');
}
/**
* Plant all our trees - Below code gets generated automatically
*/
* Plant all our trees - Below code gets generated automatically
*/
var treeSmall = this.treeSmall;
var treeMedium = this.treeMedium;
var treeLarge = this.treeLarge;
@ -159,9 +184,6 @@ var stone1 = this.stone1;
var stone2 = this.stone2;
var materialTreesAndRocks = this.materialTreesAndRocks;
var mesh = null;
var material = null;
mesh = stone2.clone();
material = materialTreesAndRocks.clone();
mesh.materials = [material];
@ -948,4 +970,4 @@ mesh.updateInstance();
GameLib.Event.Emit(GameLib.Event.GAME_LOADED);
//@ sourceURL=entityLoaded.js
//@ sourceURL=entityLoaded.js