Makes singleton variable name of NotificationCenter lowercase

When we require a singleton, its instance name should be named
by lowercase, since it is not a class.

Relates to #128
This commit is contained in:
logsol 2016-10-10 22:11:55 +02:00
parent ffc55a204a
commit 3cb2e39a18
57 changed files with 262 additions and 262 deletions

View file

@ -7,7 +7,7 @@
"Game/Config/Settings"
],
function (GameController, Nc, User, ProtocolHelper, Options, Settings) {
function (GameController, nc, User, ProtocolHelper, Options, Settings) {
"use strict";
@ -26,14 +26,14 @@
});
// Notification Center
Nc.on(Nc.ns.channel.events.round.end, this.onEndRound, this);
Nc.on(Nc.ns.channel.events.controlCommand.channel, function (message) {
nc.on(nc.ns.channel.events.round.end, this.onEndRound, this);
nc.on(nc.ns.channel.events.controlCommand.channel, function (message) {
ProtocolHelper.applyCommand(message.data, self);
});
Nc.on(Nc.ns.channel.to.client.gameCommand.broadcast, this.broadcastGameCommand, this);
Nc.on(Nc.ns.channel.to.client.controlCommand.broadcast, this.broadcastControlCommand, this);
//Nc.on(Nc.ns.channel.to.client.gameCommand.broadcastExcept, this.broadcastGameCommandExcept, this);
//Nc.on(Nc.ns.channel.to.client.controlCommand.broadcastExcept, this.broadcastControlCommandExcept, this);
nc.on(nc.ns.channel.to.client.gameCommand.broadcast, this.broadcastGameCommand, this);
nc.on(nc.ns.channel.to.client.controlCommand.broadcast, this.broadcastControlCommand, this);
//nc.on(nc.ns.channel.to.client.gameCommand.broadcastExcept, this.broadcastGameCommandExcept, this);
//nc.on(nc.ns.channel.to.client.controlCommand.broadcastExcept, this.broadcastControlCommandExcept, this);
this.beginRound();
@ -103,10 +103,10 @@
};
if(!this.gameController.level || !this.gameController.level.isLoaded) {
var token = Nc.on(Nc.ns.core.game.events.level.loaded, function() {
var token = nc.on(nc.ns.core.game.events.level.loaded, function() {
self.sendJoinSuccess(options);
self.users[options.id].sendControlCommand("beginRound", clientGameControllerOptions);
Nc.off(token);
nc.off(token);
});
} else {
this.sendJoinSuccess(options);
@ -135,16 +135,16 @@
levelUid: levelUid
};
//Nc.trigger("user/" + user.id + "/joinSuccess", options);
//nc.trigger("user/" + user.id + "/joinSuccess", options);
user.sendControlCommand("joinSuccess", options);
Nc.trigger(Nc.ns.channel.events.user.joined, user);
nc.trigger(nc.ns.channel.events.user.joined, user);
this.broadcastControlCommandExcept("userJoined", user.options, user);
};
Channel.prototype.onReleaseUser = function (userId) {
var self = this;
Nc.trigger(Nc.ns.channel.events.user.left, userId);
nc.trigger(nc.ns.channel.events.user.left, userId);
delete this.users[userId];
this.broadcastControlCommand("userLeft", userId);

View file

@ -5,7 +5,7 @@ define([
"Game/Config/Settings"
],
function(Parent, Nc, Parser, Settings) {
function(Parent, nc, Parser, Settings) {
"use strict";
@ -71,7 +71,7 @@ function(Parent, Nc, Parser, Settings) {
lv: body.GetLinearVelocity()
};
Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + this.player.id, "positionStateReset", options);
nc.trigger(nc.ns.channel.to.client.user.gameCommand.send + this.player.id, "positionStateReset", options);
}
};

View file

@ -11,7 +11,7 @@ define([
"Game/Channel/GameObjects/Items/RubeDoll"
],
function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player, GameObject, Doll, RubeDoll) {
function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player, GameObject, Doll, RubeDoll) {
"use strict";
@ -25,12 +25,12 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
Parent.call(this, options);
this.ncTokens = this.ncTokens.concat([
Nc.on(Nc.ns.channel.events.user.joined, this.onUserJoined, this),
Nc.on(Nc.ns.channel.events.user.left, this.onUserLeft, this),
Nc.on(Nc.ns.channel.events.user.level.reset, this.onResetLevel, this),
Nc.on(Nc.ns.channel.events.user.client.ready, this.onClientReady, this),
Nc.on(Nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this),
Nc.on(Nc.ns.channel.events.game.player.killed, this.onPlayerKilled, this),
nc.on(nc.ns.channel.events.user.joined, this.onUserJoined, this),
nc.on(nc.ns.channel.events.user.left, this.onUserLeft, this),
nc.on(nc.ns.channel.events.user.level.reset, this.onResetLevel, this),
nc.on(nc.ns.channel.events.user.client.ready, this.onClientReady, this),
nc.on(nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this),
nc.on(nc.ns.channel.events.game.player.killed, this.onPlayerKilled, this),
]);
console.checkpoint('starting game controller for channel (' + options.channelName + ')');
@ -65,7 +65,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
};
GameController.prototype.clearItemsOfPlayerFingerPrints = function(player) {
Nc.trigger(Nc.ns.channel.events.game.player.clearFingerPrints, player);
nc.trigger(nc.ns.channel.events.game.player.clearFingerPrints, player);
};
GameController.prototype.createPlayer = function(user) {
@ -79,7 +79,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
GameController.prototype.onPlayerKilled = function(player, killedByPlayer) {
if(killedByPlayer.stats.score >= this.options.scoreLimit) {
Nc.trigger(Nc.ns.channel.events.round.end);
nc.trigger(nc.ns.channel.events.round.end);
} else {
this.spawnPlayer(player, Settings.RESPAWN_TIME);
}
@ -102,7 +102,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
y: spawnPoint.y
};
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "spawnPlayer", options);
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "spawnPlayer", options);
var i = self.spawnTimeouts.indexOf(spawnTimeout);
self.spawnTimeouts.splice(i, 1);
@ -117,7 +117,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
var update = this.getWorldUpdateObject(false);
if(Object.getOwnPropertyNames(update).length > 0) {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "worldUpdate", update);
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "worldUpdate", update);
}
this.worldUpdateTimeout = setTimeout(this.updateWorld.bind(this), Settings.NETWORK_UPDATE_INTERVAL);
@ -232,7 +232,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
userId: userId
};
Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + userId, "clientReadyResponse", options);
nc.trigger(nc.ns.channel.to.client.user.gameCommand.send + userId, "clientReadyResponse", options);
this.spawnPlayer(player, 0);
};
@ -255,7 +255,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, Nc, Box2D, Player,
console.log('OH NO!!! ON RESET LEVEL IS CALLED AND RESPAWNES PLAYERS');
Parent.prototype.onResetLevel.call(this);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "resetLevel", true);
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "resetLevel", true);
for (var key in this.players) {
this.spawnPlayer(this.players[key]);
}

View file

@ -6,7 +6,7 @@ define([
"Lib/Utilities/Assert"
],
function (Parent, Item, Box2D, Nc, Assert) {
function (Parent, Item, Box2D, nc, Assert) {
"use strict";
@ -80,7 +80,7 @@ function (Parent, Item, Box2D, Nc, Assert) {
self.player.addDamage(damage, lastMovedPlayer, item);
};
Nc.trigger(Nc.ns.channel.engine.worldQueue.add, callback);
nc.trigger(nc.ns.channel.engine.worldQueue.add, callback);
}
}

View file

@ -3,7 +3,7 @@ define([
"Lib/Utilities/NotificationCenter",
],
function (Parent, Nc) {
function (Parent, nc) {
"use strict";
@ -13,7 +13,7 @@ function (Parent, Nc) {
this.lastMoved = null;
this.ncTokens = (this.ncTokens || []).concat([
Nc.on(Nc.ns.channel.events.game.player.clearFingerPrints, this.clearOfPlayerFingerPrints, this)
nc.on(nc.ns.channel.events.game.player.clearFingerPrints, this.clearOfPlayerFingerPrints, this)
]);
}

View file

@ -4,7 +4,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, Settings, Nc) {
function (Parent, Settings, nc) {
"use strict";
@ -35,7 +35,7 @@ function (Parent, Settings, Nc) {
var self = this;
this.scheduledForDestruction = true;
this.destructionTimeout = setTimeout(function() {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
type: 'animated',
uid: self.uid
});

View file

@ -4,7 +4,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, Settings, Nc) {
function (Parent, Settings, nc) {
"use strict";
@ -35,7 +35,7 @@ function (Parent, Settings, Nc) {
var self = this;
this.scheduledForDestruction = true;
this.destructionTimeout = setTimeout(function() {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, 'removeGameObject', {
type: 'animated',
uid: self.uid
});

View file

@ -5,7 +5,7 @@ define([
"fs"
],
function (Nc, Channel, Settings, fs) {
function (nc, Channel, Settings, fs) {
"use strict";
@ -14,7 +14,7 @@ function (Nc, Channel, Settings, fs) {
this.process = process;
this.recordingFileName = null;
Nc.on(Nc.ns.channel.to.server.controlCommand.send, this.send, this);
nc.on(nc.ns.channel.to.server.controlCommand.send, this.send, this);
process.on("message", this.onProcessMessage.bind(this));
}
@ -82,10 +82,10 @@ function (Nc, Channel, Settings, fs) {
PipeToServer.prototype.onMessage = function (message) {
switch(message.recipient) {
case "channel":
Nc.trigger(Nc.ns.channel.events.controlCommand.channel, message);
nc.trigger(nc.ns.channel.events.controlCommand.channel, message);
break;
default:
Nc.trigger(Nc.ns.channel.events.controlCommand.user + message.recipient, message);
nc.trigger(nc.ns.channel.events.controlCommand.user + message.recipient, message);
break;
}

View file

@ -4,7 +4,7 @@ define([
"Game/Channel/Control/PlayerController"
],
function (Parent, Nc, PlayerController) {
function (Parent, nc, PlayerController) {
"use strict";
@ -44,7 +44,7 @@ function (Parent, Nc, PlayerController) {
this.throw(options, item);
options.action = "throw";
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
}
} else {
// grab
@ -52,7 +52,7 @@ function (Parent, Nc, PlayerController) {
this.grab(item);
options.action = "grab";
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "handActionResponse", options);
}
}
};
@ -93,14 +93,14 @@ function (Parent, Nc, PlayerController) {
var ragDollId = this.stats.deaths;
Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
playerId: this.id,
killedByPlayerId: killedByPlayer.id,
ragDollId: ragDollId,
item: byItem ? byItem.options.name : "Suicide"
});
Nc.trigger(Nc.ns.channel.events.game.player.killed, this, killedByPlayer); // sends endround
nc.trigger(nc.ns.channel.events.game.player.killed, this, killedByPlayer); // sends endround
if(this.ragDoll) {
this.ragDoll.delayedDestroy();
@ -112,13 +112,13 @@ function (Parent, Nc, PlayerController) {
};
Player.prototype.broadcastStats = function(enemy) {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
playerId: this.id,
stats: this.stats
});
if(enemy && enemy != this) {
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "updateStats", {
playerId: enemy.id,
stats: enemy.stats
});

View file

@ -5,7 +5,7 @@ define([
"Lib/Utilities/Protocol/Parser",
],
function(Parent, Nc, ProtocolHelper, ProtocolParser) {
function(Parent, nc, ProtocolHelper, ProtocolParser) {
function User(id, options) {
Parent.call(this, id, options);
@ -14,15 +14,15 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
this.isReady = false;
var self = this;
Nc.on(Nc.ns.channel.to.client.user.controlCommand.joinSuccess + this.id, function(options) {
nc.on(nc.ns.channel.to.client.user.controlCommand.joinSuccess + this.id, function(options) {
self.sendControlCommand("joinSuccess", options);
});
Nc.on(Nc.ns.channel.events.controlCommand.user + this.id, function(message) {
nc.on(nc.ns.channel.events.controlCommand.user + this.id, function(message) {
ProtocolHelper.applyCommand(message.data, self);
});
Nc.on(Nc.ns.channel.to.client.user.gameCommand.send + this.id, function(command, options) {
nc.on(nc.ns.channel.to.client.user.gameCommand.send + this.id, function(command, options) {
self.sendGameCommand(command, options);
});
@ -44,10 +44,10 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
} // FIXME: move this to Protocol helper as a function
if(command.hasOwnProperty("resetLevel")) {
Nc.trigger(Nc.ns.channel.events.user.level.reset, this.id);
nc.trigger(nc.ns.channel.events.user.level.reset, this.id);
} else if(command.hasOwnProperty("clientReady")) {
this.isReady = true;
Nc.trigger(Nc.ns.channel.events.user.client.ready, this.id);
nc.trigger(nc.ns.channel.events.user.client.ready, this.id);
} else {
this.player.playerController.applyCommand(command);
}
@ -71,7 +71,7 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
this.isReady = false;
}
Nc.trigger(Nc.ns.channel.to.server.controlCommand.send, recipient, data);
nc.trigger(nc.ns.channel.to.server.controlCommand.send, recipient, data);
};
User.prototype.sendGameCommand = function(command, options) {