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

16 lines
506 B
TypeScript
Raw Normal View History

2022-11-28 10:49:16 +00:00
import { Collider2D } from "cc";
2022-11-28 11:19:04 +00:00
import { Enemy } from "../Unit/Enemy/Enemy";
2022-11-28 10:49:16 +00:00
import { Weapon } from "../Unit/Player/Weapon/Weapon";
2022-11-08 18:45:57 +00:00
export class WeaponCollisionSystem {
private weapon: Weapon;
public constructor(weapon: Weapon) {
this.weapon = weapon;
2022-11-28 10:49:16 +00:00
weapon.Collider.ContactBeginEvent.on(this.onWeaponContactBegin, this);
2022-11-08 18:45:57 +00:00
}
2022-11-28 10:49:16 +00:00
private onWeaponContactBegin(otherCollider: Collider2D): void {
2022-11-08 18:45:57 +00:00
otherCollider.getComponent(Enemy).dealDamage(this.weapon.Damage);
}
}