mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Added spawning gameCommand logic
This commit is contained in:
parent
371592f167
commit
fb5de522e5
8 changed files with 84 additions and 59 deletions
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue