61 lines
No EOL
2.3 KiB
JavaScript
61 lines
No EOL
2.3 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 DEFAULT_SIZE = {"x": 0.5444, "y": 0.8658, "z": 0.8925};
|
|
var BITE_SOUND;
|
|
var ZEBRA_SOUND;
|
|
|
|
this.preload = function(entityID) {
|
|
BITE_SOUND = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/liv/dev/emojis/Apple_Bite-Simon_Craggs-1683647397.wav");
|
|
ZEBRA_SOUND = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/elisalj/hack_week/zebra-sounds/zebra5.wav");
|
|
};
|
|
|
|
var gotTooBig = function(zebraProps) {
|
|
print("oh no zebra is too full");
|
|
Audio.playSound(ZEBRA_SOUND, { position: zebraProps.position, volume: 0.80, loop: false });
|
|
zebraProps.dimensions = DEFAULT_SIZE;
|
|
Entities.editEntity(zebraProps.id, zebraProps);
|
|
};
|
|
|
|
this.collisionWithEntity = function(kibble, otherObject, collisionInfo) {
|
|
var otherProps = Entities.getEntityProperties(otherObject, ["name", "id", "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 consumed");
|
|
print("zebra is currently: " + otherProps.dimensions.x);
|
|
Audio.playSound(BITE_SOUND, { position: otherProps.position, volume: 0.80, loop: false });
|
|
if (otherProps.dimensions.x > 1) {
|
|
gotTooBig(otherProps);
|
|
} else {
|
|
Entities.editEntity(otherObject, {dimensions: Vec3.multiply(otherProps.dimensions, 1.1)});
|
|
}
|
|
Entities.deleteEntity(kibble);
|
|
|
|
}
|
|
if (otherProps.id === MyAvatar.id) {
|
|
print("humanz need foodz tooo");
|
|
Audio.playSound(BITE_SOUND, { position: otherProps.position, volume: 0.80, loop: false });
|
|
Entities.deleteEntity(kibble);
|
|
}
|
|
};
|
|
|
|
|
|
}); |