dressing room and tilt maze thangs

This commit is contained in:
James B. Pollack 2016-03-28 15:07:14 -07:00
parent 3f6b7c2f1c
commit cb1f5e3e4f
3 changed files with 35 additions and 13 deletions

View file

@ -28,16 +28,7 @@
var otherProps = Entities.getEntityProperties(otherID);
if (otherProps.name === "hifi-home-dressing-room-transformer-collider" && _this.locked === false) {
var myProps = Entities.getEntityProperties(myID);
var distance = Vec3.distance(myProps.position, otherProps.position);
if (distance < TRIGGER_DISTANCE) {
print('transformer should do magic!!!')
// this.playTransformationSound(collisionInfo.contactPoint);
// this.createTransformationParticles();
_this.findRotatorBlock();
} else {
return;
}
_this.findRotatorBlock();
this.locked = true;
} else {
@ -75,11 +66,19 @@
removeCurrentBigVersion: function(rotatorBlock) {
print('transformer should remove big version')
var blacklistKey = 'Hifi-Hand-RayPick-Blacklist';
var myProps = Entities.getEntityProperties(_this.entityID);
var results = Entities.findEntities(myProps.position, 10);
results.forEach(function(result) {
var resultProps = Entities.getEntityProperties(result);
if (resultProps.name === "hifi-home-dressing-room-big-transformer") {
Messages.sendMessage(blacklistKey, JSON.stringify({
action: 'remove',
id: result
}));
Entities.deleteEntity(result);
}
});
@ -89,6 +88,7 @@
},
createBigVersion: function(smallProps) {
print('transformer should create big version!!')
print('transformer has rotatorBlock??' + _this.rotatorBlock);
var rotatorProps = Entities.getEntityProperties(_this.rotatorBlock);
@ -110,12 +110,26 @@
}
var bigVersion = Entities.addEntity(bigVersionProps);
print('transformer created big version: ' + bigVersion)
print('transformer created big version: ' + bigVersion);
var blacklistKey = 'Hifi-Hand-RayPick-Blacklist';
Messages.sendMessage(blacklistKey, JSON.stringify({
action: 'add',
id: bigVersion
}));
_this.putNewVersionOnShelf();
},
putTransformerOnRotatorBlock: function(blockPosition) {
print('transformer should get set on rotator block')
blockPosition.y = blockPosition.y + 1;
// var newPosition = {
// x:blockPosition.x,
// y:blockPosition.y+1,
// z:blockPosition
// };
return blockPosition
},

View file

@ -20,6 +20,7 @@
},
visible: true,
damping: 0.8,
angularDamping:0.8,
userData: JSON.stringify({
'grabbableKey': {
'grabbable': true
@ -32,6 +33,7 @@
'reset': true
}
}),
density:5000,
dimensions: dimensions,
script: TRANSFORMER_SCRIPT
}

View file

@ -64,6 +64,7 @@
preload: function(entityID) {
this.entityID = entityID;
VICTORY_SOUND = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/DomainContent/Home/tiltMaze/levelUp.wav");
Script.update.connect(this.update);
},
startNearGrab: function() {
//check to make sure a ball is in range, otherwise create one
@ -165,6 +166,7 @@
var ballSpawnerPosition = Entities.getEntityProperties(data.tiltMaze.ballSpawner, 'position').position;
var separation = Vec3.distance(ballPosition, ballSpawnerPosition);
print('ball separation: ' + separation)
if (separation > BALL_DISTANCE_THRESHOLD) {
this.destroyBall();
this.createBall();
@ -226,9 +228,13 @@
} else {
return;
}
}
}
print('in update loop for maze, look for balls to clear')
this.testBallDistance()
_this.testBallDistance()
},
unload:function(){
Script.update.disconnect(this.update);
}
};