merges from rubedoll

This commit is contained in:
logsol 2015-06-22 00:22:00 +02:00
commit 8e9ce62e19
4 changed files with 23 additions and 101 deletions

View file

@ -5,10 +5,11 @@ define([
"Lib/Utilities/NotificationCenter",
"Game/" + GLOBALS.context + "/GameObjects/Doll",
"Game/" + GLOBALS.context + "/GameObjects/GameObject",
"Lib/Utilities/Assert"
"Game/" + GLOBALS.context + "/GameObjects/Item",
"Lib/Utilities/Assert",
],
function (PhysicsEngine, TiledLevel, Player, Nc, Doll, GameObject, Assert) {
function (PhysicsEngine, TiledLevel, Player, Nc, Doll, GameObject, Item, Assert) {
"use strict";
@ -104,6 +105,8 @@ function (PhysicsEngine, TiledLevel, Player, Nc, Doll, GameObject, Assert) {
console.warn("User (", userId ,") left who has not joined");
return;
}
this.clearItemsOfPlayerFingerPrints(player);
player.destroy();
delete this.players[userId];
@ -115,6 +118,20 @@ function (PhysicsEngine, TiledLevel, Player, Nc, Doll, GameObject, Assert) {
return player;
};
GameController.prototype.clearItemsOfPlayerFingerPrints = function(player) {
for (var key in this.gameObjects) {
for (var i = 0; i < this.gameObjects[key].length; i++) { // to go through animated and fixed.
var gameObject = this.gameObjects[key][i];
if (gameObject instanceof Item) {
if (gameObject.getLastMovedBy() && gameObject.getLastMovedBy().player === player) {
gameObject.setLastMovedBy(null);
}
}
}
}
};
GameController.prototype.destroy = function () {
var i = 0;