mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
NC refactoring
This commit is contained in:
parent
28f71f49e1
commit
96bf9bffbd
24 changed files with 69 additions and 69 deletions
|
|
@ -37,7 +37,7 @@ function (Parent, DomController, Settings, Nc) {
|
|||
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;
|
||||
|
||||
Nc.trigger("input/onHandActionRequest", x, y);
|
||||
Nc.trigger(Nc.ns.client.input.handAction.request, x, y);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ function (Nc) {
|
|||
XyInput.prototype.onXyChange = function(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
Nc.trigger('input/onXyChange', x, y);
|
||||
Nc.trigger(Nc.ns.client.input.xy.change, x, y);
|
||||
}
|
||||
|
||||
return XyInput;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ function (Parent, KeyboardInput, MouseInput, Nc) {
|
|||
this.keyboardInput = new KeyboardInput(this);
|
||||
this.xyInput = new MouseInput(this);
|
||||
|
||||
Nc.on("input/onXyChange", this.setXY, this);
|
||||
Nc.on("input/onHandActionRequest", this.handActionRequest, this);
|
||||
Nc.on(Nc.ns.client.input.xy.change, this.setXY, this);
|
||||
Nc.on(Nc.ns.client.input.handAction.request, this.handActionRequest, this);
|
||||
|
||||
var keys = {
|
||||
w:87,
|
||||
|
|
@ -64,33 +64,33 @@ function (Parent, KeyboardInput, MouseInput, Nc) {
|
|||
|
||||
PlayerController.prototype.moveLeft = function () {
|
||||
Parent.prototype.moveLeft.call(this);
|
||||
Nc.trigger('sendGameCommand', 'moveLeft');
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveLeft');
|
||||
}
|
||||
|
||||
PlayerController.prototype.moveRight = function () {
|
||||
Parent.prototype.moveRight.call(this);
|
||||
Nc.trigger('sendGameCommand', 'moveRight');
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'moveRight');
|
||||
}
|
||||
|
||||
PlayerController.prototype.stop = function () {
|
||||
Parent.prototype.stop.call(this);
|
||||
Nc.trigger('sendGameCommand', 'stop');
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'stop');
|
||||
}
|
||||
|
||||
PlayerController.prototype.jump = function () {
|
||||
Parent.prototype.jump.call(this);
|
||||
Nc.trigger('sendGameCommand', 'jump');
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, 'jump');
|
||||
}
|
||||
|
||||
PlayerController.prototype.jumpStop = function () {
|
||||
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) {
|
||||
var options = {x:x, y:y};
|
||||
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() {
|
||||
|
|
@ -102,20 +102,20 @@ function (Parent, KeyboardInput, MouseInput, Nc) {
|
|||
};
|
||||
|
||||
PlayerController.prototype.suicide = function() {
|
||||
Nc.trigger("sendGameCommand", "suicide");
|
||||
Nc.trigger(Nc.ns.client.to.server.gameCommand.send, "suicide");
|
||||
};
|
||||
|
||||
PlayerController.prototype.handActionRequest = function(x, 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() {
|
||||
Nc.trigger("game/toggleInfo", true);
|
||||
Nc.trigger(Nc.ns.client.view.gameInfo.toggle, true);
|
||||
};
|
||||
|
||||
PlayerController.prototype.hideInfo = function() {
|
||||
Nc.trigger("game/toggleInfo", false);
|
||||
Nc.trigger(Nc.ns.client.view.gameInfo.toggle, false);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
|
|||
this.view = ViewManager.createView();
|
||||
this.me = null;
|
||||
|
||||
Nc.on("game/toggleInfo", this.toggleInfo, this);
|
||||
Nc.on(Nc.ns.client.view.gameInfo.toggle, this.toggleInfo, this);
|
||||
|
||||
Parent.call(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ function (Parent, Settings, Nc, Exception) {
|
|||
if(!state) throw new Exception("action state is undefined");
|
||||
|
||||
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);
|
||||
|
||||
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() {
|
||||
|
|
@ -74,7 +74,7 @@ function (Parent, Settings, Nc, Exception) {
|
|||
|
||||
var callback = function(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, {
|
||||
|
|
@ -93,7 +93,7 @@ function (Parent, Settings, Nc, Exception) {
|
|||
var texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/head.png";
|
||||
var callback = function (mesh) {
|
||||
self.headMesh = mesh;
|
||||
Nc.trigger("view/addMesh", mesh);
|
||||
Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
|
||||
}
|
||||
Nc.trigger("view/createMesh", texturePath, callback, {
|
||||
pivot: {
|
||||
|
|
@ -113,7 +113,7 @@ function (Parent, Settings, Nc, Exception) {
|
|||
|
||||
if(oldLookDirection != this.lookDirection) {
|
||||
for(var key in this.animatedMeshes) {
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.animatedMeshes[key],
|
||||
{
|
||||
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°
|
||||
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.headMesh,
|
||||
{
|
||||
xScale: this.lookDirection,
|
||||
|
|
@ -136,17 +136,17 @@ function (Parent, Settings, Nc, Exception) {
|
|||
|
||||
Doll.prototype.destroy = function () {
|
||||
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);
|
||||
}
|
||||
|
||||
Doll.prototype.render = function() {
|
||||
if(this.actionState) {
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.animatedMeshes[this.actionState],
|
||||
{
|
||||
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,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function (Parent, Settings, Nc) {
|
|||
|
||||
var callback = function(mesh) {
|
||||
self.mesh = mesh;
|
||||
Nc.trigger("view/addMesh", mesh);
|
||||
Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
|
||||
}
|
||||
|
||||
Nc.trigger("view/createMesh",
|
||||
|
|
@ -40,13 +40,13 @@ function (Parent, Settings, Nc) {
|
|||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
Item.prototype.render = function() {
|
||||
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.mesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
|
|
@ -62,7 +62,7 @@ function (Parent, Settings, Nc) {
|
|||
Parent.prototype.flip.call(this, direction);
|
||||
|
||||
if(oldFlipDirection != direction) {
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.mesh,
|
||||
{
|
||||
xScale: direction
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function (Parent, CoreItem, Settings, Nc) {
|
|||
self.limbMeshes[name] = mesh;
|
||||
}
|
||||
|
||||
Nc.trigger("view/addMesh", mesh);
|
||||
Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
|
||||
}
|
||||
|
||||
Nc.trigger("view/createMesh",
|
||||
|
|
@ -60,7 +60,7 @@ function (Parent, CoreItem, Settings, Nc) {
|
|||
if(this.limbs) {
|
||||
for(var name in this.limbMeshes) {
|
||||
if(this.limbs[name]) {
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.limbMeshes[name],
|
||||
{
|
||||
x: this.limbs[name].GetPosition().x * Settings.RATIO,
|
||||
|
|
@ -80,7 +80,7 @@ function (Parent, CoreItem, Settings, Nc) {
|
|||
CoreItem.prototype.flip.call(this, direction);
|
||||
|
||||
if(oldFlipDirection != direction) {
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.mesh,
|
||||
{
|
||||
xScale: direction
|
||||
|
|
@ -88,7 +88,7 @@ function (Parent, CoreItem, Settings, Nc) {
|
|||
);
|
||||
|
||||
for (var name in this.limbMeshes) {
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.limbMeshes[name],
|
||||
{
|
||||
xScale: direction
|
||||
|
|
@ -100,7 +100,7 @@ function (Parent, CoreItem, Settings, Nc) {
|
|||
|
||||
RagDoll.prototype.destroy = function() {
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function (Parent, Settings, Nc) {
|
|||
|
||||
var callback = function(mesh) {
|
||||
self.mesh = mesh;
|
||||
Nc.trigger("view/addMesh", mesh);
|
||||
Nc.trigger(Nc.ns.client.view.mesh.add, mesh);
|
||||
}
|
||||
|
||||
Nc.trigger("view/createMesh",
|
||||
|
|
@ -45,13 +45,13 @@ function (Parent, Settings, Nc) {
|
|||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
Tile.prototype.render = function() {
|
||||
|
||||
Nc.trigger("view/updateMesh",
|
||||
Nc.trigger(Nc.ns.client.view.mesh.update,
|
||||
this.mesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function (Parent, Settings, Nc, PIXI) {
|
|||
loader.onComplete = function() { callback(levelData); };
|
||||
loader.onProgress = function() {
|
||||
var progress = parseInt(100 / numPaths * ++count, 10) + 1;
|
||||
Nc.trigger("view/updateLoader", progress);
|
||||
Nc.trigger(Nc.ns.client.view.preloadBar.update, progress);
|
||||
}
|
||||
loader.load();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
ProtocolHelper.applyCommand(message, self);
|
||||
});
|
||||
|
||||
Nc.on("sendGameCommand", this.sendGameCommand, this);
|
||||
Nc.on("game/level/loaded", this.onLevelLoaded, this);
|
||||
Nc.on(Nc.ns.client.to.server.gameCommand.send, this.sendGameCommand, this);
|
||||
Nc.on(Nc.ns.core.game.events.level.loaded, this.onLevelLoaded, this);
|
||||
}
|
||||
|
||||
// Socket callbacks
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function (Parent, Settings, DomController, Box2D, Nc) {
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ function (Parent, Nc, Settings) {
|
|||
|
||||
Player.prototype.destroy = function() {
|
||||
Parent.prototype.destroy.call(this);
|
||||
Nc.trigger("view/removePlayerInfo", this.playerInfoView);
|
||||
Nc.trigger(Nc.ns.client.view.playerInfo.remove, this.playerInfoView);
|
||||
};
|
||||
|
||||
return Player;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function (Settings, Nc, Stats, Screenfull) {
|
|||
this.stats = 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() {
|
||||
|
|
@ -39,7 +39,7 @@ function (Settings, Nc, Stats, Screenfull) {
|
|||
|
||||
window.onresize = function() {
|
||||
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");
|
||||
checkbox.type = "checkbox";
|
||||
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";
|
||||
}
|
||||
label.appendChild(checkbox);
|
||||
|
|
|
|||
|
|
@ -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!");
|
||||
}
|
||||
|
||||
Nc.trigger("view/ready", view);
|
||||
Nc.trigger(Nc.ns.client.view.events.ready, view);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@ function (DomController, Settings, Exception, Nc) {
|
|||
|
||||
Nc.on("view/createMesh", this.createMesh, this);
|
||||
Nc.on("view/createAnimatedMesh", this.createAnimatedMesh, this);
|
||||
Nc.on("view/addMesh", this.addMesh, this);
|
||||
Nc.on("view/removeMesh", this.removeMesh, this);
|
||||
Nc.on("view/updateMesh", this.updateMesh, this);
|
||||
Nc.on(Nc.ns.client.view.mesh.add, this.addMesh, this);
|
||||
Nc.on(Nc.ns.client.view.mesh.remove, this.removeMesh, this);
|
||||
Nc.on(Nc.ns.client.view.mesh.update, this.updateMesh, this);
|
||||
|
||||
Nc.on("view/fullscreenChange", this.onFullscreenChange, this);
|
||||
Nc.on("view/toggleDebugMode", this.onToggleDebugMode, this);
|
||||
Nc.on("Nc.ns.client.view.fullscreen.change", this.onFullscreenChange, this);
|
||||
Nc.on(Nc.ns.client.view.debugMode.toggle, this.onToggleDebugMode, this);
|
||||
|
||||
Nc.on("view/toggleInfo", this.onToggleInfo, this);
|
||||
|
||||
Nc.on("view/createAndAddPlayerInfo", this.onCreateAndAddPlayerInfo, 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 () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue