Explorar el Código

more hider work

tags/v0.3.0
Big Bad Waffle hace 6 años
padre
commit
c4b307298f
Se han modificado 3 ficheros con 46 adiciones y 19 borrados
  1. +12
    -5
      src/client/js/components/light.js
  2. +19
    -0
      src/client/js/objects/objBase.js
  3. +15
    -14
      src/client/js/objects/objects.js

+ 12
- 5
src/client/js/components/light.js Ver fichero

@@ -1,7 +1,7 @@
define([
'js/rendering/effects',
'js/rendering/renderer'
], function(
], function (
effects,
renderer
) {
@@ -17,7 +17,7 @@ define([

range: 3,

init: function(blueprint) {
init: function (blueprint) {
this.blueprint = this.blueprint || {};

var x = this.obj.x;
@@ -79,11 +79,18 @@ define([
}
},

update: function() {
update: function () {

},

destroy: function() {
setVisible: function (visible) {
var emitters = this.emitters;
for (var p in emitters) {
emitters[p].emit = visible;
}
},

destroy: function () {
var keys = Object.keys(this.emitters);
for (var i = 0; i < keys.length; i++) {
var emitter = this.emitters[keys[i]];
@@ -93,4 +100,4 @@ define([
}
}
};
});
});

+ 19
- 0
src/client/js/objects/objBase.js Ver fichero

@@ -123,6 +123,25 @@ define([

if (this.stats)
this.stats.updateHpSprite();

this.setVisible(renderer.sprites[this.x][this.y].length > 0);
},

setVisible: function (visible) {
this.sprite.visible = (renderer.sprites[this.x][this.y].length > 0);

['nameSprite', 'chatSprite'].forEach(function (s, i) {
var sprite = this[s];
if (!sprite)
return;

sprite.visible = visible;
}, this);

this.components.forEach(function (c) {
if (c.setVisible)
c.setVisible(visible);
});
},

destroy: function () {


+ 15
- 14
src/client/js/objects/objects.js Ver fichero

@@ -146,19 +146,6 @@ define([
obj[p] = value;
}

if (obj.sheetName) {
obj.sprite = renderer.buildObject(obj);
if (template.hidden) {
obj.sprite.visible = false;
if (obj.nameSprite)
obj.nameSprite.visible = false;
if ((obj.stats) && (obj.stats.hpSprite)) {
obj.stats.hpSprite.visible = false;
obj.stats.hpSpriteInner.visible = false;
}
}
}

components.forEach(function (c) {
//Map ids to objects
var keys = Object.keys(c).filter(function (k) {
@@ -177,6 +164,20 @@ define([
obj.addComponent(c.type, c);
}, this);

if (obj.sheetName) {
obj.sprite = renderer.buildObject(obj);
obj.setVisible(renderer.sprites[obj.x][obj.y].length > 0);
if (template.hidden) {
obj.sprite.visible = false;
if (obj.nameSprite)
obj.nameSprite.visible = false;
if ((obj.stats) && (obj.stats.hpSprite)) {
obj.stats.hpSprite.visible = false;
obj.stats.hpSpriteInner.visible = false;
}
}
}

this.objects.push(obj);

if (obj.self) {
@@ -336,7 +337,7 @@ define([
for (var i = 0; i < oLen; i++) {
var obj = objects[i];
var ns = obj.nameSprite;
if ((!ns) || (obj.dead))
if ((!ns) || (obj.dead) || ((obj.sprite) && (!obj.sprite.visible)))
continue;

ns.visible = showNames;


Cargando…
Cancelar
Guardar