mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 13:49:23 +02:00
Small amounts of cleanup - added Smoke effect when Ball is Hit by Arrow
This commit is contained in:
parent
26446b6b33
commit
135beb2d48
4 changed files with 45 additions and 14 deletions
|
@ -102,8 +102,7 @@ function getControllerLocation(controllerHand) {
|
||||||
const SHOOT_ARROW_SOUND_URL = Script.resolvePath('String_release2.L.wav');
|
const SHOOT_ARROW_SOUND_URL = Script.resolvePath('String_release2.L.wav');
|
||||||
const STRING_PULL_SOUND_URL = Script.resolvePath('Bow_draw.1.L.wav');
|
const STRING_PULL_SOUND_URL = Script.resolvePath('Bow_draw.1.L.wav');
|
||||||
const ARROW_HIT_SOUND_URL = Script.resolvePath('Arrow_impact1.L.wav');
|
const ARROW_HIT_SOUND_URL = Script.resolvePath('Arrow_impact1.L.wav');
|
||||||
const SMOKE_URL = Script.resolvePath('smoke.png');
|
|
||||||
|
|
||||||
const ARROW_MODEL_URL = Script.resolvePath('arrow.fbx');
|
const ARROW_MODEL_URL = Script.resolvePath('arrow.fbx');
|
||||||
const ARROW_DIMENSIONS = {
|
const ARROW_DIMENSIONS = {
|
||||||
x: 0.20,
|
x: 0.20,
|
||||||
|
@ -387,14 +386,8 @@ function getControllerLocation(controllerHand) {
|
||||||
Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick);
|
Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick);
|
||||||
};
|
};
|
||||||
|
|
||||||
var makeBallGoPoof = function(entityA, entityB, collision) {
|
|
||||||
print("Entity hit: " + entityB);
|
|
||||||
Script.removeEventHandler(arrow, "collisionWithEntity", makeBallGoPoof);
|
|
||||||
});
|
|
||||||
|
|
||||||
Script.addEventHandler(arrow, "collisionWithEntity", makeArrowStick);
|
Script.addEventHandler(arrow, "collisionWithEntity", makeArrowStick);
|
||||||
Script.addEventHandler(arrow, "collisionWithEntity", makeBallGoPoof);
|
|
||||||
|
|
||||||
return arrow;
|
return arrow;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -627,7 +620,6 @@ function getControllerLocation(controllerHand) {
|
||||||
Audio.playSound(this.arrowNotchSound, audioProperties);
|
Audio.playSound(this.arrowNotchSound, audioProperties);
|
||||||
},
|
},
|
||||||
|
|
||||||
// This function isn't used anymore.
|
|
||||||
changeStringPullSoundVolume: function(pullBackDistance) {
|
changeStringPullSoundVolume: function(pullBackDistance) {
|
||||||
var audioProperties = {
|
var audioProperties = {
|
||||||
volume: this.scaleSoundVolume(pullBackDistance),
|
volume: this.scaleSoundVolume(pullBackDistance),
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 1.9 MiB |
|
@ -38,13 +38,50 @@
|
||||||
this.entityIDsThatHaveCollidedWithMe.push(entityB);
|
this.entityIDsThatHaveCollidedWithMe.push(entityB);
|
||||||
|
|
||||||
var colliderName = Entities.getEntityProperties(entityB, 'name').name;
|
var colliderName = Entities.getEntityProperties(entityB, 'name').name;
|
||||||
|
|
||||||
if (colliderName.indexOf("projectile") > -1) {
|
if (colliderName.indexOf("projectile") > -1) {
|
||||||
|
var smokeImage = {
|
||||||
|
accelerationSpread: { x: 0, y: 0, z: 0 },
|
||||||
|
alpha: 1,
|
||||||
|
alphaFinish: 0,
|
||||||
|
alphaSpread: 0,
|
||||||
|
alphaStart: 0.3,
|
||||||
|
azimuthFinish: 3.1,
|
||||||
|
azimuthStart: -3.14159,
|
||||||
|
color: { red: 255, green: 255, blue: 255 },
|
||||||
|
colorFinish: { red: 255, green: 255, blue: 255 },
|
||||||
|
colorSpread: { red: 0, green: 0, blue: 0 },
|
||||||
|
colorStart: { red: 255, green: 255, blue: 255 },
|
||||||
|
emitAcceleration: { x: 0, y: 0, z: 0 },
|
||||||
|
emitDimensions: { x: 0, y: 0, z: 0 },
|
||||||
|
emitOrientation: { x: -0.7, y: 0.0, z: 0.0, w: 0.7 },
|
||||||
|
emitRate: 0.01,
|
||||||
|
emitSpeed: 0,
|
||||||
|
emitterShouldTrail: 0,
|
||||||
|
isEmitting: 1,
|
||||||
|
lifespan: 0.5,
|
||||||
|
lifetime: 0.5,
|
||||||
|
maxParticles: 1000,
|
||||||
|
name: 'ball-hit-smoke',
|
||||||
|
position: Entities.getEntityProperties(entityA, 'position').position,
|
||||||
|
particleRadius: 0.132,
|
||||||
|
polarFinish: 0,
|
||||||
|
polarStart: 0,
|
||||||
|
radiusFinish: 0.35,
|
||||||
|
radiusSpread: 0,
|
||||||
|
radiusStart: 0.132,
|
||||||
|
speedSpread: 0,
|
||||||
|
textures: Script.resolvePath('bow/smoke.png'),
|
||||||
|
type: 'ParticleEffect'
|
||||||
|
};
|
||||||
|
|
||||||
|
Entities.addEntity(smokeImage);
|
||||||
|
|
||||||
Messages.sendMessage(this.gameChannel, JSON.stringify({
|
Messages.sendMessage(this.gameChannel, JSON.stringify({
|
||||||
type: "enemy-killed",
|
type: "enemy-killed",
|
||||||
entityID: this.entityID,
|
entityID: this.entityID,
|
||||||
position: Entities.getEntityProperties(this.entityID, 'position').position
|
position: Entities.getEntityProperties(this.entityID, 'position').position
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Entities.deleteEntity(this.entityID);
|
Entities.deleteEntity(this.entityID);
|
||||||
} else if (colliderName.indexOf("GateCollider") > -1) {
|
} else if (colliderName.indexOf("GateCollider") > -1) {
|
||||||
Messages.sendMessage(this.gameChannel, JSON.stringify({
|
Messages.sendMessage(this.gameChannel, JSON.stringify({
|
||||||
|
|
|
@ -468,6 +468,7 @@ ShortbowGameManager.prototype = {
|
||||||
volume: 1.0,
|
volume: 1.0,
|
||||||
position: this.rootPosition
|
position: this.rootPosition
|
||||||
});
|
});
|
||||||
|
print("CAINK - BALL KILLED");
|
||||||
this.setScore(this.score + POINTS_PER_KILL);
|
this.setScore(this.score + POINTS_PER_KILL);
|
||||||
enemiesEscaped = true;
|
enemiesEscaped = true;
|
||||||
}
|
}
|
||||||
|
@ -561,10 +562,11 @@ ShortbowGameManager.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onEnemyKilled: function(entityID, position) {
|
onEnemyKilled: function(entityID, position) {
|
||||||
if (this.gameState !== GAME_STATES.PLAYING) {
|
|
||||||
|
if (this.gameState !== GAME_STATES.PLAYING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = this.remainingEnemies.length - 1; i >= 0; --i) {
|
for (var i = this.remainingEnemies.length - 1; i >= 0; --i) {
|
||||||
var enemy = this.remainingEnemies[i];
|
var enemy = this.remainingEnemies[i];
|
||||||
if (enemy.id === entityID) {
|
if (enemy.id === entityID) {
|
||||||
|
@ -573,7 +575,6 @@ ShortbowGameManager.prototype = {
|
||||||
volume: 1.0,
|
volume: 1.0,
|
||||||
position: this.rootPosition
|
position: this.rootPosition
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update score
|
// Update score
|
||||||
this.setScore(this.score + POINTS_PER_KILL);
|
this.setScore(this.score + POINTS_PER_KILL);
|
||||||
print("SCORE: ", this.score);
|
print("SCORE: ", this.score);
|
||||||
|
@ -592,6 +593,7 @@ ShortbowGameManager.prototype = {
|
||||||
for (var i = this.remainingEnemies.length - 1; i >= 0; --i) {
|
for (var i = this.remainingEnemies.length - 1; i >= 0; --i) {
|
||||||
var enemy = this.remainingEnemies[i];
|
var enemy = this.remainingEnemies[i];
|
||||||
if (enemy.id === entityID) {
|
if (enemy.id === entityID) {
|
||||||
|
|
||||||
Entities.deleteEntity(enemy.id);
|
Entities.deleteEntity(enemy.id);
|
||||||
this.remainingEnemies.splice(i, 1);
|
this.remainingEnemies.splice(i, 1);
|
||||||
this.setLivesLeft(this.livesLeft - 1);
|
this.setLivesLeft(this.livesLeft - 1);
|
||||||
|
|
Loading…
Reference in a new issue