Clean up fire.js

This commit is contained in:
Ryan Huffman 2016-09-20 13:27:17 -07:00
parent fec8049226
commit fd929a46b3

View file

@ -1,6 +1,6 @@
// this script turns an entity into an exploder -- anything that collides with it will be vaporized! // Originally written by James Pollack, modified by Ryan Huffman for the tutorial
//
// //
// this script turns an entity into an exploder -- anything that collides with it will be vaporized!
(function() { (function() {
@ -58,27 +58,20 @@
preload: function(entityID) { preload: function(entityID) {
this.entityID = entityID; this.entityID = entityID;
this.EXPLOSION_SOUND = SoundCache.getSound("atp:/firepit/fire_burst.wav"); this.EXPLOSION_SOUND = SoundCache.getSound("atp:/firepit/fire_burst.wav");
print("IN FIRE SCRIPT");
}, },
collisionWithEntity: function(myID, otherID, collisionInfo) { collisionWithEntity: function(myID, otherID, collisionInfo) {
print("FIRE SCRIPT: COLLIDED");
var otherProps = Entities.getEntityProperties(otherID); var otherProps = Entities.getEntityProperties(otherID);
var data = null; var data = null;
print("FIRE SCRIPT: 2 COLLIDED");
try { try {
print("parsing..");
data = JSON.parse(otherProps.userData) data = JSON.parse(otherProps.userData)
print("done parsing..");
} catch (err) { } catch (err) {
print('ERROR GETTING USERDATA!'); print('ERROR GETTING USERDATA!');
} }
print("HERE");
if (data === null || "") { if (data === null || "") {
return; return;
} else { } else {
if (data.hasOwnProperty('hifiHomeKey')) { if (data.hasOwnProperty('hifiHomeKey')) {
if (data.hifiHomeKey.reset === true) { if (data.hifiHomeKey.reset === true) {
print('FLAMMABLE THING, EXPLODE IT!');
_this.playSoundAtCurrentPosition(); _this.playSoundAtCurrentPosition();
_this.explodeWithColor(); _this.explodeWithColor();
Entities.deleteEntity(otherID) Entities.deleteEntity(otherID)
@ -90,7 +83,6 @@
} }
}, },
explodeWithColor: function() { explodeWithColor: function() {
print('EXPLODE!')
var myProps = Entities.getEntityProperties(this.entityID); var myProps = Entities.getEntityProperties(this.entityID);
var color = colors[Math.floor(Math.random() * colors.length)]; var color = colors[Math.floor(Math.random() * colors.length)];
var explosionParticleProperties = { var explosionParticleProperties = {
@ -152,7 +144,6 @@
}; };
var explosion = Entities.addEntity(explosionParticleProperties); var explosion = Entities.addEntity(explosionParticleProperties);
print('explosion is: ' + explosion)
}, },
playSoundAtCurrentPosition: function() { playSoundAtCurrentPosition: function() {