Browse Source

casting animation

tags/v0.1.5^2
Shaun 6 years ago
parent
commit
7b017c7025
5 changed files with 91 additions and 29 deletions
  1. +9
    -4
      src/client/js/components/gatherer.js
  2. +74
    -16
      src/client/js/components/lightningEffect.js
  3. +6
    -7
      src/client/js/rendering/effects.js
  4. +1
    -1
      src/server/config/maps/tutorial/zone.js
  5. +1
    -1
      src/server/world/resourceSpawner.js

+ 9
- 4
src/client/js/components/gatherer.js View File

@@ -16,7 +16,7 @@ define([
},

extend: function(msg) {
if (msg.width) {
if ((msg.width) && (msg.progress != 100)) {
if (this.effect)
this.effect.destroyed = true;

@@ -29,6 +29,9 @@ define([
break;
}

this.obj.flipX = (x < this.obj.x);
this.obj.setSpritePosition();

this.effect = this.obj.addComponent('lightningEffect', {
new: true,
toX: x,
@@ -36,11 +39,13 @@ define([
ttl: -1,
divisions: 4,
cdMax: 12,
colors: [0xfafcfc, 0xc0c3cf, 0xc0c3cf],
maxDeviate: 5
colors: [0xc0c3cf, 0xc0c3cf, 0x929398],
maxDeviate: 5,
lineGrow: true,
lineShrink: true
});
} else {
if (msg.progress == 100) {
if ((msg.progress == 100) && (this.effect)) {
this.effect.destroyed = true;
this.effect = null;
}


+ 74
- 16
src/client/js/components/lightningEffect.js View File

@@ -14,17 +14,28 @@ define([
effect: null,

ttl: 6,
lineGrow: false,
linePercentage: 0.1,

lineShrink: false,
shrinking: false,

init: function() {
effects.register(this);

var xOffset = (this.toX >= this.obj.x) ? 1 : 0;

var fromX = this.obj.x + xOffset;
var fromY = this.obj.y + 0.5;

var toX = this.lineGrow ? fromX : this.toX + 0.5;
var toY = this.lineGrow ? fromY : this.toY + 0.5;

this.effect = lightningBuilder.build({
fromX: this.obj.x + xOffset,
fromY: this.obj.y + 0.5,
toX: this.toX + 0.5,
toY: this.toY + 0.5,
fromX: fromX,
fromY: fromY,
toX: toX,
toY: toY,
divisions: this.divisions,
colors: this.colors,
maxDeviate: this.maxDeviate
@@ -42,30 +53,77 @@ define([
lightningBuilder.destroy(this.effect);
this.effect = null;

this.ttl--;
if (this.ttl == 0) {
this.destroyed = true;
return;
if (!this.shrinking) {
this.ttl--;
if (this.ttl == 0) {
this.destroyed = true;
return;
}
}

var xOffset = (this.toX > this.obj.x) ? 1 : 0;
var xOffset = (this.toX >= this.obj.x) ? 1 : 0;

var fromX = this.obj.x + xOffset;
var fromY = this.obj.y + 0.5;

var toX = this.toX + 0.5;
var toY = this.toY + 0.5;

var changeTo = (
(
(this.lineGrow) &&
(this.linePercentage < 1)
) ||
(
(this.shrinking) &&
(this.linePercentage > 0)
)
);

if (changeTo) {
var linePercentage = this.linePercentage;
if (this.shrinking) {
linePercentage /= 3;
} else {
linePercentage *= 1.5;
if (linePercentage > 1)
linePercentage = 1;
}
this.linePercentage = linePercentage;

var angle = Math.atan2(toY - fromY, toX - fromX);
var distance = Math.sqrt(Math.pow(fromX - toX, 2) + Math.pow(fromY - toY, 2));
toX = fromX + (Math.cos(angle) * distance * this.linePercentage);
toY = fromY + (Math.sin(angle) * distance * this.linePercentage);
}

this.effect = lightningBuilder.build({
fromX: this.obj.x + xOffset,
fromY: this.obj.y + 0.5,
toX: this.toX + 0.5,
toY: this.toY + 0.5,
fromX: fromX,
fromY: fromY,
toX: toX,
toY: toY,
divisions: this.divisions,
colors: this.colors,
maxDeviate: this.maxDeviate
});

if ((this.shrinking) && (linePercentage < 0.1))
this.destroyed = true;
},

destroyManual: function() {
if (this.effect)
lightningBuilder.destroy(this.effect);
if ((!this.lineShrink) || (this.shrinking)) {
if (this.effect)
lightningBuilder.destroy(this.effect);

effects.unregister(this);
return;
}

this.destroyed = false;
this.shrinking = true;

effects.unregister(this);
return true;
}
};
});

+ 6
- 7
src/client/js/rendering/effects.js View File

@@ -33,14 +33,13 @@ define([
var l = list[i];

if ((l.destroyed) || (l.obj.destroyed)) {
list.splice(i, 1);
i--;
lLen--;
if (((l.destroyManual) && (!l.destroyManual())) || (!l.destroyManual)) {
list.splice(i, 1);
i--;
lLen--;

if (l.destroyManual)
l.destroyManual();
continue;
continue;
}
}

l.renderManual();


+ 1
- 1
src/server/config/maps/tutorial/zone.js View File

@@ -16,7 +16,7 @@ module.exports = {
},
objects: {
'sun carp school': {
max: 4,
max: 40,
type: 'fish',
quanity: [3, 6]
},


+ 1
- 1
src/server/world/resourceSpawner.js View File

@@ -12,7 +12,7 @@ define([
physics: null,
map: null,

cdMax: 200,
cdMax: 2,

init: function(instance) {
this.objects = instance.objects;


Loading…
Cancel
Save