Added spawning gameCommand logic

This commit is contained in:
Logsol 2013-01-05 08:19:49 +01:00
parent 371592f167
commit fb5de522e5
8 changed files with 84 additions and 59 deletions

View file

@ -46,14 +46,12 @@ function (ProtocolHelper, GameController, User, NotificationCenter) {
this.gameController = new GameController();
this.gameController.loadLevel("default.json");
var user = new User(options.userId);
this.gameController.meJoined(user);
console.log("Joined Success", options);
this.onUserJoined(options.userId);
this.gameController.onJoinMe(options.userId);
if (options.others) {
for(var i = 0; i < options.others.length; i++) {
this.users[userId] = new User(options.others[i]);
this.onUserJoined(options.others[i]);
}
}
}
@ -73,10 +71,14 @@ function (ProtocolHelper, GameController, User, NotificationCenter) {
// Commands from server
Networker.prototype.onUserJoined = function (userId) {
this.users[userId] = new User(userId);
var user = new User(userId);
this.users[userId] = user;
this.gameController.userJoined(user);
}
Networker.prototype.onUserLeft = function (userId) {
var user = this.users[userId];
this.gameController.userLeft(user);
delete this.users[userId];
}