Adjust attack sound logic
This commit is contained in:
parent
798f3f7a64
commit
24ffb87af9
|
@ -288,10 +288,7 @@ export class AnimalEntity extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attack(ctx: WorldContext) {
|
attack(ctx: WorldContext) {
|
||||||
this.yell(1)
|
|
||||||
if (this.isMonster) {
|
if (this.isMonster) {
|
||||||
let v = 1 + Math.floor(Math.random() * 4)
|
|
||||||
playSound(`action/hit-v${v}`, 1.0)
|
|
||||||
this.sprite.animate = true
|
this.sprite.animate = true
|
||||||
this.sprite.loop = false
|
this.sprite.loop = false
|
||||||
this.sprite.setKey = 'attack'
|
this.sprite.setKey = 'attack'
|
||||||
|
@ -321,14 +318,22 @@ export class AnimalEntity extends Entity {
|
||||||
box[1][1] += 20
|
box[1][1] += 20
|
||||||
}
|
}
|
||||||
|
|
||||||
let entities: AnimalEntity[] = ctx.queryEntities([box[0][0], box[1][0]], [box[0][1], box[1][1]]).filter(v=>v instanceof AnimalEntity && v !== this && !v.isMonster) as AnimalEntity[]
|
let entities: AnimalEntity[] = ctx.queryEntities([box[0][0], box[1][0]], [box[0][1], box[1][1]]).filter(v=>v instanceof AnimalEntity && v !== this && !v.isMonster && !v.dead) as AnimalEntity[]
|
||||||
if (entities.length > 0) {
|
if (entities.length > 0) {
|
||||||
|
let v = 1 + Math.floor(Math.random() * 4)
|
||||||
|
playSound(`action/hit-v${v}`, 1.0)
|
||||||
entities[0].dead = true
|
entities[0].dead = true
|
||||||
entities[0].shouldGib = true
|
entities[0].shouldGib = true
|
||||||
|
if (Math.random() > 0.5) {
|
||||||
|
this.yell(1)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// growl if there are no targets.
|
||||||
|
this.yell(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.yell(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yell(volume: number) {
|
yell(volume: number) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user