Slash-The-Hordes/assets/Scripts/Game/Collision/PlayerProjectileCollisionSystem.ts

17 lines
757 B
TypeScript
Raw Normal View History

2022-12-22 11:08:00 +00:00
import { IProjectileLauncherSignaler } from "../Projectile/IProjectileLauncherSignaler";
2022-11-30 07:21:22 +00:00
import { ProjectileCollision } from "../Projectile/ProjectileCollision";
import { Enemy } from "../Unit/Enemy/Enemy";
export class PlayerProjectileCollisionSystem {
2022-12-22 11:08:00 +00:00
public constructor(collisionSignalers: IProjectileLauncherSignaler[]) {
2022-11-30 10:44:20 +00:00
for (const collisionSignaler of collisionSignalers) {
collisionSignaler.ProjectileCollisionEvent.on(this.onProjectileCollision, this);
}
2022-11-30 07:21:22 +00:00
}
private onProjectileCollision(projectileCollision: ProjectileCollision): void {
2022-12-13 10:58:40 +00:00
projectileCollision.otherCollider.getComponent(Enemy).dealDamage(projectileCollision.projectile.Damage);
projectileCollision.projectile.pierce();
2022-11-30 07:21:22 +00:00
}
}