Skip to content

Commit

Permalink
Fix dead units and drops
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer-Zhang committed Apr 24, 2016
1 parent 09c251b commit ead404c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
8 changes: 4 additions & 4 deletions development/src/creature.js
Expand Up @@ -1018,7 +1018,7 @@ var Creature = Class.create( {
var crea = this;
crea.stats = $j.extend({}, this.baseStats); // Copy

var buffDebuffArray = this.effects.concat(this.dropCollection);
var buffDebuffArray = this.effects;

// Multiplication Buff
buffDebuffArray.each(function() {
Expand Down Expand Up @@ -1092,7 +1092,7 @@ var Creature = Class.create( {
// Drop item
if( this.drop ) {
var offsetX = (this.player.flipped) ? this.x - this.size + 1 : this.x ;
new Drop( this.drop.name, this.drop.alterations, offsetX, this.y );
new Drop( this.drop.name, this.drop.health, this.drop.energy, offsetX, this.y );
}


Expand Down Expand Up @@ -1139,8 +1139,8 @@ var Creature = Class.create( {
// Kill animation
var tweenSprite = G.Phaser.add.tween(this.sprite).to( {alpha:0}, 500, Phaser.Easing.Linear.None ).start();
var tweenHealth = G.Phaser.add.tween(this.healtIndicatorGrp).to( { alpha: 0 }, 500, Phaser.Easing.Linear.None ).start();
tweenSprite.onCompleteCallback(function() { crea.sprite.destroy(); });
tweenHealth.onCompleteCallback(function() { crea.healtIndicatorGrp.destroy(); });
tweenSprite.onComplete.add( function() { crea.sprite.destroy(); } );
tweenHealth.onComplete.add( function() { crea.healtIndicatorGrp.destroy(); } );

this.cleanHex();

Expand Down
33 changes: 12 additions & 21 deletions development/src/drops.js
@@ -1,13 +1,14 @@
var Drop = Class.create({

initialize : function(name,alterations,x,y){
initialize : function(name,health,energy,x,y){

this.name = name;
this.id = dropID++;
this.x = x;
this.y = y;
this.pos = { x:x, y:y };
this.alterations = alterations;
this.health = health;
this.energy = energy;
this.hex = G.grid.hexs[this.y][this.x];

this.hex.drop = this;
Expand All @@ -29,29 +30,19 @@ var Drop = Class.create({

this.hex.drop = undefined;

// Fills up consumable stats
$j.each( this.alterations, function(key, value){
switch(key){
case "health" :
creature.heal(value);
break;
case "endurance" :
creature.endurance += value;
break;
case "energy" :
creature.energy += value;
break;
case "movement" :
creature.remainingMove += value;
break;
}
G.log("%CreatureName"+creature.id+"% gains "+value+" "+key);
});
if(this.health) {
creature.heal(this.health);
G.log("%CreatureName"+creature.id+"% gains "+this.health+" health");
}
if(this.energy) {
creature.energy += this.energy;
G.log("%CreatureName"+creature.id+"% gains "+this.energy+" energy");
}

creature.updateAlteration(); // Will cap the stats

var drop = this;
var tween = G.Phaser.add.tween(this.display).to( {alpha:0}, 500, Phaser.Easing.Linear.None ).start();
tween.onCompleteCallback(function() { drop.display.destroy(); });
tween.onComplete.add(function() { drop.display.destroy(); });
}
});

0 comments on commit ead404c

Please sign in to comment.