content/hifi-content/elisalj/hack_week/feedZebra.js
2022-02-13 23:16:46 +01:00

47 lines
No EOL
1.7 KiB
JavaScript

///
/// feedZebra.js
/// A script to feed the kibble to the zebras
///
/// Author: Elisa Lupin-Jimenez
/// Copyright High Fidelity 2017
///
/// Licensed under the Apache 2.0 License
/// See accompanying license file or http://apache.org/
///
/// All assets are under CC Attribution Non-Commerical
/// http://creativecommons.org/licenses/
///
(function() {
var ALIEN_CHANNEL_BASE = "AlienChannel";
var sound;
this.preload = function(entityID) {
print("loading zebra feeding script");
sound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/liv/dev/emojis/Apple_Bite-Simon_Craggs-1683647397.wav");
};
this.collisionWithEntity = function(kibble, otherObject, collisionInfo) {
var otherProps = Entities.getEntityProperties(otherObject, ["name", "position", "dimensions"]);
if (otherProps.name.indexOf("Alien") !== -1) {
Messages.sendMessage(ALIEN_CHANNEL_BASE, JSON.stringify({type: "HitAlienWithFood", alienID: otherObject}));
Entities.deleteEntity(kibble);
}
if (otherProps.name === "zebra") {
print("kibble is being eaten");
Audio.playSound(sound, { position: otherProps.position, volume: 0.80, loop: false });
Entities.editEntity(otherObject, {dimensions: Vec3.multiply(otherProps.dimensions, 1.1)});
Entities.callEntityMethod(otherObject, "gotTooBig");
Entities.deleteEntity(kibble);
}
if (otherProps.id === MyAvatar.id) {
print("humanz need foodz tooo");
Audio.playSound(sound, { position: otherProps.position, volume: 0.80, loop: false });
Entities.deleteEntity(kibble);
}
};
})