end handshake when successful, stop handshake sound if other guy pulls out

This commit is contained in:
David Kelly 2017-03-22 14:55:57 -07:00
parent 34a89e4b9a
commit 020dcca78d

View file

@ -212,6 +212,12 @@ function deleteMakeConnectionParticleEffect() {
} }
} }
function stopHandshakeSound() {
if (handshakeInjector) {
handshakeInjector.stop();
}
}
function calcParticlePos(myHand, otherHand, otherOrientation, reset) { function calcParticlePos(myHand, otherHand, otherOrientation, reset) {
if (reset) { if (reset) {
particleRotationAngle = 0.0; particleRotationAngle = 0.0;
@ -234,6 +240,7 @@ function updateVisualization() {
if (state == STATES.inactive) { if (state == STATES.inactive) {
deleteParticleEffect(); deleteParticleEffect();
deleteMakeConnectionParticleEffect(); deleteMakeConnectionParticleEffect();
stopHandshakeSound();
return; return;
} }
@ -255,6 +262,7 @@ function updateVisualization() {
// no visualization while waiting // no visualization while waiting
deleteParticleEffect(); deleteParticleEffect();
deleteMakeConnectionParticleEffect(); deleteMakeConnectionParticleEffect();
stopHandshakeSound();
break; break;
case STATES.connecting: case STATES.connecting:
var particleProps = {}; var particleProps = {};
@ -478,15 +486,13 @@ function makeConnection(id) {
// now that we made connection, reset everything // now that we made connection, reset everything
makingFriendsTimeout = Script.setTimeout(function () { makingFriendsTimeout = Script.setTimeout(function () {
connectingId = undefined;
connectingHand = undefined;
makingConnectionTimeout = undefined;
if (!successfulHandshakeInjector) { if (!successfulHandshakeInjector) {
successfulHandshakeInjector = Audio.playSound(successfulHandshakeSound, {position: getHandPosition(MyAvatar, currentHand), volume: 0.5, localOnly: true}); successfulHandshakeInjector = Audio.playSound(successfulHandshakeSound, {position: getHandPosition(MyAvatar, currentHand), volume: 0.5, localOnly: true});
} else { } else {
successfulHandshakeInjector.restart(); successfulHandshakeInjector.restart();
} }
Controller.triggerHapticPulse(HAPTIC_DATA.success.strength, HAPTIC_DATA.success.duration, handToHaptic(currentHand)); Controller.triggerHapticPulse(HAPTIC_DATA.success.strength, HAPTIC_DATA.success.duration, handToHaptic(currentHand));
endHandshake();
}, MAKING_CONNECTION_TIMEOUT); }, MAKING_CONNECTION_TIMEOUT);
} }