mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-28 04:28:03 +00:00
16 lines
506 B
TypeScript
16 lines
506 B
TypeScript
import { Collider2D } from "cc";
|
|
import { Enemy } from "../Unit/Enemy/Enemy";
|
|
import { Weapon } from "../Unit/Player/Weapon/Weapon";
|
|
|
|
export class WeaponCollisionSystem {
|
|
private weapon: Weapon;
|
|
public constructor(weapon: Weapon) {
|
|
this.weapon = weapon;
|
|
weapon.Collider.ContactBeginEvent.on(this.onWeaponContactBegin, this);
|
|
}
|
|
|
|
private onWeaponContactBegin(otherCollider: Collider2D): void {
|
|
otherCollider.getComponent(Enemy).dealDamage(this.weapon.Damage);
|
|
}
|
|
}
|