added gangsta level and tried to fix on new level

This commit is contained in:
Jeena 2015-04-12 18:08:11 +02:00
parent 3283f97f07
commit 0592e2524d
11 changed files with 1434 additions and 15 deletions

View file

@ -77,6 +77,7 @@
levelUid: gameControllerOptions.levelUid levelUid: gameControllerOptions.levelUid
}; };
console.log("beginRound")
this.broadcastControlCommand("beginRound", clientGameControllerOptions); this.broadcastControlCommand("beginRound", clientGameControllerOptions);
}; };

View file

@ -214,6 +214,7 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
}; };
GameController.prototype.destroy = function() { GameController.prototype.destroy = function() {
console.log("clearTimeout")
clearTimeout(this.animationTimeout); clearTimeout(this.animationTimeout);
clearTimeout(this.worldUpdateTimeout); clearTimeout(this.worldUpdateTimeout);

View file

@ -74,8 +74,9 @@ function (Parent, Item, Box2D, Nc, Assert) {
// * 80: tested imperically by throwing knife fast // * 80: tested imperically by throwing knife fast
var damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2; var damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
var lastMovedPlayer = item.lastMoved.player;
var callback = function() { var callback = function() {
self.player.addDamage(damage, item.lastMoved.player, item); self.player.addDamage(damage, lastMovedPlayer, item);
}; };
Nc.trigger(Nc.ns.channel.engine.worldQueue.add, callback); Nc.trigger(Nc.ns.channel.engine.worldQueue.add, callback);

View file

@ -68,8 +68,6 @@ function (Parent, Nc) {
if(this.stats.health <= 0) { if(this.stats.health <= 0) {
if(enemy != this) enemy.score(); if(enemy != this) enemy.score();
this.kill(enemy, byItem); this.kill(enemy, byItem);
} else {
this.broadcastStats();
} }
this.broadcastStats(); this.broadcastStats();
@ -86,7 +84,6 @@ function (Parent, Nc) {
var ragDollId = this.stats.deaths; var ragDollId = this.stats.deaths;
Parent.prototype.kill.call(this, killedByPlayer, ragDollId); Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
this.broadcastStats();
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", { Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
playerId: this.id, playerId: this.id,
killedByPlayerId: killedByPlayer.id, killedByPlayerId: killedByPlayer.id,
@ -103,7 +100,6 @@ function (Parent, Nc) {
Player.prototype.score = function() { Player.prototype.score = function() {
this.stats.score++; this.stats.score++;
this.broadcastStats();
}; };
Player.prototype.broadcastStats = function() { Player.prototype.broadcastStats = function() {

View file

@ -108,8 +108,8 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
} }
} }
this.audioPlayer = new AudioPlayer(Settings.AUDIO_PATH + "city.mp3"); //this.audioPlayer = new AudioPlayer(Settings.AUDIO_PATH + "city.mp3");
this.audioPlayer.play(); //this.audioPlayer.play();
}; };
GameController.prototype.onWorldUpdateGameObject = function(body, gameObject, update) { GameController.prototype.onWorldUpdateGameObject = function(body, gameObject, update) {
@ -269,7 +269,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);
this.audioPlayer.destroy(); //this.audioPlayer.destroy();
this.view.destroy(); this.view.destroy();
}; };

View file

@ -86,13 +86,14 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
}; };
Networker.prototype.onLevelLoaded = function() { Networker.prototype.onLevelLoaded = function() {
/*
this.gameController.createMe(this.users[this.meUserId]); this.gameController.createMe(this.users[this.meUserId]);
for (var userId in this.users) { for (var userId in this.users) {
if(this.meUserId != userId) { if(this.meUserId != userId) {
this.gameController.createPlayer(this.users[userId]); this.gameController.createPlayer(this.users[userId]);
} }
} }*/
this.gameController.onLevelLoaded(); this.gameController.onLevelLoaded();
@ -166,7 +167,11 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
} }
Networker.prototype.onGameCommand = function(message) { Networker.prototype.onGameCommand = function(message) {
if (this.gameController) {
this.gameController.onGameCommand(message); this.gameController.onGameCommand(message);
} else {
console.warn("Networker.onGameCommand: this.gameController is undefined", message);
}
} }
Networker.prototype.onPong = function(timestamp) { Networker.prototype.onPong = function(timestamp) {
@ -183,6 +188,14 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
} }
this.gameController = new GameController(options); this.gameController = new GameController(options);
this.gameController.createMe(this.users[this.meUserId]);
for (var userId in this.users) {
if(this.meUserId != userId) {
this.gameController.createPlayer(this.users[userId]);
}
}
}; };
Networker.prototype.onEndRound = function() { Networker.prototype.onEndRound = function() {

View file

@ -25,7 +25,7 @@ function (Abstract) {
value: { value: {
TILE: 'tile', TILE: 'tile',
ITEM: 'item', ITEM: 'item',
SPAWN: 'spawn' SPAWN: 'spawnpoints'
} }
}); });

View file

@ -22,6 +22,8 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
Parent.call(this); Parent.call(this);
this.xyz = Math.random()
this.layerManager = null; this.layerManager = null;
this.stage = null; this.stage = null;
this.container = null; this.container = null;
@ -52,6 +54,7 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
if(Settings.USE_WEBGL) { if(Settings.USE_WEBGL) {
PIXI.WebGLRenderer.glContextId = 0;
this.renderer = new PIXI.WebGLRenderer(Settings.STAGE_WIDTH, Settings.STAGE_HEIGHT, rendererOptions); this.renderer = new PIXI.WebGLRenderer(Settings.STAGE_WIDTH, Settings.STAGE_HEIGHT, rendererOptions);
console.log('WebGLRenderer'); console.log('WebGLRenderer');
@ -62,6 +65,7 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
} }
this.stage = new PIXI.Stage(0x333333); this.stage = new PIXI.Stage(0x333333);
this.container = new PIXI.DisplayObjectContainer(); this.container = new PIXI.DisplayObjectContainer();
@ -95,6 +99,7 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
} }
PixiView.prototype.render = function () { PixiView.prototype.render = function () {
if (this.me) { if (this.me) {
this.layerManager.render(this.calculateCenterPosition(), this.currentZoom); this.layerManager.render(this.calculateCenterPosition(), this.currentZoom);
} }
@ -245,6 +250,9 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
this.renderer.render(this.stage); this.renderer.render(this.stage);
this.renderer.destroy();
delete this.renderer;
Parent.prototype.destroy.call(this); Parent.prototype.destroy.call(this);
}; };

View file

@ -78,7 +78,7 @@ function () {
// NETWORKING // NETWORKING
NETWORK_UPDATE_INTERVAL: 70, // in milliseconds NETWORK_UPDATE_INTERVAL: 70, // in milliseconds
NETWORK_LOG_INCOMING: false, NETWORK_LOG_INCOMING: true,
NETWORK_LOG_OUTGOING: false, NETWORK_LOG_OUTGOING: false,
NETWORK_LOG_FILTER: ["ping", "pong", "worldUpdate", "lookAt"], NETWORK_LOG_FILTER: ["ping", "pong", "worldUpdate", "lookAt"],

View file

@ -37,7 +37,7 @@ define([
this.levelData = levelData; this.levelData = levelData;
var spawnpointsExists = levelData.layers.some(function(o) { var spawnpointsExists = levelData.layers.some(function(o) {
return o.name == "spawnpoints"; return o.name == AbstractLayer.ID.SPAWN;
}); });
if (!spawnpointsExists) { if (!spawnpointsExists) {
@ -67,7 +67,7 @@ define([
layerOptions.z = i; layerOptions.z = i;
layerOptions.layerId = getLayerId(layerOptions.name, i); layerOptions.layerId = getLayerId(layerOptions.name, i);
if (layerOptions.name == "spawnpoints") { if (layerOptions.name == AbstractLayer.ID.SPAWN) {
spawnpointsFound = true; spawnpointsFound = true;
} }
@ -95,7 +95,7 @@ define([
layerOptions.z = i; layerOptions.z = i;
layerOptions.layerId = getLayerId(layerOptions.name, i); layerOptions.layerId = getLayerId(layerOptions.name, i);
if (layerOptions.name == "spawnpoints") { if (layerOptions.name == AbstractLayer.ID.SPAWN) {
spawnpointsFound = true; spawnpointsFound = true;
continue; continue;
} }

File diff suppressed because one or more lines are too long