- SkillData에 jumpToTarget, animationSpeed 필드 추가 - 점프 중 XZ를 타겟 위치로 lerp, 착지 시 스냅 - endClip 재생 중 점프 이동 비활성화 (IsInEndAnimation) - 보스/플레이어 겹침 시 플레이어를 밀어내는 방식으로 분리 처리 - 점프준비/점프/착지 3단계 스킬 & 패턴 구성 - UsePatternAction에 Target 블랙보드 변수 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
128 lines
3.6 KiB
C#
128 lines
3.6 KiB
C#
using System;
|
|
using Colosseum.AI;
|
|
using Colosseum.Skills;
|
|
using Unity.Behavior;
|
|
using Unity.Properties;
|
|
using UnityEngine;
|
|
using Action = Unity.Behavior.Action;
|
|
|
|
/// <summary>
|
|
/// 보스 패턴을 실행하는 Behavior Tree Action.
|
|
/// 패턴 내 스텝(스킬 또는 대기)을 순서대로 실행하며, 패턴 쿨타임을 관리합니다.
|
|
/// </summary>
|
|
[Serializable, GeneratePropertyBag]
|
|
[NodeDescription(name: "Use Pattern", story: "[Pattern] 실행", category: "Action", id: "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6")]
|
|
public partial class UsePatternAction : Action
|
|
{
|
|
[SerializeReference] public BlackboardVariable<BossPatternData> Pattern;
|
|
[SerializeReference] public BlackboardVariable<GameObject> Target;
|
|
|
|
private SkillController skillController;
|
|
private int currentStepIndex;
|
|
private float waitEndTime;
|
|
private bool isWaiting;
|
|
private float lastUsedTime = float.MinValue;
|
|
|
|
protected override Status OnStart()
|
|
{
|
|
if (Pattern?.Value == null)
|
|
{
|
|
Debug.LogWarning("[UsePatternAction] 패턴이 null입니다.");
|
|
return Status.Failure;
|
|
}
|
|
|
|
if (Time.time - lastUsedTime < Pattern.Value.Cooldown)
|
|
{
|
|
return Status.Failure;
|
|
}
|
|
|
|
if (Pattern.Value.Steps.Count == 0)
|
|
{
|
|
return Status.Failure;
|
|
}
|
|
|
|
skillController = GameObject.GetComponent<SkillController>();
|
|
if (skillController == null)
|
|
{
|
|
Debug.LogWarning($"[UsePatternAction] SkillController를 찾을 수 없습니다: {GameObject.name}");
|
|
return Status.Failure;
|
|
}
|
|
|
|
currentStepIndex = 0;
|
|
isWaiting = false;
|
|
return ExecuteCurrentStep();
|
|
}
|
|
|
|
protected override Status OnUpdate()
|
|
{
|
|
if (skillController == null)
|
|
return Status.Failure;
|
|
|
|
if (isWaiting)
|
|
{
|
|
if (Time.time < waitEndTime)
|
|
return Status.Running;
|
|
|
|
isWaiting = false;
|
|
}
|
|
else
|
|
{
|
|
if (skillController.IsPlayingAnimation)
|
|
return Status.Running;
|
|
|
|
}
|
|
|
|
currentStepIndex++;
|
|
|
|
if (currentStepIndex >= Pattern.Value.Steps.Count)
|
|
{
|
|
lastUsedTime = Time.time;
|
|
return Status.Success;
|
|
}
|
|
|
|
return ExecuteCurrentStep();
|
|
}
|
|
|
|
protected override void OnEnd()
|
|
{
|
|
skillController = null;
|
|
}
|
|
|
|
private Status ExecuteCurrentStep()
|
|
{
|
|
PatternStep step = Pattern.Value.Steps[currentStepIndex];
|
|
|
|
if (step.Type == PatternStepType.Wait)
|
|
{
|
|
isWaiting = true;
|
|
waitEndTime = Time.time + step.Duration;
|
|
return Status.Running;
|
|
}
|
|
|
|
// PatternStepType.Skill
|
|
if (step.Skill == null)
|
|
{
|
|
Debug.LogWarning($"[UsePatternAction] 스킬이 null입니다. (index {currentStepIndex})");
|
|
return Status.Failure;
|
|
}
|
|
|
|
bool success = skillController.ExecuteSkill(step.Skill);
|
|
if (!success)
|
|
{
|
|
Debug.LogWarning($"[UsePatternAction] 스킬 실행 실패: {step.Skill.SkillName} (index {currentStepIndex})");
|
|
return Status.Failure;
|
|
}
|
|
|
|
// jumpToTarget 스킬이면 타겟 위치 전달
|
|
if (step.Skill.JumpToTarget)
|
|
{
|
|
if (Target?.Value == null)
|
|
Debug.LogWarning($"[UsePatternAction] '{step.Skill.SkillName}'은 JumpToTarget 스킬이지만 Target이 바인딩되지 않았습니다.");
|
|
else
|
|
GameObject.GetComponent<Colosseum.Enemy.EnemyBase>()?.SetJumpTarget(Target.Value.transform.position);
|
|
}
|
|
|
|
return Status.Running;
|
|
}
|
|
}
|