Skip to content

Commit

Permalink
prepare for more than 1 zombie.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Hulha committed Nov 21, 2013
1 parent 6f8e93d commit c85499a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
36 changes: 22 additions & 14 deletions js/loadScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ require([
//var point;
// The Loader takes care of loading data from a URL...
var loader = new DynamicLoader({world: goo.world, rootPath: 'res'});
//var loader2 = new DynamicLoader({world: goo.world, rootPath: 'res'});
//var loader3 = new DynamicLoader({world: goo.world, rootPath: 'res'});

var promises = [];
promises.push(loader.loadFromBundle('project.project', 'root.bundle'));
promises.push(loader.loadFromBundle('project.project', 'zombie.bundle'));
promises.push(loader.loadFromBundle('project.project', 'Point.bundle'));
promises.push(loader.loadFromBundle('project.project', 'zombie.bundle'));
//promises.push(loader2.loadFromBundle('project.project', 'zombie.bundle'));
//promises.push(loader3.loadFromBundle('project.project', 'zombie.bundle'));
RSVP.all(promises)
.then(function(){
initGoobers(goo);
Expand Down Expand Up @@ -128,17 +133,20 @@ require([

Game.userEntity.setComponent(new FlashlightComponent());

var zombie = loader.getCachedObjectForRef("zombie_idle/entities/Zombie_Geo_0.entity");
//zombie.removeFromWorld(); // this breaks the parent child relationship, the parent has the animation that I need...
var z2 = zombie; // EntityUtils.clone(goo.world, zombie);
z2.transformComponent.setTranslation(-2,0,2);
z2.setComponent(new AIComponent(z2));
z2.aIComponent.addBehavior({name:"Zombie-Idle", update:ZombieIdle}, 0);
z2.aIComponent.addBehavior({name:"Zombie-PathFind", update:ZombiePathFind}, 1);
// z2.addToWorld();
Game.zombie = zombie;
Game.zombieRoot = zombie.transformComponent.parent.entity;

function addZombie( loader, x, y, z ) {
var z = loader.getCachedObjectForRef("zombie_idle/entities/Zombie_Geo_0.entity");
//zombie.removeFromWorld(); EntityUtils.clone(goo.world, zombie); // this breaks the parent child relationship, the parent has the animation that I need...
z.transformComponent.setTranslation( x, y, z);
z.setComponent(new AIComponent(z));
z.aIComponent.addBehavior({name:"Zombie-Idle", update:ZombieIdle}, 0);
z.aIComponent.addBehavior({name:"Zombie-PathFind", update:ZombiePathFind}, 1);
}
// var z3 = EntityUtils.clone(goo.world, zombie.transformComponent.parent.entity); z3.addToWorld(); // shares animation... this sucks...

addZombie( loader, 7, 0, -50);
//addZombie( loader2, 50, 0, -50);
//addZombie( loader3, -50, 0, -50);

//console.log(navRef);

goo.renderer.domElement.id = 'goo';
Expand Down Expand Up @@ -179,7 +187,7 @@ require([
(v1.x * v2.y) - (v1.y * v2.x));
c.normalize();
var dp = (this.pickRay.direction.x*c.x)+(this.pickRay.direction.y*c.y)+(this.pickRay.direction.z*c.z);
console.log(dp);
//console.log(dp);
// if(dp >= 0){
if(result[i].intersection.distances[j] < distance){
distance = result[i].intersection.distances[j];
Expand Down Expand Up @@ -376,7 +384,7 @@ require([
node.doorPos = navMesh.room[entity.room].door[node.curNode.door].center;
entity.aIComponent.setActiveByName("Zombie-Idle", false);
node.state = 1;
var eac = Game.zombieRoot.animationComponent;
var eac = entity.transformComponent.parent.entity.animationComponent;
eac.transitionTo( eac.getStates()[1]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/FPSCamComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ define([
var entityTransform;
var cam;
var camTransform;
var speed = 5;
var speed = 10;
var tmpVec = new Vector3();
var fwdBase = new Vector3(0,0,-1);
var leftBase = new Vector3(-1,0,0);
Expand All @@ -52,7 +52,7 @@ define([
this.type = "FPSCamComponent";
//entity = entityRef;
entityTransform = Game.userEntity.transformComponent.transform;
cam = EntityUtils.createTypicalEntity(Game.goo.world, new Camera(45, 1.0, 0.01, 100));
cam = EntityUtils.createTypicalEntity(Game.goo.world, new Camera(45, 1.0, 0.01, 130));
Game.viewCam = cam;
camTransform = cam.transformComponent.transform;
cam.addToWorld();
Expand Down
3 changes: 2 additions & 1 deletion lib/ShotgunComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ define([
if( entity.dmg && entity.dmg > 100) {
eac.layers[0]._steadyStates['mixamo_com__']._sourceTree._clipInstance._loopCount=1;
eac.transitionTo( eac.getStates()[3]); // idle, injured_walk, uppercut_jab, dying
Game.zombie.aIComponent.setActiveByName("Zombie-PathFind", false);
entity.aIComponent.setActiveByName("Zombie-PathFind", false);
}
}

Expand All @@ -118,6 +118,7 @@ define([
if(true == bool0){
//console.log("bam");
if(document.pointerLockElement) {
console.log( Game.userEntity.transformComponent.transform.translation.data );
sound.play();
shotgun.transformComponent.setRotation( 0.35, 0.1, 0);
setTimeout( resetSSG, 250);
Expand Down

0 comments on commit c85499a

Please sign in to comment.