- 기본기3 시작 프레임의 수평 루트모션 스냅을 차단하고 정면 투영/접촉 정지 거리 보정을 정리 - 스킬 완료 판정과 시작 타깃 정렬 로직을 보강하고 드로그/플레이어 정면 및 시작점 디버그 gizmo를 추가 - 드로그 기본기3 관련 애니메이션·패턴·스킬 자산을 재정리하고 Blender 보조 스크립트를 추가
89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
using Unity.Behavior;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
using Colosseum.Debugging;
|
|
using Colosseum.Stats;
|
|
|
|
namespace Colosseum.Enemy
|
|
{
|
|
/// <summary>
|
|
/// 보스 캐릭터입니다.
|
|
/// </summary>
|
|
public class BossEnemy : EnemyBase
|
|
{
|
|
private static readonly Color FacingGizmoColor = new Color(1f, 0.25f, 0.2f, 1f);
|
|
|
|
[Header("Boss Settings")]
|
|
[Tooltip("초기 Behavior Graph")]
|
|
[SerializeField] private BehaviorGraph initialBehaviorGraph;
|
|
|
|
[Header("Debug")]
|
|
[SerializeField] private bool debugMode = true;
|
|
|
|
// 컴포넌트
|
|
private BehaviorGraphAgent behaviorAgent;
|
|
|
|
// 정적 이벤트 (UI 자동 연결용)
|
|
/// <summary>
|
|
/// 보스 스폰 시 발생하는 정적 이벤트
|
|
/// </summary>
|
|
public static event System.Action<BossEnemy> OnBossSpawned;
|
|
|
|
/// <summary>
|
|
/// 현재 활성화된 보스 (Scene에 하나만 존재한다고 가정)
|
|
/// </summary>
|
|
public static BossEnemy ActiveBoss { get; private set; }
|
|
|
|
public override void OnNetworkSpawn()
|
|
{
|
|
base.OnNetworkSpawn();
|
|
|
|
// BehaviorGraphAgent 컴포넌트 확인/추가
|
|
behaviorAgent = GetComponent<BehaviorGraphAgent>();
|
|
if (behaviorAgent == null)
|
|
{
|
|
behaviorAgent = gameObject.AddComponent<BehaviorGraphAgent>();
|
|
}
|
|
|
|
// 초기 AI 설정
|
|
if (IsServer && initialBehaviorGraph != null)
|
|
{
|
|
behaviorAgent.Graph = initialBehaviorGraph;
|
|
}
|
|
|
|
// 정적 이벤트 발생 (UI 자동 연결용)
|
|
ActiveBoss = this;
|
|
OnBossSpawned?.Invoke(this);
|
|
|
|
if (debugMode)
|
|
{
|
|
Debug.Log($"[Boss] Boss spawned: {name}");
|
|
}
|
|
}
|
|
|
|
protected override void OnServerUpdate()
|
|
{
|
|
}
|
|
|
|
protected override void HandleDeath()
|
|
{
|
|
// AI 완전 중단 (순서 중요: enabled=false를 먼저 호출하여 Update() 차단)
|
|
if (behaviorAgent != null)
|
|
{
|
|
behaviorAgent.enabled = false; // 가장 먼저: Update() 호출 방지
|
|
behaviorAgent.End();
|
|
behaviorAgent.Graph = null;
|
|
}
|
|
behaviorAgent = null;
|
|
|
|
base.HandleDeath();
|
|
}
|
|
|
|
private void OnDrawGizmos()
|
|
{
|
|
FacingDirectionGizmoUtility.DrawFacingArrow(transform, FacingGizmoColor, length: 2.2f, headLength: 0.45f, headWidth: 0.28f, heightOffset: 0.15f, shaftThickness: 0.14f);
|
|
}
|
|
}
|
|
}
|