feat: 보스 패턴 시스템 구현
- BossPatternData SO로 스킬/Wait 스텝 순서와 쿨타임 정의 - UsePatternAction으로 Behavior Graph에서 패턴 실행 - 보스 전용 애니메이션 분리 및 AnimatorOverrideController 정상화 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
117
Assets/Scripts/AI/BehaviorActions/Actions/UsePatternAction.cs
Normal file
117
Assets/Scripts/AI/BehaviorActions/Actions/UsePatternAction.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return Status.Running;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a696fff0581f7264d9491514e9aee277
|
||||
38
Assets/Scripts/AI/BossPatternData.cs
Normal file
38
Assets/Scripts/AI/BossPatternData.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Colosseum.Skills;
|
||||
|
||||
namespace Colosseum.AI
|
||||
{
|
||||
public enum PatternStepType { Skill, Wait }
|
||||
|
||||
[System.Serializable]
|
||||
public class PatternStep
|
||||
{
|
||||
public PatternStepType Type = PatternStepType.Skill;
|
||||
public SkillData Skill;
|
||||
[Min(0f)] public float Duration = 0.5f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 보스 패턴 데이터. 순서대로 실행할 스텝(스킬 또는 대기) 목록과 쿨타임을 정의합니다.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "NewBossPattern", menuName = "Colosseum/Boss Pattern")]
|
||||
public class BossPatternData : ScriptableObject
|
||||
{
|
||||
[Header("패턴 정보")]
|
||||
[SerializeField] private string patternName;
|
||||
|
||||
[Header("스텝 순서")]
|
||||
[SerializeField] private List<PatternStep> steps = new List<PatternStep>();
|
||||
|
||||
[Header("쿨타임")]
|
||||
[Min(0f)]
|
||||
[Tooltip("패턴 완료 후 다시 사용 가능해지기까지의 시간")]
|
||||
[SerializeField] private float cooldown = 5f;
|
||||
|
||||
public string PatternName => patternName;
|
||||
public IReadOnlyList<PatternStep> Steps => steps;
|
||||
public float Cooldown => cooldown;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/AI/BossPatternData.cs.meta
Normal file
2
Assets/Scripts/AI/BossPatternData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ce956e0878565343974c31b8111c0c6
|
||||
@@ -8,7 +8,8 @@
|
||||
"Unity.InputSystem",
|
||||
"Unity.TextMeshPro",
|
||||
"Unity.Behavior",
|
||||
"Unity.Behavior.SerializableGUID"
|
||||
"Unity.Behavior.SerializableGUID",
|
||||
"Unity.Collections"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
Reference in New Issue
Block a user