Skip to content

Commit

Permalink
Loot the bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikketer committed Jul 15, 2024
1 parent 1acfa94 commit d1a2319
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
15 changes: 15 additions & 0 deletions militia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d1a2319

Please sign in to comment.