2026-04-23 14:47:51 +00:00
|
|
|
using Platformer.Core;
|
|
|
|
|
using Platformer.Mechanics;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using static Platformer.Core.Simulation;
|
|
|
|
|
|
|
|
|
|
namespace Platformer.Gameplay
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2026-04-24 07:22:13 +00:00
|
|
|
/// Player attack event — fires on a periodic timer (no manual input).
|
|
|
|
|
/// BT7-Plan PD 지시 2026-04-24 — VS 순수형 자동 발동 전환 (공격 버튼 제거, 이동·점프만 남기고 공격은 주기 타이머).
|
|
|
|
|
/// Schedule<PlayerAttack>은 PlayerAttackTicker 컴포넌트가 일정 주기로 발화한다.
|
|
|
|
|
/// OnExecute 훅으로 카드 효과·특성 효과가 결합될 확장 지점 유지 (개발 02 §2-1).
|
2026-04-23 14:47:51 +00:00
|
|
|
/// </summary>
|
|
|
|
|
public class PlayerAttack : Simulation.Event<PlayerAttack>
|
|
|
|
|
{
|
|
|
|
|
public PlayerController player;
|
2026-04-24 07:22:13 +00:00
|
|
|
public Vector2 direction; // 플레이어 facing 방향 (±1, 0) — PlayerController.facing 기반
|
2026-04-23 14:47:51 +00:00
|
|
|
|
|
|
|
|
public override void Execute()
|
|
|
|
|
{
|
|
|
|
|
if (player == null) return;
|
|
|
|
|
|
2026-04-24 07:22:13 +00:00
|
|
|
// 공격 애니메이션 트리거 (Animator에 "attack" trigger 있으면 재생)
|
2026-04-23 14:47:51 +00:00
|
|
|
if (player.animator != null)
|
|
|
|
|
{
|
|
|
|
|
var attackHash = Animator.StringToHash("attack");
|
|
|
|
|
player.animator.SetTrigger(attackHash);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 공격 효과음 (존재 시)
|
|
|
|
|
if (player.audioSource != null && player.attackAudio != null)
|
|
|
|
|
{
|
|
|
|
|
player.audioSource.PlayOneShot(player.attackAudio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 플레이어 앞에 판정 박스 발생
|
|
|
|
|
if (player.attackHitbox != null)
|
|
|
|
|
{
|
|
|
|
|
player.attackHitbox.Fire(direction);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|