mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:08:51 +02:00
Fix coding standard issues
This commit is contained in:
parent
f1ab013511
commit
7f8f870d9f
1 changed files with 21 additions and 19 deletions
|
@ -10,7 +10,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
var RED_BALLOON_URL = Script.resolvePath("../Models/redBalloon.fbx");
|
var RED_BALLOON_URL = Script.resolvePath("../Models/redBalloon.fbx");
|
||||||
var BLUE_BALLOON_URL = Script.resolvePath("../Models/blueBalloon.fbx");
|
var BLUE_BALLOON_URL = Script.resolvePath("../Models/blueBalloon.fbx");
|
||||||
var GREEN_BALLOON_URL = Script.resolvePath("../Models/greenBalloon.fbx");
|
var GREEN_BALLOON_URL = Script.resolvePath("../Models/greenBalloon.fbx");
|
||||||
|
@ -27,6 +27,9 @@
|
||||||
|
|
||||||
var NUM_COLORS = 7;
|
var NUM_COLORS = 7;
|
||||||
var COUNTDOWN_SECONDS = 9;
|
var COUNTDOWN_SECONDS = 9;
|
||||||
|
//Lowering the spawn rate below 10 spawns so many balloons that the interface slows down
|
||||||
|
var MIN_SPAWN_RATE = 10;
|
||||||
|
var MILLISECONDS_IN_SECOND = 1000;
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var spawnRate = 2000;
|
var spawnRate = 2000;
|
||||||
|
@ -40,13 +43,12 @@
|
||||||
var spawnMusic;
|
var spawnMusic;
|
||||||
var countdownIntervalID;
|
var countdownIntervalID;
|
||||||
var countdownEntityID;
|
var countdownEntityID;
|
||||||
|
|
||||||
|
|
||||||
_this.preload = function(pEntityID) {
|
_this.preload = function (pEntityID) {
|
||||||
var parentProperties = Entities.getEntityProperties(pEntityID, ["userData"]),
|
var parentProperties = Entities.getEntityProperties(pEntityID, ["userData"]),
|
||||||
spawnMusicURL,
|
spawnMusicURL,
|
||||||
spawnerSettings;
|
spawnerSettings;
|
||||||
if (parentProperties.userData){
|
if (parentProperties.userData) {
|
||||||
spawnerSettings = JSON.parse(parentProperties.userData);
|
spawnerSettings = JSON.parse(parentProperties.userData);
|
||||||
}
|
}
|
||||||
spawnMusicURL = spawnerSettings.spawnMusicURL ? spawnerSettings.spawnMusicURL : SPAWN_MUSIC_URL;
|
spawnMusicURL = spawnerSettings.spawnMusicURL ? spawnerSettings.spawnMusicURL : SPAWN_MUSIC_URL;
|
||||||
|
@ -55,7 +57,7 @@
|
||||||
_this.startCountdown(pEntityID);
|
_this.startCountdown(pEntityID);
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.startCountdown = function(pEntityID) {
|
_this.startCountdown = function (pEntityID) {
|
||||||
var countdownSeconds = COUNTDOWN_SECONDS,
|
var countdownSeconds = COUNTDOWN_SECONDS,
|
||||||
parentProperties = Entities.getEntityProperties(pEntityID, ["position"]),
|
parentProperties = Entities.getEntityProperties(pEntityID, ["position"]),
|
||||||
countdownEntityProperties;
|
countdownEntityProperties;
|
||||||
|
@ -98,13 +100,13 @@
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.spawnBalloons = function(pEntityID) {
|
_this.spawnBalloons = function (pEntityID) {
|
||||||
var parentProperties = Entities.getEntityProperties(pEntityID, ["position", "userData"]),
|
var parentProperties = Entities.getEntityProperties(pEntityID, ["position", "userData"]),
|
||||||
spawnerSettings,
|
spawnerSettings,
|
||||||
spawnMusicVolume,
|
spawnMusicVolume,
|
||||||
spawnCount = 0;
|
spawnCount = 0;
|
||||||
|
|
||||||
if (parentProperties.userData){
|
if (parentProperties.userData) {
|
||||||
spawnerSettings = JSON.parse(parentProperties.userData);
|
spawnerSettings = JSON.parse(parentProperties.userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,12 +118,12 @@
|
||||||
spawnRate = !isNaN(spawnerSettings.spawnRate) ? spawnerSettings.spawnRate : spawnRate;
|
spawnRate = !isNaN(spawnerSettings.spawnRate) ? spawnerSettings.spawnRate : spawnRate;
|
||||||
spawnMusicVolume = !isNaN(spawnerSettings.spawnMusicVolume) ? spawnerSettings.spawnMusicVolume : 0.1;
|
spawnMusicVolume = !isNaN(spawnerSettings.spawnMusicVolume) ? spawnerSettings.spawnMusicVolume : 0.1;
|
||||||
|
|
||||||
if (spawnRate < 10){
|
if (spawnRate < MIN_SPAWN_RATE) {
|
||||||
spawnRate = 10;
|
spawnRate = MIN_SPAWN_RATE;
|
||||||
print("The lowest balloon spawn rate allowed is 10.");
|
print("The lowest balloon spawn rate allowed is " + MIN_SPAWN_RATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spawnMusic.downloaded){
|
if (spawnMusic.downloaded) {
|
||||||
musicInjector = Audio.playSound(spawnMusic, {
|
musicInjector = Audio.playSound(spawnMusic, {
|
||||||
position: parentProperties.position,
|
position: parentProperties.position,
|
||||||
volume: spawnMusicVolume,
|
volume: spawnMusicVolume,
|
||||||
|
@ -129,7 +131,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnIntervalID = Script.setInterval(function() {
|
spawnIntervalID = Script.setInterval(function () {
|
||||||
var colorID = Math.floor(Math.random() * NUM_COLORS),
|
var colorID = Math.floor(Math.random() * NUM_COLORS),
|
||||||
color = BALLOON_COLORS[colorID],
|
color = BALLOON_COLORS[colorID],
|
||||||
balloonURL = BALLOON_URLS[colorID],
|
balloonURL = BALLOON_URLS[colorID],
|
||||||
|
@ -190,31 +192,31 @@
|
||||||
Entities.addEntity(balloonProperties);
|
Entities.addEntity(balloonProperties);
|
||||||
|
|
||||||
//Clean up after spawnDuration
|
//Clean up after spawnDuration
|
||||||
if (spawnCount * spawnRate / 1000 > spawnDuration){
|
if (spawnCount * spawnRate / MILLISECONDS_IN_SECOND > spawnDuration) {
|
||||||
_this.cleanUp(pEntityID);
|
_this.cleanUp(pEntityID);
|
||||||
}
|
}
|
||||||
}, spawnRate);
|
}, spawnRate);
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.unload = function(){
|
_this.unload = function () {
|
||||||
_this.cleanUp();
|
_this.cleanUp();
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.cleanUp = function(pEntityID) {
|
_this.cleanUp = function (pEntityID) {
|
||||||
if (spawnIntervalID){
|
if (spawnIntervalID ) {
|
||||||
Script.clearInterval(spawnIntervalID);
|
Script.clearInterval(spawnIntervalID);
|
||||||
}
|
}
|
||||||
if (countdownIntervalID){
|
if (countdownIntervalID) {
|
||||||
Script.clearInterval(countdownIntervalID);
|
Script.clearInterval(countdownIntervalID);
|
||||||
}
|
}
|
||||||
if (countdownEntityID){
|
if (countdownEntityID) {
|
||||||
Entities.deleteEntity(countdownEntityID);
|
Entities.deleteEntity(countdownEntityID);
|
||||||
}
|
}
|
||||||
if (musicInjector !== undefined && musicInjector.isPlaying) {
|
if (musicInjector !== undefined && musicInjector.isPlaying) {
|
||||||
musicInjector.stop();
|
musicInjector.stop();
|
||||||
musicInjector = undefined;
|
musicInjector = undefined;
|
||||||
}
|
}
|
||||||
if (pEntityID){
|
if (pEntityID) {
|
||||||
Entities.deleteEntity(pEntityID);
|
Entities.deleteEntity(pEntityID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue