// // Carrot Server.js // // Team 8 Hifi Hackathon 2018 // Chang Kayla Sam Lab // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // /* globals Entities */ (function() { var _entityID; var triggered = false; var Carrot = function() { }; Carrot.prototype = { remotelyCallable: ['triggerCarrot'], preload: function(entityID) { _entityID = entityID; }, triggerCarrot: function(senderID, params) { var playerUUID = params[0]; print("received a triggerCarrot!!! from " + playerUUID) /* Can t guarantee that we don;t have a cheater .... var position = Entities.getEntityProperties(_entityID, 'position').position; var avatarsInRange = AvatarList.getAvatarsInRange(position, 1.0); print("Avatars in range are: " + JSON.stringify(avatarsInRange)) */ if (triggered === false) { triggered = true; Entities.callEntityClientMethod(playerUUID, _entityID, 'triggerWin'); } else { Entities.callEntityClientMethod(playerUUID, _entityID, 'triggerMiss'); } } }; return new Carrot(); });