44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Platformer.Core;
|
|
using Platformer.Mechanics;
|
|
using UnityEngine;
|
|
using static Platformer.Core.Simulation;
|
|
|
|
namespace Platformer.Gameplay
|
|
{
|
|
/// <summary>
|
|
/// Fired when the player triggers an attack (mouse left click / touch attack button).
|
|
/// EerieVillage BT5-Dev 2단계 신설 — 기획 04 §5 근거리 공격 1종 파일럿.
|
|
/// OnExecute 훅으로 카드 효과·특성 효과가 결합될 확장 지점 (개발 02 §2-1).
|
|
/// </summary>
|
|
public class PlayerAttack : Simulation.Event<PlayerAttack>
|
|
{
|
|
public PlayerController player;
|
|
public Vector2 direction; // 플레이어 facing 방향 (±1, 0)
|
|
|
|
public override void Execute()
|
|
{
|
|
if (player == null) return;
|
|
|
|
// 공격 애니메이션 트리거 (Animator에 "attack" trigger 있으면 재생 — 정적 스프라이트면 무시)
|
|
if (player.animator != null)
|
|
{
|
|
var attackHash = Animator.StringToHash("attack");
|
|
// SetTrigger는 미존재 파라미터여도 예외 없음
|
|
player.animator.SetTrigger(attackHash);
|
|
}
|
|
|
|
// 공격 효과음 (존재 시)
|
|
if (player.audioSource != null && player.attackAudio != null)
|
|
{
|
|
player.audioSource.PlayOneShot(player.attackAudio);
|
|
}
|
|
|
|
// 플레이어 앞에 판정 박스 발생
|
|
if (player.attackHitbox != null)
|
|
{
|
|
player.attackHitbox.Fire(direction);
|
|
}
|
|
}
|
|
}
|
|
}
|