using Platformer.Core; using Platformer.Mechanics; using UnityEngine; using static Platformer.Core.Simulation; namespace Platformer.Gameplay { /// /// Player attack event — fires on a periodic timer (no manual input). /// BT7-Plan PD 지시 2026-04-24 — VS 순수형 자동 발동 전환 (공격 버튼 제거, 이동·점프만 남기고 공격은 주기 타이머). /// Schedule은 PlayerAttackTicker 컴포넌트가 일정 주기로 발화한다. /// OnExecute 훅으로 카드 효과·특성 효과가 결합될 확장 지점 유지 (개발 02 §2-1). /// public class PlayerAttack : Simulation.Event { public PlayerController player; public Vector2 direction; // 플레이어 facing 방향 (±1, 0) — PlayerController.facing 기반 /// 리뉴얼 2026-11-10 — 근접 자동 공격이 타격을 직접 처리했으면 true (판정 박스 중복 타격 방지). public bool strikeHandled; public override void Execute() { if (player == null) return; // 공격 애니메이션 트리거 (Animator에 "attack" trigger 있으면 재생) 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 && !strikeHandled) { player.attackHitbox.Fire(direction); } strikeHandled = false; // 이벤트 객체 재사용(풀) 대비 초기화 // [BT5-Dev Hero1 2026-05-07] combatidle 5초 타이머 갱신 (PlayerStateTimer.NotifyAttackFired) var stateTimer = player.GetComponent(); if (stateTimer != null) stateTimer.NotifyAttackFired(); } } }