NC refactoring

This commit is contained in:
Jeena 2014-03-17 21:45:40 +01:00
parent 28f71f49e1
commit 96bf9bffbd
24 changed files with 69 additions and 69 deletions

View file

@ -50,7 +50,7 @@
var self = this; var self = this;
if(!this.gameController.level || !this.gameController.level.isLoaded) { if(!this.gameController.level || !this.gameController.level.isLoaded) {
var token = Nc.on("game/level/loaded", function() { var token = Nc.on(Nc.ns.core.game.events.level.loaded, function() {
self.sendJoinSuccess(options); self.sendJoinSuccess(options);
Nc.off(token); Nc.off(token);
}); });
@ -82,14 +82,14 @@
//Nc.trigger('user/' + user.id + "/joinSuccess", options); //Nc.trigger('user/' + user.id + "/joinSuccess", options);
user.sendControlCommand("joinSuccess", options); user.sendControlCommand("joinSuccess", options);
Nc.trigger('user/joined', user); Nc.trigger(Nc.ns.channel.events.user.joined, user);
this.broadcastControlCommandExcept("userJoined", user.options, user); this.broadcastControlCommandExcept("userJoined", user.options, user);
}; };
Channel.prototype.onReleaseUser = function (userId) { Channel.prototype.onReleaseUser = function (userId) {
var user = this.users[userId]; var user = this.users[userId];
Nc.trigger('user/left', userId); Nc.trigger(Nc.ns.channel.events.user.left, userId);
delete this.users[userId]; delete this.users[userId];
this.broadcastControlCommand("userLeft", userId); this.broadcastControlCommand("userLeft", userId);

View file

@ -20,8 +20,8 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
Parent.call(this); Parent.call(this);
Nc.on('user/joined', this.onUserJoined, this); Nc.on(Nc.ns.channel.events.user.joined, this.onUserJoined, this);
Nc.on('user/left', this.onUserLeft, this); Nc.on(Nc.ns.channel.events.user.left, this.onUserLeft, this);
Nc.on('user/resetLevel', this.onResetLevel, this); Nc.on('user/resetLevel', this.onResetLevel, this);
Nc.on('user/clientReady', this.onClientReady, this); Nc.on('user/clientReady', this.onClientReady, this);
Nc.on('player/killed', this.onPlayerKilled, this); Nc.on('player/killed', this.onPlayerKilled, this);

View file

@ -37,7 +37,7 @@ function (Nc, Channel) {
}; };
PipeToServer.prototype.onMessage = function (message) { PipeToServer.prototype.onMessage = function (message) {
Nc.trigger(message.recipient + '/controlCommand', message); Nc.trigger(Nc.ns.channel.events.controlCommand + recipient, message);
} }
PipeToServer.prototype.destroy = function() { PipeToServer.prototype.destroy = function() {

View file

@ -37,7 +37,7 @@ function (Parent, DomController, Settings, Nc) {
var x = (((e.clientX - this.offsetLeft) / Settings.STAGE_WIDTH) * 2) - 1; var x = (((e.clientX - this.offsetLeft) / Settings.STAGE_WIDTH) * 2) - 1;
var y = (((Settings.STAGE_HEIGHT - (e.clientY - this.offsetTop)) / Settings.STAGE_HEIGHT) * 2) -1; var y = (((Settings.STAGE_HEIGHT - (e.clientY - this.offsetTop)) / Settings.STAGE_HEIGHT) * 2) -1;
Nc.trigger("input/onHandActionRequest", x, y); Nc.trigger(Nc.ns.client.input.handAction.request, x, y);
} }
}; };

View file

@ -12,7 +12,7 @@ function (Nc) {
XyInput.prototype.onXyChange = function(x, y) { XyInput.prototype.onXyChange = function(x, y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
Nc.trigger('input/onXyChange', x, y); Nc.trigger(Nc.ns.client.input.xy.change, x, y);
} }
return XyInput; return XyInput;

View file

@ -14,8 +14,8 @@ function (Parent, KeyboardInput, MouseInput, Nc) {
this.keyboardInput = new KeyboardInput(this); this.keyboardInput = new KeyboardInput(this);
this.xyInput = new MouseInput(this); this.xyInput = new MouseInput(this);
Nc.on("input/onXyChange", this.setXY, this); Nc.on(Nc.ns.client.input.xy.change, this.setXY, this);
Nc.on("input/onHandActionRequest", this.handActionRequest, this); Nc.on(Nc.ns.client.input.handAction.request, this.handActionRequest, this);
var keys = { var keys = {
w:87, w:87,
@ -64,33 +64,33 @@ function (Parent, KeyboardInput, MouseInput, Nc) {
PlayerController.prototype.moveLeft = function () { PlayerController.prototype.moveLeft = function () {
Parent.prototype.moveLeft.call(this); Parent.prototype.moveLeft.call(this);
Nc.trigger('sendGameCommand', 'moveLeft'); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveLeft');
} }
PlayerController.prototype.moveRight = function () { PlayerController.prototype.moveRight = function () {
Parent.prototype.moveRight.call(this); Parent.prototype.moveRight.call(this);
Nc.trigger('sendGameCommand', 'moveRight'); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveRight');
} }
PlayerController.prototype.stop = function () { PlayerController.prototype.stop = function () {
Parent.prototype.stop.call(this); Parent.prototype.stop.call(this);
Nc.trigger('sendGameCommand', 'stop'); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'stop');
} }
PlayerController.prototype.jump = function () { PlayerController.prototype.jump = function () {
Parent.prototype.jump.call(this); Parent.prototype.jump.call(this);
Nc.trigger('sendGameCommand', 'jump'); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jump');
} }
PlayerController.prototype.jumpStop = function () { PlayerController.prototype.jumpStop = function () {
Parent.prototype.jumpStop.call(this); Parent.prototype.jumpStop.call(this);
Nc.trigger('sendGameCommand', 'jumpStop'); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jumpStop');
} }
PlayerController.prototype.setXY = function(x, y) { PlayerController.prototype.setXY = function(x, y) {
var options = {x:x, y:y}; var options = {x:x, y:y};
Parent.prototype.lookAt.call(this, options); Parent.prototype.lookAt.call(this, options);
Nc.trigger('sendGameCommand', 'lookAt', options); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'lookAt', options);
}; };
PlayerController.prototype.handActionLeft = function() { PlayerController.prototype.handActionLeft = function() {
@ -102,20 +102,20 @@ function (Parent, KeyboardInput, MouseInput, Nc) {
}; };
PlayerController.prototype.suicide = function() { PlayerController.prototype.suicide = function() {
Nc.trigger("sendGameCommand", "suicide"); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "suicide");
}; };
PlayerController.prototype.handActionRequest = function(x, y) { PlayerController.prototype.handActionRequest = function(x, y) {
var options = {x:x, y:y}; var options = {x:x, y:y};
Nc.trigger("sendGameCommand", "handActionRequest", options); Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "handActionRequest", options);
}; };
PlayerController.prototype.showInfo = function() { PlayerController.prototype.showInfo = function() {
Nc.trigger("game/toggleInfo", true); Nc.trigger(Nc.ns.client.view.gameInfo.toggle, true);
}; };
PlayerController.prototype.hideInfo = function() { PlayerController.prototype.hideInfo = function() {
Nc.trigger("game/toggleInfo", false); Nc.trigger(Nc.ns.client.view.gameInfo.toggle, false);
}; };

View file

@ -18,7 +18,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
this.view = ViewManager.createView(); this.view = ViewManager.createView();
this.me = null; this.me = null;
Nc.on("game/toggleInfo", this.toggleInfo, this); Nc.on(Nc.ns.client.view.gameInfo.toggle, this.toggleInfo, this);
Parent.call(this); Parent.call(this);
} }

View file

@ -35,12 +35,12 @@ function (Parent, Settings, Nc, Exception) {
if(!state) throw new Exception("action state is undefined"); if(!state) throw new Exception("action state is undefined");
if(this.animatedMeshes[this.actionState]) { if(this.animatedMeshes[this.actionState]) {
Nc.trigger("view/updateMesh", this.animatedMeshes[this.actionState], { visible: false }); Nc.trigger(Nc.ns.client.view.mesh.update, this.animatedMeshes[this.actionState], { visible: false });
} }
Parent.prototype.setActionState.call(this, state); Parent.prototype.setActionState.call(this, state);
Nc.trigger("view/updateMesh", this.animatedMeshes[this.actionState], { visible: true }); Nc.trigger(Nc.ns.client.view.mesh.update, this.animatedMeshes[this.actionState], { visible: true });
} }
Doll.prototype.createMesh = function() { Doll.prototype.createMesh = function() {
@ -74,7 +74,7 @@ function (Parent, Settings, Nc, Exception) {
var callback = function(mesh) { var callback = function(mesh) {
self.animatedMeshes[key] = mesh; self.animatedMeshes[key] = mesh;
Nc.trigger("view/addMesh", mesh); Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
}; };
Nc.trigger("view/createAnimatedMesh", texturePaths, callback, { Nc.trigger("view/createAnimatedMesh", texturePaths, callback, {
@ -93,7 +93,7 @@ function (Parent, Settings, Nc, Exception) {
var texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/head.png"; var texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/head.png";
var callback = function (mesh) { var callback = function (mesh) {
self.headMesh = mesh; self.headMesh = mesh;
Nc.trigger("view/addMesh", mesh); Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
} }
Nc.trigger("view/createMesh", texturePath, callback, { Nc.trigger("view/createMesh", texturePath, callback, {
pivot: { pivot: {
@ -113,7 +113,7 @@ function (Parent, Settings, Nc, Exception) {
if(oldLookDirection != this.lookDirection) { if(oldLookDirection != this.lookDirection) {
for(var key in this.animatedMeshes) { for(var key in this.animatedMeshes) {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.animatedMeshes[key], this.animatedMeshes[key],
{ {
xScale: this.lookDirection xScale: this.lookDirection
@ -124,7 +124,7 @@ function (Parent, Settings, Nc, Exception) {
var angle = Math.atan2(this.lookAtXY.x, this.lookAtXY.y) / 2 - 0.7855 * this.lookDirection; // 0.7855 = 45° var angle = Math.atan2(this.lookAtXY.x, this.lookAtXY.y) / 2 - 0.7855 * this.lookDirection; // 0.7855 = 45°
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.headMesh, this.headMesh,
{ {
xScale: this.lookDirection, xScale: this.lookDirection,
@ -136,17 +136,17 @@ function (Parent, Settings, Nc, Exception) {
Doll.prototype.destroy = function () { Doll.prototype.destroy = function () {
for (var key in this.animatedMeshes) { for (var key in this.animatedMeshes) {
Nc.trigger("view/removeMesh", this.animatedMeshes[key]); Nc.trigger(Nc.ns.client.view.mesh.remove, this.animatedMeshes[key]);
} }
Nc.trigger("view/removeMesh", this.headMesh); Nc.trigger(Nc.ns.client.view.mesh.remove, this.headMesh);
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);
} }
Doll.prototype.render = function() { Doll.prototype.render = function() {
if(this.actionState) { if(this.actionState) {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.animatedMeshes[this.actionState], this.animatedMeshes[this.actionState],
{ {
x: this.body.GetPosition().x * Settings.RATIO, x: this.body.GetPosition().x * Settings.RATIO,
@ -155,7 +155,7 @@ function (Parent, Settings, Nc, Exception) {
} }
); );
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.headMesh, this.headMesh,
{ {
x: this.body.GetPosition().x * Settings.RATIO, x: this.body.GetPosition().x * Settings.RATIO,

View file

@ -22,7 +22,7 @@ function (Parent, Settings, Nc) {
var callback = function(mesh) { var callback = function(mesh) {
self.mesh = mesh; self.mesh = mesh;
Nc.trigger("view/addMesh", mesh); Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
} }
Nc.trigger("view/createMesh", Nc.trigger("view/createMesh",
@ -40,13 +40,13 @@ function (Parent, Settings, Nc) {
}; };
Item.prototype.destroy = function() { Item.prototype.destroy = function() {
Nc.trigger("view/removeMesh", this.mesh); Nc.trigger(Nc.ns.client.view.mesh.remove, this.mesh);
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);
}; };
Item.prototype.render = function() { Item.prototype.render = function() {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.mesh, this.mesh,
{ {
x: this.body.GetPosition().x * Settings.RATIO, x: this.body.GetPosition().x * Settings.RATIO,
@ -62,7 +62,7 @@ function (Parent, Settings, Nc) {
Parent.prototype.flip.call(this, direction); Parent.prototype.flip.call(this, direction);
if(oldFlipDirection != direction) { if(oldFlipDirection != direction) {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.mesh, this.mesh,
{ {
xScale: direction xScale: direction

View file

@ -37,7 +37,7 @@ function (Parent, CoreItem, Settings, Nc) {
self.limbMeshes[name] = mesh; self.limbMeshes[name] = mesh;
} }
Nc.trigger("view/addMesh", mesh); Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
} }
Nc.trigger("view/createMesh", Nc.trigger("view/createMesh",
@ -60,7 +60,7 @@ function (Parent, CoreItem, Settings, Nc) {
if(this.limbs) { if(this.limbs) {
for(var name in this.limbMeshes) { for(var name in this.limbMeshes) {
if(this.limbs[name]) { if(this.limbs[name]) {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.limbMeshes[name], this.limbMeshes[name],
{ {
x: this.limbs[name].GetPosition().x * Settings.RATIO, x: this.limbs[name].GetPosition().x * Settings.RATIO,
@ -80,7 +80,7 @@ function (Parent, CoreItem, Settings, Nc) {
CoreItem.prototype.flip.call(this, direction); CoreItem.prototype.flip.call(this, direction);
if(oldFlipDirection != direction) { if(oldFlipDirection != direction) {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.mesh, this.mesh,
{ {
xScale: direction xScale: direction
@ -88,7 +88,7 @@ function (Parent, CoreItem, Settings, Nc) {
); );
for (var name in this.limbMeshes) { for (var name in this.limbMeshes) {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.limbMeshes[name], this.limbMeshes[name],
{ {
xScale: direction xScale: direction
@ -100,7 +100,7 @@ function (Parent, CoreItem, Settings, Nc) {
RagDoll.prototype.destroy = function() { RagDoll.prototype.destroy = function() {
for (var name in this.limbMeshes) { for (var name in this.limbMeshes) {
Nc.trigger("view/removeMesh", this.limbMeshes[name]); Nc.trigger(Nc.ns.client.view.mesh.remove, this.limbMeshes[name]);
}; };
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);

View file

@ -27,7 +27,7 @@ function (Parent, Settings, Nc) {
var callback = function(mesh) { var callback = function(mesh) {
self.mesh = mesh; self.mesh = mesh;
Nc.trigger("view/addMesh", mesh); Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
} }
Nc.trigger("view/createMesh", Nc.trigger("view/createMesh",
@ -45,13 +45,13 @@ function (Parent, Settings, Nc) {
}; };
Tile.prototype.destroy = function() { Tile.prototype.destroy = function() {
Nc.trigger("view/removeMesh", this.mesh); Nc.trigger(Nc.ns.client.view.mesh.remove, this.mesh);
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);
}; };
Tile.prototype.render = function() { Tile.prototype.render = function() {
Nc.trigger("view/updateMesh", Nc.trigger(Nc.ns.client.view.mesh.update,
this.mesh, this.mesh,
{ {
x: this.body.GetPosition().x * Settings.RATIO, x: this.body.GetPosition().x * Settings.RATIO,

View file

@ -39,7 +39,7 @@ function (Parent, Settings, Nc, PIXI) {
loader.onComplete = function() { callback(levelData); }; loader.onComplete = function() { callback(levelData); };
loader.onProgress = function() { loader.onProgress = function() {
var progress = parseInt(100 / numPaths * ++count, 10) + 1; var progress = parseInt(100 / numPaths * ++count, 10) + 1;
Nc.trigger("view/updateLoader", progress); Nc.trigger(Nc.ns.client.view.preloadBar.update, progress);
} }
loader.load(); loader.load();
}; };

View file

@ -26,8 +26,8 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
ProtocolHelper.applyCommand(message, self); ProtocolHelper.applyCommand(message, self);
}); });
Nc.on("sendGameCommand", this.sendGameCommand, this); Nc.on(Nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
Nc.on("game/level/loaded", this.onLevelLoaded, this); Nc.on(Nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this);
} }
// Socket callbacks // Socket callbacks

View file

@ -13,7 +13,7 @@ function (Parent, Settings, DomController, Box2D, Nc) {
this.debugMode = false; this.debugMode = false;
Nc.on("view/toggleDebugMode", this.onToggleDebugMode, this); Nc.on(Nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this);
} }
Engine.prototype = Object.create(Parent.prototype); Engine.prototype = Object.create(Parent.prototype);

View file

@ -102,7 +102,7 @@ function (Parent, Nc, Settings) {
Player.prototype.destroy = function() { Player.prototype.destroy = function() {
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);
Nc.trigger("view/removePlayerInfo", this.playerInfoView); Nc.trigger(Nc.ns.client.view.playerInfo.remove, this.playerInfoView);
}; };
return Player; return Player;

View file

@ -13,7 +13,7 @@ function (Settings, Nc, Stats, Screenfull) {
this.stats = null; this.stats = null;
this.ping = null; this.ping = null;
Nc.on("view/ready", this.initDevTools, this); Nc.on(Nc.ns.client.view.events.ready, this.initDevTools, this);
} }
DomController.prototype.initDevTools = function() { DomController.prototype.initDevTools = function() {
@ -39,7 +39,7 @@ function (Settings, Nc, Stats, Screenfull) {
window.onresize = function() { window.onresize = function() {
if(Screenfull.enabled) { if(Screenfull.enabled) {
Nc.trigger("view/fullscreenChange", Screenfull.isFullscreen); Nc.trigger("Nc.ns.client.view.fullscreen.change", Screenfull.isFullscreen);
} }
} }
@ -71,7 +71,7 @@ function (Settings, Nc, Stats, Screenfull) {
var checkbox = document.createElement("input"); var checkbox = document.createElement("input");
checkbox.type = "checkbox"; checkbox.type = "checkbox";
checkbox.onclick = function(e) { checkbox.onclick = function(e) {
Nc.trigger("view/toggleDebugMode", e.target.checked); Nc.trigger(Nc.ns.client.view.debugMode.toggle, e.target.checked);
self.getDebugCanvas().style.display = e.target.checked ? "" : "none"; self.getDebugCanvas().style.display = e.target.checked ? "" : "none";
} }
label.appendChild(checkbox); label.appendChild(checkbox);

View file

@ -36,7 +36,7 @@ function (Settings, Exception, AbstractView, PixiView, Nc) {
throw new Exception("In the view", Settings.VIEW_CONTROLLER + 'View', "this.setCanvas(canvas) has not been called with a valid HTMLCanvasElement!"); throw new Exception("In the view", Settings.VIEW_CONTROLLER + 'View', "this.setCanvas(canvas) has not been called with a valid HTMLCanvasElement!");
} }
Nc.trigger("view/ready", view); Nc.trigger(Nc.ns.client.view.events.ready, view);
return view; return view;
} }

View file

@ -14,20 +14,20 @@ function (DomController, Settings, Exception, Nc) {
Nc.on("view/createMesh", this.createMesh, this); Nc.on("view/createMesh", this.createMesh, this);
Nc.on("view/createAnimatedMesh", this.createAnimatedMesh, this); Nc.on("view/createAnimatedMesh", this.createAnimatedMesh, this);
Nc.on("view/addMesh", this.addMesh, this); Nc.on(Nc.ns.client.view.mesh.add, this.addMesh, this);
Nc.on("view/removeMesh", this.removeMesh, this); Nc.on(Nc.ns.client.view.mesh.remove, this.removeMesh, this);
Nc.on("view/updateMesh", this.updateMesh, this); Nc.on(Nc.ns.client.view.mesh.update, this.updateMesh, this);
Nc.on("view/fullscreenChange", this.onFullscreenChange, this); Nc.on("Nc.ns.client.view.fullscreen.change", this.onFullscreenChange, this);
Nc.on("view/toggleDebugMode", this.onToggleDebugMode, this); Nc.on(Nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this);
Nc.on("view/toggleInfo", this.onToggleInfo, this); Nc.on("view/toggleInfo", this.onToggleInfo, this);
Nc.on("view/createAndAddPlayerInfo", this.onCreateAndAddPlayerInfo, this); Nc.on("view/createAndAddPlayerInfo", this.onCreateAndAddPlayerInfo, this);
Nc.on("view/updatePlayerInfo", this.onUpdatePlayerInfo, this); Nc.on("view/updatePlayerInfo", this.onUpdatePlayerInfo, this);
Nc.on("view/removePlayerInfo", this.onRemovePlayerInfo, this); Nc.on(Nc.ns.client.view.playerInfo.remove, this.onRemovePlayerInfo, this);
Nc.on("view/updateLoader", this.onUpdateLoader, this); Nc.on(Nc.ns.client.view.preloadBar.update, this.onUpdateLoader, this);
} }
AbstractView.prototype.isWebGlEnabled = function () { AbstractView.prototype.isWebGlEnabled = function () {

View file

@ -18,7 +18,7 @@ define(function() {
GRAPHICS_SUBPATH_CHARACTERS: 'Characters/', GRAPHICS_SUBPATH_CHARACTERS: 'Characters/',
GRAPHICS_SUBPATH_TILES: 'Tiles/', GRAPHICS_SUBPATH_TILES: 'Tiles/',
MAPS_PATH: 'static/maps/tiled/', MAPS_PATH: 'static/maps/tiled/',
DEFAULT_LEVELS: ['stones2', 'debug'], DEFAULT_LEVELS: ['debug', 'stones2', 'debug'],
RATIO: 21, //35 RATIO: 21, //35
// original tile size is 25 but we want it to resize to 20 // original tile size is 25 but we want it to resize to 20

View file

@ -16,10 +16,10 @@ function (PhysicsEngine, TiledLevel, Player, Nc) {
this.physicsEngine = new PhysicsEngine(); this.physicsEngine = new PhysicsEngine();
this.physicsEngine.setCollisionDetector(); this.physicsEngine.setCollisionDetector();
Nc.on("game/level/loaded", this.onLevelLoaded, this); Nc.on(Nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this);
Nc.on("game/object/add", this.onGameObjectAdd, this); Nc.on(Nc.ns.core.game.gameObject.add, this.onGameObjectAdd, this);
Nc.on("game/object/remove", this.onGameObjectRemove, this); Nc.on(Nc.ns.core.game.gameObject.remove, this.onGameObjectRemove, this);
this.update(); this.update();
} }

View file

@ -163,7 +163,7 @@ function (Parent, Box2D, Settings, Nc) {
); );
Nc.trigger("game/object/add", 'animated', this); Nc.trigger(Nc.ns.core.game.gameObject.add, 'animated', this);
} }
RagDoll.prototype = Object.create(Parent.prototype); RagDoll.prototype = Object.create(Parent.prototype);
@ -362,7 +362,7 @@ function (Parent, Box2D, Settings, Nc) {
}; };
RagDoll.prototype.destroy = function() { RagDoll.prototype.destroy = function() {
Nc.trigger("game/object/remove", 'animated', this); Nc.trigger(Nc.ns.core.game.gameObject.remove, 'animated', this);
var world = this.body.GetWorld(); var world = this.body.GetWorld();
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);

View file

@ -28,7 +28,7 @@ define([
self.createTiles(); self.createTiles();
self.createItems(); self.createItems();
self.isLoaded = true; self.isLoaded = true;
Nc.trigger("game/level/loaded"); Nc.trigger(Nc.ns.core.game.events.level.loaded);
}); });
} }

View file

@ -40,7 +40,7 @@ function (Doll, Settings, Nc, Exception, SpectatorDoll, RagDoll) {
this.doll = new Doll(this.physicsEngine, "doll-" + this.id, this); this.doll = new Doll(this.physicsEngine, "doll-" + this.id, this);
this.doll.spawn(x, y); this.doll.spawn(x, y);
this.isSpawned = true; this.isSpawned = true;
Nc.trigger("game/object/add", 'animated', this.doll); Nc.trigger(Nc.ns.core.game.gameObject.add, 'animated', this.doll);
} }
Player.prototype.getPosition = function () { Player.prototype.getPosition = function () {
@ -120,7 +120,7 @@ function (Doll, Settings, Nc, Exception, SpectatorDoll, RagDoll) {
this.isSpawned = false; this.isSpawned = false;
Nc.trigger("game/object/remove", 'animated', this.doll); Nc.trigger(Nc.ns.core.game.gameObject.remove, 'animated', this.doll);
this.doll.destroy(); this.doll.destroy();
this.doll = null; this.doll = null;

View file

@ -40,7 +40,7 @@ function (Parent, ProtocolHelper, GameController, User, Nc) {
} }
}, this); }, this);
Nc.on("sendGameCommand", this.sendGameCommand, this); Nc.on(Nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
} }
Worker.prototype.sendCommand = function (command, options) { Worker.prototype.sendCommand = function (command, options) {