Bläddra i källkod

moved music area to mod

tags/v0.7.0^2
Shaun 4 år sedan
förälder
incheckning
742deb3aeb
4 ändrade filer med 35 tillägg och 558 borttagningar
  1. +3
    -2
      src/client/js/components/sound.js
  2. +28
    -6
      src/client/js/sound/sound.js
  3. +4
    -2
      src/server/components/sound.js
  4. +0
    -548
      src/server/config/maps/fjolarok/map.json

+ 3
- 2
src/client/js/components/sound.js Visa fil

@@ -10,7 +10,7 @@ define([
volume: 0,

init: function () {
const { obj: { zoneId, x, y, width, height, area }, sound, volume, minDistance, fadeInOut } = this;
const { obj: { zoneId, x, y, width, height, area }, sound, volume, minDistance, fadeInOut, defaultMusic } = this;

soundManager.addSoundFromConfig({
scope: zoneId,
@@ -22,7 +22,8 @@ define([
h: height,
area,
minDistance,
fadeInOut
fadeInOut,
defaultMusic
});
}
};


+ 28
- 6
src/client/js/sound/sound.js Visa fil

@@ -59,10 +59,10 @@ define([
},

update: function (playerX, playerY) {
this.sounds.forEach(s => {
this.sounds.forEach((s, i) => {
const { x, y, w, area, sound, minDistance, fadeInOut } = s;

let volume;
let volume = 0;

if (!w) {
let dx = Math.abs(x - playerX);
@@ -87,9 +87,15 @@ define([
let distance = physics.distanceToPolygon([playerX, playerY], area);
if (distance >= minDistance) {
if (sound) {
if (fadeInOut)
if (fadeInOut) {
sound.fade(sound.volume(), 0, 3000);
else

//Start the default audio if default audio is before us in the list and playing
const defaultAudio = this.sounds.find(f => f.defaultMusic);
const defaultAudioBefore = this.sounds.findIndex(f => f === defaultAudio) < i;
if (defaultAudioBefore && defaultAudio.sound)
defaultAudio.sound.fade(defaultAudio.sound.volume(), 0.3 * defaultAudio.volume, 3000);
} else
sound.volume(0);
}
@@ -118,6 +124,21 @@ define([
if (this.muted)
return;

if (s.defaultMusic) {
//Only play if no other music is playing
const musicPlaying = this.sounds.some(f => f.sound && f.fadeInOut && f.sound.playing());
if (musicPlaying)
volume = 0;
else
volume = 1;
} else if (s.fadeInOut) {
//Stop the default audio if default audio is before us in the list and playing
const defaultAudio = this.sounds.find(f => f.defaultMusic);
const defaultAudioBefore = this.sounds.findIndex(f => f === defaultAudio) < i;
if (defaultAudioBefore && defaultAudio.sound && defaultAudio.sound.playing())
defaultAudio.sound.fade(defaultAudio.sound.volume(), 0, 3000);
}

const oldVolume = s.sound.volume();
const newVolume = volume * s.volume;
const volumeChanged = newVolume !== oldVolume;
@@ -135,7 +156,7 @@ define([
this.addSoundFromConfig({ scope, file, volume, x, y, w, h, area });
},

addSoundFromConfig: function ({ scope, file, volume, x, y, w, h, area, minDistance, fadeInOut }) {
addSoundFromConfig: function ({ scope, file, volume, x, y, w, h, area, minDistance, fadeInOut, defaultMusic }) {
if (!area && w) {
area = [
[x, y],
@@ -156,7 +177,8 @@ define([
sound: null,
scope,
minDistance,
fadeInOut
fadeInOut,
defaultMusic
};

this.sounds.push(sound);


+ 4
- 2
src/server/components/sound.js Visa fil

@@ -5,16 +5,18 @@ module.exports = {
volume: 0,
minDistance: 10,
fadeInOut: false,
defaultMusic: false,

simplify: function () {
const { sound, volume, minDistance, fadeInOut } = this;
const { sound, volume, minDistance, fadeInOut, defaultMusic } = this;

return {
type: 'sound',
sound,
volume,
minDistance,
fadeInOut
fadeInOut,
defaultMusic
};
}
};

+ 0
- 548
src/server/config/maps/fjolarok/map.json Visa fil

@@ -1907,554 +1907,6 @@
"width":8,
"x":1056,
"y":920
},
{
"height":0,
"id":993,
"name":"",
"polygon":[
{
"x":0,
"y":0
},
{
"x":0,
"y":112
},
{
"x":-72,
"y":112
},
{
"x":-72,
"y":120
},
{
"x":-80,
"y":120
},
{
"x":-80,
"y":112
},
{
"x":-96,
"y":112
},
{
"x":-96,
"y":128
},
{
"x":-96,
"y":136
},
{
"x":-104,
"y":136
},
{
"x":-104,
"y":144
},
{
"x":-112,
"y":144
},
{
"x":-112,
"y":152
},
{
"x":-168,
"y":152
},
{
"x":-168,
"y":160
},
{
"x":-184,
"y":160
},
{
"x":-184,
"y":168
},
{
"x":-232,
"y":168
},
{
"x":-232,
"y":160
},
{
"x":-256,
"y":160
},
{
"x":-256,
"y":152
},
{
"x":-264,
"y":152
},
{
"x":-264,
"y":144
},
{
"x":-304,
"y":144
},
{
"x":-304,
"y":136
},
{
"x":-328,
"y":136
},
{
"x":-328,
"y":128
},
{
"x":-368,
"y":128
},
{
"x":-368,
"y":120
},
{
"x":-384,
"y":120
},
{
"x":-384,
"y":112
},
{
"x":-392,
"y":112
},
{
"x":-392,
"y":104
},
{
"x":-408,
"y":104
},
{
"x":-408,
"y":80
},
{
"x":-424,
"y":80
},
{
"x":-424,
"y":56
},
{
"x":-432,
"y":56
},
{
"x":-432,
"y":24
},
{
"x":-440,
"y":24
},
{
"x":-440,
"y":-8
},
{
"x":-416,
"y":-8
},
{
"x":-416,
"y":-16
},
{
"x":-408,
"y":-16
},
{
"x":-408,
"y":-24
},
{
"x":-384,
"y":-24
},
{
"x":-384,
"y":-32
},
{
"x":-360,
"y":-32
},
{
"x":-360,
"y":-80
},
{
"x":-368,
"y":-80
},
{
"x":-368,
"y":-88
},
{
"x":-392,
"y":-88
},
{
"x":-392,
"y":-96
},
{
"x":-400,
"y":-96
},
{
"x":-400,
"y":-104
},
{
"x":-584,
"y":-104
},
{
"x":-584,
"y":-216
},
{
"x":0,
"y":-216
}],
"properties":[
{
"name":"cpnSound",
"type":"string",
"value":"{\"sound\":\"server\/mods\/iwd-ui-sounds\/audio\/music\/fjol_town.ogg\",\"volume\":0.5,\"minDistance\":0, \"fadeInOut\": true}"
}],
"rotation":0,
"type":"",
"visible":true,
"width":0,
"x":936,
"y":344
},
{
"height":0,
"id":994,
"name":"",
"polygon":[
{
"x":0,
"y":0
},
{
"x":8,
"y":0
},
{
"x":8,
"y":8
},
{
"x":16,
"y":8
},
{
"x":16,
"y":16
},
{
"x":40,
"y":16
},
{
"x":40,
"y":24
},
{
"x":48,
"y":24
},
{
"x":48,
"y":72
},
{
"x":24,
"y":72
},
{
"x":24,
"y":80
},
{
"x":0,
"y":80
},
{
"x":0,
"y":88
},
{
"x":-8,
"y":88
},
{
"x":-8,
"y":96
},
{
"x":-32,
"y":96
},
{
"x":-32,
"y":128
},
{
"x":-24,
"y":128
},
{
"x":-24,
"y":160
},
{
"x":-16,
"y":160
},
{
"x":-16,
"y":184
},
{
"x":0,
"y":184
},
{
"x":0,
"y":208
},
{
"x":16,
"y":208
},
{
"x":16,
"y":216
},
{
"x":24,
"y":216
},
{
"x":24,
"y":224
},
{
"x":40,
"y":224
},
{
"x":40,
"y":232
},
{
"x":80,
"y":232
},
{
"x":80,
"y":240
},
{
"x":104,
"y":240
},
{
"x":104,
"y":248
},
{
"x":144,
"y":248
},
{
"x":144,
"y":256
},
{
"x":152,
"y":256
},
{
"x":152,
"y":264
},
{
"x":176,
"y":264
},
{
"x":176,
"y":272
},
{
"x":224,
"y":272
},
{
"x":224,
"y":264
},
{
"x":240,
"y":264
},
{
"x":240,
"y":256
},
{
"x":296,
"y":256
},
{
"x":296,
"y":248
},
{
"x":304,
"y":248
},
{
"x":304,
"y":240
},
{
"x":312,
"y":240
},
{
"x":312,
"y":216
},
{
"x":328,
"y":216
},
{
"x":328,
"y":224
},
{
"x":336,
"y":224
},
{
"x":336,
"y":216
},
{
"x":408,
"y":216
},
{
"x":408,
"y":-112
},
{
"x":592,
"y":-232
},
{
"x":1024,
"y":-232
},
{
"x":1024,
"y":368
},
{
"x":1024,
"y":1192
},
{
"x":1024,
"y":1264
},
{
"x":856,
"y":1264
},
{
"x":472,
"y":1264
},
{
"x":152,
"y":1264
},
{
"x":-256,
"y":1256
},
{
"x":-424,
"y":1048
},
{
"x":-360,
"y":752
},
{
"x":-152,
"y":536
},
{
"x":-168,
"y":376
},
{
"x":-184,
"y":48
},
{
"x":-64,
"y":8
}],
"properties":[
{
"name":"cpnSound",
"type":"string",
"value":"{\"sound\":\"server\/mods\/iwd-ui-sounds\/audio\/music\/fjol_wild.ogg\",\"volume\":0.5,\"minDistance\":0, \"fadeInOut\": true}"
}],
"rotation":0,
"type":"",
"visible":true,
"width":0,
"x":528,
"y":240
}],
"opacity":1,
"type":"objectgroup",


Laddar…
Avbryt
Spara