- SkillData에 jumpToTarget, animationSpeed 필드 추가 - 점프 중 XZ를 타겟 위치로 lerp, 착지 시 스냅 - endClip 재생 중 점프 이동 비활성화 (IsInEndAnimation) - 보스/플레이어 겹침 시 플레이어를 밀어내는 방식으로 분리 처리 - 점프준비/점프/착지 3단계 스킬 & 패턴 구성 - UsePatternAction에 Target 블랙보드 변수 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
2.3 KiB
C#
78 lines
2.3 KiB
C#
using System;
|
|
using Colosseum.Skills;
|
|
using Unity.Behavior;
|
|
using UnityEngine;
|
|
using Action = Unity.Behavior.Action;
|
|
using Unity.Properties;
|
|
|
|
/// <summary>
|
|
/// 지정된 스킬을 사용하는 Behavior Tree Action.
|
|
/// 스킬 실행이 완료될 때까지 Running 상태를 유지합니다.
|
|
/// </summary>
|
|
[Serializable, GeneratePropertyBag]
|
|
[NodeDescription(name: "Use Skill", story: "[스킬] 사용", category: "Action", id: "799f1e8cfafa78b2d52ef61a6bbb29b9")]
|
|
public partial class UseSkillAction : Action
|
|
{
|
|
[SerializeReference] public BlackboardVariable<SkillData> 스킬;
|
|
[SerializeReference] public BlackboardVariable<GameObject> Target;
|
|
|
|
private SkillController skillController;
|
|
|
|
protected override Status OnStart()
|
|
{
|
|
// 스킬 데이터 확인
|
|
if (스킬?.Value == null)
|
|
{
|
|
Debug.LogWarning("[UseSkillAction] 스킬이 null입니다.");
|
|
return Status.Failure;
|
|
}
|
|
|
|
// SkillController 컴포넌트 가져오기
|
|
skillController = GameObject.GetComponent<SkillController>();
|
|
if (skillController == null)
|
|
{
|
|
Debug.LogWarning($"[UseSkillAction] SkillController를 찾을 수 없습니다: {GameObject.name}");
|
|
return Status.Failure;
|
|
}
|
|
|
|
// 스킬 실행 시도
|
|
bool success = skillController.ExecuteSkill(스킬.Value);
|
|
if (!success)
|
|
{
|
|
// 이미 다른 스킬 사용 중이거나 쿨타임
|
|
return Status.Failure;
|
|
}
|
|
|
|
// jumpToTarget 스킬이면 타겟 위치 전달
|
|
if (스킬.Value.JumpToTarget && Target?.Value != null)
|
|
{
|
|
var enemyBase = GameObject.GetComponent<Colosseum.Enemy.EnemyBase>();
|
|
enemyBase?.SetJumpTarget(Target.Value.transform.position);
|
|
}
|
|
|
|
return Status.Running;
|
|
}
|
|
|
|
protected override Status OnUpdate()
|
|
{
|
|
// SkillController가 해제된 경우
|
|
if (skillController == null)
|
|
{
|
|
return Status.Failure;
|
|
}
|
|
|
|
// 스킬 애니메이션이 종료되면 성공
|
|
if (!skillController.IsPlayingAnimation)
|
|
{
|
|
return Status.Success;
|
|
}
|
|
|
|
return Status.Running;
|
|
}
|
|
|
|
protected override void OnEnd()
|
|
{
|
|
skillController = null;
|
|
}
|
|
}
|