Merge 176160cacc2f48c39ee9c1dd2a966c60fde8db35 into a1806aaef773a2762d7670a2b6a2224eceec80f2

This commit is contained in:
Boy Cans S 2025-04-07 22:07:51 +07:00 committed by GitHub
commit 0e88a03546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,11 +16,13 @@ export class Weapon extends Component {
private strikeTimer: GameTimer; private strikeTimer: GameTimer;
private strikeState: AnimationState; private strikeState: AnimationState;
private damage: number; private damage: number;
private playerDirectionX: number;
public init(strikeDelay: number, damage: number): void { public init(strikeDelay: number, damage: number): void {
this.strikeTimer = new GameTimer(strikeDelay); this.strikeTimer = new GameTimer(strikeDelay);
this.damage = damage; this.damage = damage;
this.node.active = false; this.node.active = false;
this.setWeaponDirection();
this.weaponAnimation.on(Animation.EventType.FINISHED, this.endStrike, this); this.weaponAnimation.on(Animation.EventType.FINISHED, this.endStrike, this);
this.strikeState = this.weaponAnimation.getState(this.weaponAnimation.clips[0].name); this.strikeState = this.weaponAnimation.getState(this.weaponAnimation.clips[0].name);
@ -36,6 +38,11 @@ export class Weapon extends Component {
} }
} }
private setWeaponDirection(){
this.playerDirectionX = this.node.parent.getChildByName("PlayerGraphics").scale.x;
this.node.setScale(this.playerDirectionX,1,1);
}
public get WeaponStrikeEvent(): ISignal<Weapon> { public get WeaponStrikeEvent(): ISignal<Weapon> {
return this.weaponStrikeEvent; return this.weaponStrikeEvent;
} }
@ -57,6 +64,7 @@ export class Weapon extends Component {
private strike(): void { private strike(): void {
this.node.active = true; this.node.active = true;
this.setWeaponDirection();
this.weaponAnimation.play(this.strikeState.name); this.weaponAnimation.play(this.strikeState.name);
this.weaponStrikeEvent.trigger(this); this.weaponStrikeEvent.trigger(this);
} }