mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added gangsta level and tried to fix on new level
This commit is contained in:
parent
3283f97f07
commit
0592e2524d
11 changed files with 1434 additions and 15 deletions
|
|
@ -77,6 +77,7 @@
|
|||
levelUid: gameControllerOptions.levelUid
|
||||
};
|
||||
|
||||
console.log("beginRound")
|
||||
this.broadcastControlCommand("beginRound", clientGameControllerOptions);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N
|
|||
};
|
||||
|
||||
GameController.prototype.destroy = function() {
|
||||
console.log("clearTimeout")
|
||||
clearTimeout(this.animationTimeout);
|
||||
clearTimeout(this.worldUpdateTimeout);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,8 +74,9 @@ function (Parent, Item, Box2D, Nc, Assert) {
|
|||
// * 80: tested imperically by throwing knife fast
|
||||
var damage = (velocityDamage + 0.5) * (weightDamage * 300 + dangerDamage * 80) / 2;
|
||||
|
||||
var lastMovedPlayer = item.lastMoved.player;
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ function (Parent, Nc) {
|
|||
if(this.stats.health <= 0) {
|
||||
if(enemy != this) enemy.score();
|
||||
this.kill(enemy, byItem);
|
||||
} else {
|
||||
this.broadcastStats();
|
||||
}
|
||||
|
||||
this.broadcastStats();
|
||||
|
|
@ -86,7 +84,6 @@ function (Parent, Nc) {
|
|||
var ragDollId = this.stats.deaths;
|
||||
Parent.prototype.kill.call(this, killedByPlayer, ragDollId);
|
||||
|
||||
this.broadcastStats();
|
||||
Nc.trigger(Nc.ns.channel.to.client.gameCommand.broadcast, "playerKill", {
|
||||
playerId: this.id,
|
||||
killedByPlayerId: killedByPlayer.id,
|
||||
|
|
@ -103,7 +100,6 @@ function (Parent, Nc) {
|
|||
|
||||
Player.prototype.score = function() {
|
||||
this.stats.score++;
|
||||
this.broadcastStats();
|
||||
};
|
||||
|
||||
Player.prototype.broadcastStats = function() {
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
|
|||
}
|
||||
}
|
||||
|
||||
this.audioPlayer = new AudioPlayer(Settings.AUDIO_PATH + "city.mp3");
|
||||
this.audioPlayer.play();
|
||||
//this.audioPlayer = new AudioPlayer(Settings.AUDIO_PATH + "city.mp3");
|
||||
//this.audioPlayer.play();
|
||||
};
|
||||
|
||||
GameController.prototype.onWorldUpdateGameObject = function(body, gameObject, update) {
|
||||
|
|
@ -269,7 +269,7 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
|
|||
|
||||
Parent.prototype.destroy.call(this);
|
||||
|
||||
this.audioPlayer.destroy();
|
||||
//this.audioPlayer.destroy();
|
||||
|
||||
this.view.destroy();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -86,13 +86,14 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
};
|
||||
|
||||
Networker.prototype.onLevelLoaded = function() {
|
||||
/*
|
||||
this.gameController.createMe(this.users[this.meUserId]);
|
||||
|
||||
for (var userId in this.users) {
|
||||
if(this.meUserId != userId) {
|
||||
this.gameController.createPlayer(this.users[userId]);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
this.gameController.onLevelLoaded();
|
||||
|
||||
|
|
@ -166,7 +167,11 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
}
|
||||
|
||||
Networker.prototype.onGameCommand = function(message) {
|
||||
this.gameController.onGameCommand(message);
|
||||
if (this.gameController) {
|
||||
this.gameController.onGameCommand(message);
|
||||
} else {
|
||||
console.warn("Networker.onGameCommand: this.gameController is undefined", message);
|
||||
}
|
||||
}
|
||||
|
||||
Networker.prototype.onPong = function(timestamp) {
|
||||
|
|
@ -183,6 +188,14 @@ function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function (Abstract) {
|
|||
value: {
|
||||
TILE: 'tile',
|
||||
ITEM: 'item',
|
||||
SPAWN: 'spawn'
|
||||
SPAWN: 'spawnpoints'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
|
|||
|
||||
Parent.call(this);
|
||||
|
||||
this.xyz = Math.random()
|
||||
|
||||
this.layerManager = null;
|
||||
this.stage = null;
|
||||
this.container = null;
|
||||
|
|
@ -52,6 +54,7 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
|
|||
|
||||
if(Settings.USE_WEBGL) {
|
||||
|
||||
PIXI.WebGLRenderer.glContextId = 0;
|
||||
this.renderer = new PIXI.WebGLRenderer(Settings.STAGE_WIDTH, Settings.STAGE_HEIGHT, rendererOptions);
|
||||
console.log('WebGLRenderer');
|
||||
|
||||
|
|
@ -62,6 +65,7 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
|
|||
|
||||
}
|
||||
|
||||
|
||||
this.stage = new PIXI.Stage(0x333333);
|
||||
|
||||
this.container = new PIXI.DisplayObjectContainer();
|
||||
|
|
@ -95,6 +99,7 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
|
|||
}
|
||||
|
||||
PixiView.prototype.render = function () {
|
||||
|
||||
if (this.me) {
|
||||
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.destroy();
|
||||
delete this.renderer;
|
||||
|
||||
Parent.prototype.destroy.call(this);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ function () {
|
|||
|
||||
// NETWORKING
|
||||
NETWORK_UPDATE_INTERVAL: 70, // in milliseconds
|
||||
NETWORK_LOG_INCOMING: false,
|
||||
NETWORK_LOG_INCOMING: true,
|
||||
NETWORK_LOG_OUTGOING: false,
|
||||
NETWORK_LOG_FILTER: ["ping", "pong", "worldUpdate", "lookAt"],
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ define([
|
|||
this.levelData = levelData;
|
||||
|
||||
var spawnpointsExists = levelData.layers.some(function(o) {
|
||||
return o.name == "spawnpoints";
|
||||
return o.name == AbstractLayer.ID.SPAWN;
|
||||
});
|
||||
|
||||
if (!spawnpointsExists) {
|
||||
|
|
@ -67,7 +67,7 @@ define([
|
|||
layerOptions.z = i;
|
||||
layerOptions.layerId = getLayerId(layerOptions.name, i);
|
||||
|
||||
if (layerOptions.name == "spawnpoints") {
|
||||
if (layerOptions.name == AbstractLayer.ID.SPAWN) {
|
||||
spawnpointsFound = true;
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ define([
|
|||
layerOptions.z = i;
|
||||
layerOptions.layerId = getLayerId(layerOptions.name, i);
|
||||
|
||||
if (layerOptions.name == "spawnpoints") {
|
||||
if (layerOptions.name == AbstractLayer.ID.SPAWN) {
|
||||
spawnpointsFound = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
1399
static/maps/tiled/gangsta.json
Normal file
1399
static/maps/tiled/gangsta.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue