content/hifi-content/davidback/development/shortbow/startGameButtonClientEntity.js
2022-02-13 22:49:05 +01:00

33 lines
No EOL
1.2 KiB
JavaScript

(function() {
Script.include('utils.js');
StartButton = function() {
};
StartButton.prototype = {
preload: function(entityID) {
this.entityID = entityID;
this.commChannel = "shortbow-" + Entities.getEntityProperties(entityID, 'parentID').parentID;
Script.addEventHandler(entityID, "collisionWithEntity", this.onCollide.bind(this));
},
signalAC: function() {
print("DBACK start-game sent");
Messages.sendMessage(this.commChannel, JSON.stringify({
type: 'start-game'
}));
},
onCollide: function(entityA, entityB, collision) {
var colliderName = Entities.getEntityProperties(entityB, 'name').name;
if (colliderName.indexOf("projectile") > -1) {
this.signalAC();
}
}
};
StartButton.prototype.startNearTrigger = StartButton.prototype.signalAC;
StartButton.prototype.startFarTrigger = StartButton.prototype.signalAC;
StartButton.prototype.clickDownOnEntity = StartButton.prototype.signalAC;
return new StartButton();
});