Ver código fonte

added a fadeInOut client component, a spawnObject event phase and a global event after an actor dies

tags/v0.8.0
Shaun 3 anos atrás
pai
commit
a62f4f6948
5 arquivos alterados com 109 adições e 1 exclusões
  1. +1
    -0
      src/client/css/colors.less
  2. +2
    -1
      src/client/js/components/components.js
  3. +52
    -0
      src/client/js/components/fadeInOut.js
  4. +2
    -0
      src/server/components/stats.js
  5. +52
    -0
      src/server/events/phases/phaseSpawnObject.js

+ 1
- 0
src/client/css/colors.less Ver arquivo

@@ -11,6 +11,7 @@
@greenA: #80f643;
@greenB: #4ac441;
@greenC: #386646;
@greenD: #2b4b3e;
@blackA: #505360;
@blackB: #3c3f4c;
@blackC: #373041;


+ 2
- 1
src/client/js/components/components.js Ver arquivo

@@ -33,7 +33,8 @@ let components = [
'social',
'passives',
'sound',
'whirlwind'
'whirlwind',
'fadeInOut'
].map(function (c) {
return 'js/components/' + c;
});


+ 52
- 0
src/client/js/components/fadeInOut.js Ver arquivo

@@ -0,0 +1,52 @@
define([
'js/rendering/effects'
], function (
effects
) {
return {
type: 'fadeInOut',

delta: 1,

updateCd: 0,
updateCdMax: 10,

alphaMax: 1,
alphaMin: 0,

infinite: false,

init: function (blueprint) {
if (this.obj.components.some(c => c.type === this.type))
return true;

console.log(blueprint);
},

update: function () {
let { updateCd, delta } = this;
const { updateCdMax, alphaMin, alphaMax, infinite, obj: { sprite } } = this;

updateCd += delta;
if (updateCd === updateCdMax) {
if (!infinite)
this.destroyed = true;
else
delta *= -1;
}

this.updateCd = updateCd;
this.delta = delta;

if (!sprite)
return;

const alpha = alphaMin + ((updateCd / updateCdMax) * (alphaMax - alphaMin));
sprite.alpha = alpha;
},

destroy: function () {
effects.unregister(this);
}
};
});

+ 2
- 0
src/server/components/stats.js Ver arquivo

@@ -402,9 +402,11 @@ module.exports = {
killSource.stats.kill(obj);

const deathEvent = {
target: obj,
source: killSource
};

obj.instance.eventEmitter.emitNoSticky('onAfterActorDies', deathEvent);
obj.fireEvent('afterDeath', deathEvent);

if (obj.player) {


+ 52
- 0
src/server/events/phases/phaseSpawnObject.js Ver arquivo

@@ -0,0 +1,52 @@
const buildMob = (objects, mobConfig) => {
const { id, sheetName, cell, name, properties, pos: { x, y } } = mobConfig;

let obj = objects.buildObjects([{
x,
y,
sheetName: sheetName || 'objects',
cell,
name,
properties
}]);

obj.id = id;

return obj;
};

const spawnAnimation = (syncer, { x, y }) => {
syncer.queue('onGetObject', {
x: x,
y: y,
components: [{
type: 'attackAnimation',
row: 0,
col: 4
}]
}, -1);
};

module.exports = {
spawnRect: null,
mobs: null,

init: function () {
const { instance: { objects, syncer } } = this;

if (!this.objs.push)
this.objs = [this.objs];

this.objs.forEach(l => {
const obj = buildMob(objects, l);

this.event.objects.push(obj);
obj.event = this.event;

spawnAnimation(syncer, obj);
});

if (!this.endMark)
this.end = true;
}
};

Carregando…
Cancelar
Salvar