mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 16:46:00 +00:00
Enemy projectiles
This commit is contained in:
@@ -15,7 +15,7 @@ export class Projectile extends Component {
|
||||
private piercesLeft = 0;
|
||||
private damage = 0;
|
||||
|
||||
public init(damage: number, pierces: number, angle: number): void {
|
||||
public setup(damage: number, pierces: number, angle: number): void {
|
||||
this.piercesLeft = pierces;
|
||||
this.damage = damage;
|
||||
|
||||
|
@@ -13,7 +13,7 @@ const { ccclass, property } = _decorator;
|
||||
export class ProjectileLauncher extends Component implements IProjectileLauncherSignaler {
|
||||
@property(Prefab) private projectilePrefab: Prefab;
|
||||
private projectileCollisionEvent = new Signal<ProjectileCollision>();
|
||||
private projectileLauncehdEvent = new Signal();
|
||||
private projectileLaunchedEvent = new Signal();
|
||||
|
||||
private projectileDamage: number;
|
||||
private projectilePierces: number;
|
||||
@@ -32,7 +32,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
|
||||
}
|
||||
|
||||
public get ProjectileLaunchedEvent(): ISignal {
|
||||
return this.projectileLauncehdEvent;
|
||||
return this.projectileLaunchedEvent;
|
||||
}
|
||||
|
||||
public init(projectileLifetime: number, projectileSpeed: number, projectileDamage: number, projectilePierces: number): void {
|
||||
@@ -61,7 +61,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
|
||||
private fireProjectile(startPosition: Vec3, direction: Vec2): void {
|
||||
direction = direction.normalize();
|
||||
const projectile: Projectile = this.projectilePool.borrow();
|
||||
projectile.init(this.projectileDamage, this.projectilePierces, getDegreeAngleFromDirection(direction.x, direction.y));
|
||||
projectile.setup(this.projectileDamage, this.projectilePierces, getDegreeAngleFromDirection(direction.x, direction.y));
|
||||
projectile.node.setWorldPosition(startPosition);
|
||||
projectile.node.active = true;
|
||||
projectile.ContactBeginEvent.on(this.onProjectileCollision, this);
|
||||
@@ -71,7 +71,7 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
|
||||
this.directions.push(direction);
|
||||
this.expireTimes.push(this.currentTime + this.projectileLifetime);
|
||||
|
||||
this.projectileLauncehdEvent.trigger({});
|
||||
this.projectileLaunchedEvent.trigger();
|
||||
}
|
||||
|
||||
private tryRemoveExpiredProjectiles(): void {
|
||||
|
Reference in New Issue
Block a user