fixed problem when user disconnected

This commit is contained in:
Jeena Paradies 2012-07-14 00:04:41 +02:00
parent e751210345
commit 7d0df79ac8
8 changed files with 73 additions and 33 deletions

View file

@ -2,20 +2,28 @@ define(["Chuck/Processors/ClientProcessor"], function(ClientProcessor) {
function ClientGame(networker, id) {
this.networker = networker;
this.processor = new ClientProcessor(this);
this.processor.spawnMeWithId(id);
this.clientProcessor = new ClientProcessor(this);
this.clientProcessor.spawnMeWithId(id);
this.players = {};
}
ClientGame.prototype.loadLevel = function(path) {
this.processor.loadLevel(path);
this.clientProcessor.loadLevel(path);
}
ClientGame.prototype.userJoined = function(userId) {
this.processor.spawnNewPlayerWithId(userId);
};
this.players[userId] = this.clientProcessor.spawnNewPlayerWithId(userId);
}
ClientGame.prototype.userLeft = function(userId) {
var player = this.players[userId];
player.destroy();
delete this.players[userId];
}
ClientGame.prototype.processGameCommand = function(command, options){
this.processor.processGameCommand(command, options);
this.clientProcessor.processGameCommand(command, options);
}
ClientGame.prototype.sendGameCommand = function(command, options) {
@ -23,7 +31,7 @@ define(["Chuck/Processors/ClientProcessor"], function(ClientProcessor) {
}
ClientGame.prototype.destruct = function(){
this.processor.destruct();
this.clientProcessor.destruct();
}
return ClientGame;