From 0adbc2a10af616e3c375c52866a1416b40f707b1 Mon Sep 17 00:00:00 2001 From: Logsol Date: Thu, 3 Jan 2013 23:44:25 +0100 Subject: [PATCH] removed worm --- app/Game/Client/Networker.js | 8 ++++---- app/Game/Core/GameController.js | 5 ----- app/Game/Server/Channel.js | 13 +++---------- app/Game/Server/GameController.js | 16 +++++++++------- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/app/Game/Client/Networker.js b/app/Game/Client/Networker.js index 484aa05..1728fbc 100755 --- a/app/Game/Client/Networker.js +++ b/app/Game/Client/Networker.js @@ -48,8 +48,8 @@ function (ProtocolHelper, GameController) { Networker.prototype.onJoinSuccess = function (options) { - //this.gameController = new GameController(); - //this.gameController.loadLevel("default.json"); + this.gameController = new GameController(); + this.gameController.loadLevel("default.json"); @@ -79,7 +79,7 @@ function (ProtocolHelper, GameController) { } Networker.prototype.onUserJoined = function (userId) { - //this.gameController.userJoined(userId); + //this.gameController.userJoined(userId); -> replace with game command console.log("User " + userId + " joined"); } /* @@ -88,7 +88,7 @@ function (ProtocolHelper, GameController) { } */ Networker.prototype.onUserLeft = function (userId) { - //this.gameController.userLeft(userId); + //this.gameController.userLeft(userId); -> replace with game command console.log("User " + userId + " left"); } diff --git a/app/Game/Core/GameController.js b/app/Game/Core/GameController.js index 447f016..6d489b3 100755 --- a/app/Game/Core/GameController.js +++ b/app/Game/Core/GameController.js @@ -29,16 +29,12 @@ function (Engine, Level, Player) { this.level.loadLevelInToEngine(); } - /* - GameController.prototype.destroy = function () { for(var player in this.players) { this.players[player].destroy(); } } - - GameController.prototype.userJoined = function (user) { var player = new Player(user.id, this.physicsEngine); this.players[user.id] = player; @@ -51,7 +47,6 @@ function (Engine, Level, Player) { delete this.players[user.id]; } - */ return GameController; }); diff --git a/app/Game/Server/Channel.js b/app/Game/Server/Channel.js index 2233d99..30f29b5 100755 --- a/app/Game/Server/Channel.js +++ b/app/Game/Server/Channel.js @@ -15,25 +15,18 @@ this.users = {}; this.pipeToLobby = pipeToLobby; + this.gameController = new GameController(this); - this.gameController.loadLevel("default.json"); - //this.pipeToLobby.receive = function (message) { self.onMessage(message) }; - // !!! This should be done differently - use NotificationCenter.on('channel/dungeon/message') instead /* var self = this; NotificationCenter.on("processGameCommandFromUser", function (topic, args) { self.processGameCommandFromUser.apply(self, args); }); + */ - - */ - - // Messages look like: - // {channel: {setName: 'foo'}} - // {user: {jupm: null}, id: 12} NotificationCenter.on('channel/message', function (message) { switch(message.recipient) { @@ -60,7 +53,7 @@ } }); - NotificationCenter.on('channel/users/all', this.sendControlCommandToAllUsers, this); + NotificationCenter.on('sendControlCommandToAllUsers', this.sendControlCommandToAllUsers, this); NotificationCenter.on('channel/users/all/except', this.sendControlCommandToAllUsersExcept, this); console.checkpoint('channel ' + name + ' created'); diff --git a/app/Game/Server/GameController.js b/app/Game/Server/GameController.js index 9288075..ab32119 100755 --- a/app/Game/Server/GameController.js +++ b/app/Game/Server/GameController.js @@ -15,17 +15,17 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No this.inputControllers = {}; this.channel = channel; - //this.update(); - //this.updateWorld(); + this.update(); + this.updateWorld(); - //NotificationCenter.on('user/joined', this.userJoined, this); - //NotificationCenter.on('user/left', this.userLeft, this); + NotificationCenter.on('user/joined', this.userJoined, this); + NotificationCenter.on('user/left', this.userLeft, this); console.checkpoint('starting game controller for channel ' + channel.name); } GameController.prototype = Object.create(Parent.prototype); -/* + GameController.prototype.update = function () { requestAnimFrame(this.update.bind(this)); @@ -37,6 +37,8 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No } GameController.prototype.userJoined = function (user) { + console.log(Parent.prototype); + Parent.prototype.userJoined.call(this, user); var id = user.id; @@ -77,11 +79,11 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No } while (body = body.GetNext()); if(isUpdateNeeded) { - //NotificationCenter.trigger("sendCommandToAllUsers", ['gameCommand', {worldUpdate:update}]); + NotificationCenter.trigger("sendControlCommandToAllUsers", ['gameCommand', {worldUpdate:update}]); } setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL); } -*/ + return GameController; });