mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
cleared items of player fingerprints (lastMovedBy). fixes #92
This commit is contained in:
parent
bd7edc779e
commit
6233588e63
4 changed files with 23 additions and 102 deletions
|
|
@ -14,6 +14,9 @@ function (Parent) {
|
|||
|
||||
Item.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Item.prototype.getLastMovedBy = function() {
|
||||
return this.lastMoved;
|
||||
}
|
||||
|
||||
Item.prototype.setLastMovedBy = function(player) {
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ function () {
|
|||
CHANNEL_DEFAULT_MAX_USERS: 40,
|
||||
CHANNEL_DEFAULT_SCORE_LIMIT: 10,
|
||||
CHANNEL_DEFAULT_LEVELS: ["debug"],
|
||||
CHANNEL_RECORD_SESSION: true,
|
||||
CHANNEL_RECORD_SESSION: false,
|
||||
|
||||
// ME STATE
|
||||
ME_STATE_MAX_DIFFERENCE_METERS: 1,
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
@ -126,6 +127,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];
|
||||
|
|
@ -137,6 +140,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;
|
||||
|
||||
|
|
@ -149,7 +166,6 @@ function (PhysicsEngine, TiledLevel, Player, Nc, Doll, GameObject, Assert) {
|
|||
// try using a real gameobject for the health bar
|
||||
}*/
|
||||
|
||||
|
||||
for (i = 0; i < this.ncTokens.length; i++) {
|
||||
Nc.off(this.ncTokens[i]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue