new structure, spawner, rebind

This commit is contained in:
Martin
2022-11-08 19:45:57 +01:00
parent 5b098af31d
commit 279218b4c3
45 changed files with 1157 additions and 302 deletions

View 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);
}
}