mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 21:51:36 +02:00
Update xylophoneKey.js
Made all the requested changes.
This commit is contained in:
parent
2e2a6318a6
commit
62287a6a9f
1 changed files with 23 additions and 21 deletions
|
@ -1,12 +1,12 @@
|
||||||
(function() {
|
(function() {
|
||||||
var BASE_PATH = "http://mpassets.highfidelity.com/3fd92e5e-93cf-4bc1-b2f1-c6bae5629814-v1/";
|
Script.include(Script.resolvePath("pUtils.js"));
|
||||||
Script.include(BASE_PATH + "pUtils.js");
|
const TIMEOUT = 150;
|
||||||
var TIMEOUT = 150;
|
const TEXGRAY = Script.resolvePath("xylotex_bar_gray.png");
|
||||||
|
const TEXBLACK = Script.resolvePath("xylotex_bar_black.png");
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
function XylophoneKey() {
|
function XylophoneKey() {
|
||||||
_this = this;
|
_this = this;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XylophoneKey.prototype = {
|
XylophoneKey.prototype = {
|
||||||
|
@ -17,15 +17,16 @@
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
_this.entityID = entityID;
|
_this.entityID = entityID;
|
||||||
|
var soundURL = Script.resolvePath(JSON.parse(Entities.getEntityProperties(_this.entityID, ["userData"]).userData).soundFile);
|
||||||
var soundURL = BASE_PATH + JSON.parse(Entities.getEntityProperties(_this.entityID, ["userData"]).userData).soundFile;
|
|
||||||
//_this.homePos = Entities.getEntityProperties(entityID, ["position"]).position;
|
|
||||||
//Entities.editEntity(_this.entityID, {position: _this.homePos}); //This is the workaround for collisionWithEntity not being triggered after entity is reloaded.
|
|
||||||
_this.sound = SoundCache.getSound(soundURL);
|
_this.sound = SoundCache.getSound(soundURL);
|
||||||
|
//Explicitly setting dimensions is a workaround for collisionWithEntity not being triggered after entity is reloaded. Fogbugz Case no. 1939
|
||||||
|
Entities.editEntity(_this.entityID, {dimensions: {x: 0.15182036161422729, y: 0.049085158854722977, z: 0.39702033996582031}});
|
||||||
},
|
},
|
||||||
|
|
||||||
collisionWithEntity: function(thisEntity, otherEntity, collision) {
|
collisionWithEntity: function(thisEntity, otherEntity, collision) {
|
||||||
if (!_this.isWaiting && collision.type == 0) {_this.hit();}
|
if (collision.type === 0) {
|
||||||
|
_this.hit();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clickDownOnEntity: function() {
|
clickDownOnEntity: function() {
|
||||||
|
@ -33,25 +34,26 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
hit: function() {
|
hit: function() {
|
||||||
_this.isWaiting = true;
|
if (!_this.isWaiting) {
|
||||||
_this.homePos = Entities.getEntityProperties(_this.entityID, ["position"]).position;
|
_this.isWaiting = true;
|
||||||
_this.injector = Audio.playSound(_this.sound, {position: _this.homePos, volume: 1});
|
_this.homePos = Entities.getEntityProperties(_this.entityID, ["position"]).position;
|
||||||
Controller.triggerHapticPulse(1, 15, 2); //This should be made to only pulse the hand thats holding the mallet.
|
_this.injector = Audio.playSound(_this.sound, {position: _this.homePos, volume: 1});
|
||||||
editEntityTextures(_this.entityID, "file5", BASE_PATH + "xylotex_bar_gray.png");
|
Controller.triggerHapticPulse(1, 15, 2); //This should be made to only pulse the hand thats holding the mallet.
|
||||||
var newPos = Vec3.sum(_this.homePos, {x:0,y:-0.025,z:0});
|
editEntityTextures(_this.entityID, "file5", TEXGRAY);
|
||||||
Entities.editEntity(_this.entityID, {position: newPos});
|
var newPos = Vec3.sum(_this.homePos, {x:0,y:-0.025,z:0});
|
||||||
_this.timeout();
|
Entities.editEntity(_this.entityID, {position: newPos});
|
||||||
|
_this.timeout();
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
timeout: function() {
|
timeout: function() {
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
editEntityTextures(_this.entityID, "file5", BASE_PATH + "xylotex_bar_black.png");
|
editEntityTextures(_this.entityID, "file5", TEXBLACK);
|
||||||
Entities.editEntity(_this.entityID, {position: _this.homePos});
|
Entities.editEntity(_this.entityID, {position: _this.homePos});
|
||||||
_this.isWaiting = false;
|
_this.isWaiting = false;
|
||||||
}, TIMEOUT)
|
}, TIMEOUT);
|
||||||
},
|
},
|
||||||
|
}
|
||||||
};
|
|
||||||
|
|
||||||
return new XylophoneKey();
|
return new XylophoneKey();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue