From d1a2319ce4d5d45f2e71ac7225a45e9f13efba9e Mon Sep 17 00:00:00 2001 From: Chris Weed Date: Sun, 14 Jul 2024 20:30:49 -0500 Subject: [PATCH] Loot the bodies --- island.ts | 6 +++++- militia.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/island.ts b/island.ts index ce1d659..bd7b531 100644 --- a/island.ts +++ b/island.ts @@ -44,7 +44,11 @@ namespace Island { // manually check each enemy to see if they overlap, also check for parry currentEnemies.forEach((enemy) => { - // Do nothing on dead enemies + if (enemy.health <= 0 && enemy.riches > 0) { + enemy.lootTheBody() + } + + // Don't hurt the dead, that's just mean if (enemy.health <= 0) return if (direction === 'right' && enemy.sprite.x >= hitXZone[0] && enemy.sprite.x <= hitXZone[1] diff --git a/militia.ts b/militia.ts index 1617491..2d0cbbb 100644 --- a/militia.ts +++ b/militia.ts @@ -19,6 +19,7 @@ class Militia { private _lastDirectionTick: number = 0 private _isAttacking: boolean = false private _isParrying: boolean = false + public riches = 1 public sprite: Sprite public health: number = 1 @@ -123,6 +124,20 @@ class Militia { } } + public lootTheBody() { + if (this.riches > 0) { + TreasureStats.updateTreasure({ inPocket: this.riches }) + this.riches = 0 + const oldX = this.sprite.x + const oldY = this.sprite.y + + this.sprite.destroy() + this.sprite = sprites.create(assets.image`Militia Broken and Broke`) + this.sprite.x = oldX + this.sprite.y = oldY + } + } + private attack() { // Stop moving this.sprite.follow(this.currentTarget.sprite, 0)