mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-12-08 13:49:29 +00:00
new structure, spawner, rebind
This commit is contained in:
15
assets/Scripts/Game/Collision/WeaponCollisionSystem.ts
Normal file
15
assets/Scripts/Game/Collision/WeaponCollisionSystem.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Collider2D, Contact2DType } from "cc";
|
||||
import { Enemy } from "../Enemy/Enemy";
|
||||
import { Weapon } from "../Weapon";
|
||||
|
||||
export class WeaponCollisionSystem {
|
||||
private weapon: Weapon;
|
||||
public constructor(weapon: Weapon) {
|
||||
this.weapon = weapon;
|
||||
weapon.Collider.on(Contact2DType.BEGIN_CONTACT, this.onWeaponContactBegin, this);
|
||||
}
|
||||
|
||||
private onWeaponContactBegin(_selfCollider: Collider2D, otherCollider: Collider2D): void {
|
||||
otherCollider.getComponent(Enemy).dealDamage(this.weapon.Damage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user