replaced all tabs with 4 spaces

This commit is contained in:
logsol 2012-07-28 13:26:05 +02:00
parent 5d11540c55
commit 26f3d22db7
30 changed files with 1017 additions and 1011 deletions

View file

@ -1,112 +1,118 @@
define([
"Game/Core/Protocol/Helper",
"Game/Client/GameController"
"Game/Core/Protocol/Helper",
"Game/Client/GameController"
],
function(ProtocolHelper, GameController) {
function Networker(socketLink) {
this.socketLink = socketLink;
this.gameController = null;
function Networker(socketLink) {
this.socketLink = socketLink;
this.gameController = null;
this.init();
}
this.init();
}
Networker.prototype.init = function() {
var self = this;
Networker.prototype.init = function() {
var self = this;
this.socketLink.on('connect', function() {
self.onConnect();
});
this.socketLink.on('connect', function() {
self.onConnect();
});
/*
this.socketLink.on('message', function(message) {
self.onMessage(message);
});
this.socketLink.on('message', function(message) {
self.onMessage(message);
});
*/
this.socketLink.on('disconnect', function() {
self.onDisconnect();
});
this.socketLink.on('disconnect', function() {
self.onDisconnect();
});
}
}
Networker.prototype.onConnect = function() {
console.log('connected.')
this.join('dungeon');
}
Networker.prototype.onDisconnect = function() {
if(this.gameController) this.gameController.destruct();
this.gameController = null;
console.log('disconnected. game destroyed. no auto-reconnect');
}
Networker.prototype.join = function(channelName){
this.sendCommand('join', channelName);
}
Networker.prototype.onJoinSuccess = function(options) {
this.gameController = new GameController(options.id);
this.gameController.loadLevel("default.json");
/*
console.log("Joined " + options.channelName);
if (options.userIds && options.userIds.length > 0) {
for(var i = 0; i < options.userIds.length; i++) {
this.gameController.userJoined(options.userIds[i])
}
}
*/
}
Networker.prototype.sendCommand = function(command, options) {
var message = ProtocolHelper.encodeCommand(command, options);
this.socketLink.send(message);
}
Networker.prototype.onConnect = function() {
console.log('connected.')
this.join('dungeon');
}
/*
Networker.prototype.onMessage = function(message) {
var self = this;
ProtocolHelper.runCommands(message, function(command, options) {
self.processControlCommand(command, options);
});
}
Networker.prototype.onMessage = function(message) {
var self = this;
ProtocolHelper.runCommands(message, function(command, options) {
self.processControlCommand(command, options);
});
}
Networker.prototype.onUserJoined = function(userId) {
this.gameController.userJoined(userId);
console.log("User " + userId + " joined");
}
Networker.prototype.sendGameCommand = function(command, options) {
this.sendCommand('gameCommand', ProtocolHelper.assemble(command, options));
}
Networker.prototype.onUserLeft = function(userId) {
this.gameController.userLeft(userId);
}
Networker.prototype.processControlCommand = function(command, options) {
switch(command) {
case 'joinSuccess':
this.onJoinSuccess(options);
break;
case 'gameCommand':
for(var gameCommand in options) {
this.gameController.processGameCommand(gameCommand, options[gameCommand]);
}
break;
case 'userJoined':
this.onUserJoined(options);
break;
case 'userLeft':
this.onUserLeft(options);
break;
default:
break;
}
}
*/
Networker.prototype.onDisconnect = function() {
if(this.gameController) this.gameController.destruct();
this.gameController = null;
console.log('disconnected. game destroyed. no auto-reconnect');
}
Networker.prototype.join = function(channelName){
this.sendCommand('join', channelName);
}
Networker.prototype.sendCommand = function(command, options) {
var message = ProtocolHelper.encodeCommand(command, options);
this.socketLink.send(message);
}
/*
Networker.prototype.onJoinSuccess = function(options) {
this.gameController = new GameController(options.id);
this.gameController.loadLevel("default.json")
console.log("Joined " + options.channelName);
if (options.userIds && options.userIds.length > 0) {
for(var i = 0; i < options.userIds.length; i++) {
this.gameController.userJoined(options.userIds[i])
}
}
}
Networker.prototype.onUserJoined = function(userId) {
this.gameController.userJoined(userId);
console.log("User " + userId + " joined");
}
Networker.prototype.sendGameCommand = function(command, options) {
this.sendCommand('gameCommand', ProtocolHelper.assemble(command, options));
}
Networker.prototype.onUserLeft = function(userId) {
this.gameController.userLeft(userId);
}
Networker.prototype.processControlCommand = function(command, options) {
switch(command) {
case 'joinSuccess':
this.onJoinSuccess(options);
break;
case 'gameCommand':
for(var gameCommand in options) {
this.gameController.processGameCommand(gameCommand, options[gameCommand]);
}
break;
case 'userJoined':
this.onUserJoined(options);
break;
case 'userLeft':
this.onUserLeft(options);
break;
default:
break;
}
}
*/
return Networker;
return Networker;
});