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 = []; 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.MIN_SPAWN_TIME = 1;
GameLib.D3.CustomCode.MAX_SPAWN_TIME = 4; 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.fog = GameLib.EntityManager.Instance.findComponentById('v8r4pl37b0')
this.bull = GameLib.EntityManager.Instance.findComponentById('vff1tr1qyr'); this.bull = GameLib.EntityManager.Instance.findComponentById('vff1tr1qyr');
this.star = GameLib.EntityManager.Instance.findComponentById('bjm2i7hmvh'); 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.renderer = GameLib.EntityManager.Instance.findComponentById('hat9imrjl1');
this.thrower = GameLib.EntityManager.Instance.findComponentById('fn4ywfqnho'); this.thrower = GameLib.EntityManager.Instance.findComponentById('fn4ywfqnho');
//this.renderer = GameLib.EntityManager.Instance.findComponentById('e4xb4aw01w');
this.treeSmall = GameLib.EntityManager.Instance.findComponentById('xcmk2jzxwa'); this.treeSmall = GameLib.EntityManager.Instance.findComponentById('xcmk2jzxwa');
this.treeMedium = GameLib.EntityManager.Instance.findComponentById('wxc9hpu4vx'); this.treeMedium = GameLib.EntityManager.Instance.findComponentById('wxc9hpu4vx');
this.treeLarge = GameLib.EntityManager.Instance.findComponentById('rio8uzlafp'); this.treeLarge = GameLib.EntityManager.Instance.findComponentById('rio8uzlafp');
@ -72,9 +71,9 @@ GameLib.Event.Subscribe(
GameLib.Event.WINDOW_RESIZE, GameLib.Event.WINDOW_RESIZE,
function(data) { function(data) {
var aspect = (data.width / data.height); var aspect = (data.width / data.height);
this.camera.aspect = aspect; this.camera.aspect = aspect;
this.camera.updateInstance('aspect'); this.camera.updateInstance('aspect');
this.renderer.setSize( this.renderer.setSize(
data.width, data.width,
data.height data.height
); );
@ -82,8 +81,8 @@ 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.Subscribe(
GameLib.Event.CUSTOM_GAME_START, GameLib.Event.CUSTOM_GAME_START,
function() { function() {
@ -109,12 +108,35 @@ GameLib.Event.Subscribe(
}.bind(this) }.bind(this)
); );
var mesh = null;
var material = null;
var smokeParticleEngine = null;
var explodeParticleEngine = null;
var fireParticleEngine = null;
this.meshes = {}; this.meshes = {};
this.createMesh = function(meshType, type) { 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.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') { if (typeof this.meshes[meshType] === 'undefined') {
this.meshes[meshType] = []; this.meshes[meshType] = [];
@ -148,10 +170,13 @@ for (var n = 0; n < 5; n++) {
this.createMesh(5, 'santa'); 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 treeSmall = this.treeSmall;
var treeMedium = this.treeMedium; var treeMedium = this.treeMedium;
var treeLarge = this.treeLarge; var treeLarge = this.treeLarge;
@ -159,9 +184,6 @@ var stone1 = this.stone1;
var stone2 = this.stone2; var stone2 = this.stone2;
var materialTreesAndRocks = this.materialTreesAndRocks; var materialTreesAndRocks = this.materialTreesAndRocks;
var mesh = null;
var material = null;
mesh = stone2.clone(); mesh = stone2.clone();
material = materialTreesAndRocks.clone(); material = materialTreesAndRocks.clone();
mesh.materials = [material]; mesh.materials = [material];