implemented clientReady and changed loading of assets, fixed unique ragdoll id

This commit is contained in:
Jeena 2014-02-24 17:41:01 +01:00
parent f578b92734
commit 695008afd8
278 changed files with 306 additions and 287 deletions

View file

@ -20,6 +20,8 @@ function (PhysicsEngine, TiledLevel, Player, NotificationCenter) {
NotificationCenter.on("game/object/add", this.onGameObjectAdd, this);
NotificationCenter.on("game/object/remove", this.onGameObjectRemove, this);
this.update();
}
GameController.prototype.update = function() {
@ -61,7 +63,7 @@ function (PhysicsEngine, TiledLevel, Player, NotificationCenter) {
};
GameController.prototype.onLevelLoaded = function() {
this.update();
};
@ -71,11 +73,13 @@ function (PhysicsEngine, TiledLevel, Player, NotificationCenter) {
}
}
/*
GameController.prototype.userJoined = function (user) {
this.players[user.id] = this.createPlayer(user);
}
*/
GameController.prototype.userLeft = function (user) {
GameController.prototype.onUserLeft = function (user) {
var player = this.players[user.id];
var i = this.gameObjects.animated.indexOf(player);
@ -86,7 +90,9 @@ function (PhysicsEngine, TiledLevel, Player, NotificationCenter) {
}
GameController.prototype.createPlayer = function(user) {
return new Player(user.id, this.physicsEngine);
var player = new Player(user.id, this.physicsEngine);
this.players[user.id] = player;
return player;
};
return GameController;

View file

@ -10,6 +10,7 @@ function (Parent, Box2D, Settings, CollisionDetector, Item) {
function Doll (physicsEngine, uid, player) {
this.characterName = "Chuck";
this.player = player;
this.height = 43;
this.width = 9;

View file

@ -122,7 +122,7 @@ function (Parent, Box2D, Options, Settings) {
var vector = new Box2D.Common.Math.b2Vec2(
x * Settings.MAX_THROW_FORCE / this.options.weight,
-y * Settings.MAX_THROW_FORCE * 1.5 / this.options.weight // 1.5 is to throw higher then far
-y * Settings.MAX_THROW_FORCE / this.options.weight
);
this.body.SetLinearVelocity(vector);

View file

@ -22,7 +22,7 @@ define([
throw "Level: Can't create level, nothing found";
}
var collisionLayer = this.getLayer("collision");
var collisionLayer = this.getLayer(this.levelData, "collision");
if(collisionLayer) {
@ -56,7 +56,7 @@ define([
}
TiledLevel.prototype.createItems = function() {
var objects = this.getLayer("items").objects;
var objects = this.getLayer(this.levelData, "items").objects;
for (var i = 0; i < objects.length; i++) {
var object = objects[i];
var options = object.properties;
@ -84,7 +84,7 @@ define([
return Parent.prototype.getRandomSpawnPoint.call(this);
} else {
var spawnLayer = this.getLayer("spawnpoints");
var spawnLayer = this.getLayer(this.levelData, "spawnpoints");
var size = spawnLayer.objects.length;
var object = spawnLayer.objects[parseInt(Math.random() * (size -1), 10)];
@ -97,10 +97,10 @@ define([
}
};
TiledLevel.prototype.getLayer = function(name) {
for (var i = 0; i < this.levelData.layers.length; i++) {
if(this.levelData.layers[i].name === name) {
return this.levelData.layers[i];
TiledLevel.prototype.getLayer = function(levelData, name) {
for (var i = 0; i < levelData.layers.length; i++) {
if(levelData.layers[i].name === name) {
return levelData.layers[i];
}
}

View file

@ -26,11 +26,6 @@ function (Doll, Settings, NotificationCenter, Exception, SpectatorDoll, RagDoll)
this.spectatorDoll = new SpectatorDoll(this.physicsEngine, "spectatorDoll-" + this.id, this);
}
Player.prototype.getDoll = function() {
throw new Exception('-- PLEASE REMOVE getDoll Calls --');
return this.doll;
};
Player.prototype.getActiveDoll = function() {
if(this.isSpawned) {
return this.doll;
@ -96,7 +91,7 @@ function (Doll, Settings, NotificationCenter, Exception, SpectatorDoll, RagDoll)
this.holdingItem = null;
};
Player.prototype.kill = function(killedByPlayer) {
Player.prototype.kill = function(killedByPlayer, ragDollId) {
if(!this.isSpawned) return false;
// FIXME: do something better then just respawn in GameController
@ -119,9 +114,9 @@ function (Doll, Settings, NotificationCenter, Exception, SpectatorDoll, RagDoll)
height: 12
};
var ragDoll = new RagDoll(this.physicsEngine, "ragDoll-" + this.id, options);
var ragDoll = new RagDoll(this.physicsEngine, "ragDoll-" + this.id + "-" + ragDollId, options);
ragDoll.setVelocities(this.doll.getVelocities());
console.log(ragDoll.uid)
this.isSpawned = false;