feat: 젬 장착 제약 시스템 추가
- 기반 스킬 분류를 도입하고 젬별 장착 가능 스킬 타입 조건을 추가함 - 동일 젬 중복 장착, 카테고리 상호 배타, 특정 젬 상호 배타를 로드아웃 검증에 반영함 - 테스트용 젬/스킬 자산과 디버그 생성 메뉴를 새 제약 구조에 맞게 갱신함 - Unity 재컴파일과 콘솔 확인으로 신규 컴파일 에러가 없음을 검증함
This commit is contained in:
@@ -5,6 +5,23 @@ using UnityEngine;
|
||||
|
||||
namespace Colosseum.Skills
|
||||
{
|
||||
/// <summary>
|
||||
/// 젬 장착 조건에서 사용하는 기반 스킬 분류입니다.
|
||||
/// 하나의 스킬이 여러 분류를 동시에 가질 수 있습니다.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SkillBaseType
|
||||
{
|
||||
None = 0,
|
||||
Attack = 1 << 0,
|
||||
Defense = 1 << 1,
|
||||
Support = 1 << 2,
|
||||
Control = 1 << 3,
|
||||
Mobility = 1 << 4,
|
||||
Utility = 1 << 5,
|
||||
All = Attack | Defense | Support | Control | Mobility | Utility,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 스킬 데이터. 스킬의 기본 정보와 효과 목록을 관리합니다.
|
||||
/// </summary>
|
||||
@@ -17,6 +34,10 @@ namespace Colosseum.Skills
|
||||
[SerializeField] private string description;
|
||||
[SerializeField] private Sprite icon;
|
||||
|
||||
[Header("기반 스킬 분류")]
|
||||
[Tooltip("젬 장착 가능 조건에 사용하는 기반 스킬 분류")]
|
||||
[SerializeField] private SkillBaseType baseTypes = SkillBaseType.None;
|
||||
|
||||
[Header("애니메이션")]
|
||||
[Tooltip("기본 Animator Controller의 'Skill' 상태에 덮어씌워질 클립")]
|
||||
[SerializeField] private AnimationClip skillClip;
|
||||
@@ -61,6 +82,7 @@ namespace Colosseum.Skills
|
||||
public string SkillName => skillName;
|
||||
public string Description => description;
|
||||
public Sprite Icon => icon;
|
||||
public SkillBaseType BaseTypes => baseTypes;
|
||||
public AnimationClip SkillClip => skillClip;
|
||||
public AnimationClip EndClip => endClip;
|
||||
public float AnimationSpeed => animationSpeed;
|
||||
|
||||
@@ -65,6 +65,14 @@ namespace Colosseum.Skills
|
||||
[Tooltip("젬의 주 역할 분류")]
|
||||
[SerializeField] private SkillGemCategory category = SkillGemCategory.Common;
|
||||
|
||||
[Header("장착 제약")]
|
||||
[Tooltip("장착 가능한 기반 스킬 분류입니다. None 또는 All이면 제한하지 않습니다.")]
|
||||
[SerializeField] private SkillBaseType allowedSkillTypes = SkillBaseType.All;
|
||||
[Tooltip("함께 장착할 수 없는 젬 분류")]
|
||||
[SerializeField] private SkillGemCategory[] incompatibleCategories = Array.Empty<SkillGemCategory>();
|
||||
[Tooltip("함께 장착할 수 없는 특정 젬")]
|
||||
[SerializeField] private List<SkillGemData> incompatibleGems = new();
|
||||
|
||||
[Header("기본 수치 보정")]
|
||||
[Tooltip("장착 시 마나 비용 배율")]
|
||||
[Min(0f)] [SerializeField] private float manaCostMultiplier = 1f;
|
||||
@@ -99,6 +107,7 @@ namespace Colosseum.Skills
|
||||
public string Description => description;
|
||||
public Sprite Icon => icon;
|
||||
public SkillGemCategory Category => category;
|
||||
public SkillBaseType AllowedSkillTypes => allowedSkillTypes;
|
||||
public float ManaCostMultiplier => manaCostMultiplier;
|
||||
public float CooldownMultiplier => cooldownMultiplier;
|
||||
public float CastSpeedMultiplier => castSpeedMultiplier;
|
||||
@@ -107,9 +116,59 @@ namespace Colosseum.Skills
|
||||
public float ShieldMultiplier => shieldMultiplier;
|
||||
public float ThreatMultiplier => threatMultiplier;
|
||||
public int AdditionalRepeatCount => additionalRepeatCount;
|
||||
public IReadOnlyList<SkillGemCategory> IncompatibleCategories => incompatibleCategories;
|
||||
public IReadOnlyList<SkillGemData> IncompatibleGems => incompatibleGems;
|
||||
public IReadOnlyList<SkillEffect> CastStartEffects => castStartEffects;
|
||||
public IReadOnlyList<SkillGemTriggeredEffectEntry> TriggeredEffects => triggeredEffects;
|
||||
public IReadOnlyList<AbnormalityData> SelfAbnormalities => selfAbnormalities;
|
||||
public IReadOnlyList<SkillGemTriggeredAbnormalityEntry> OnHitAbnormalities => onHitAbnormalities;
|
||||
|
||||
/// <summary>
|
||||
/// 지정한 기반 스킬에 이 젬을 장착할 수 있는지 확인합니다.
|
||||
/// </summary>
|
||||
public bool CanAttachToSkill(SkillData skill)
|
||||
{
|
||||
if (skill == null)
|
||||
return false;
|
||||
|
||||
if (allowedSkillTypes == SkillBaseType.None || allowedSkillTypes == SkillBaseType.All)
|
||||
return true;
|
||||
|
||||
return (allowedSkillTypes & skill.BaseTypes) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 지정한 젬 분류와 상호 배타적인지 확인합니다.
|
||||
/// </summary>
|
||||
public bool IsCategoryIncompatible(SkillGemCategory otherCategory)
|
||||
{
|
||||
if (incompatibleCategories == null || incompatibleCategories.Length == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < incompatibleCategories.Length; i++)
|
||||
{
|
||||
if (incompatibleCategories[i] == otherCategory)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 지정한 젬과 상호 배타적인지 확인합니다.
|
||||
/// </summary>
|
||||
public bool IsGemIncompatible(SkillGemData other)
|
||||
{
|
||||
if (other == null || incompatibleGems == null || incompatibleGems.Count == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < incompatibleGems.Count; i++)
|
||||
{
|
||||
if (incompatibleGems[i] == other)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Colosseum.Skills
|
||||
}
|
||||
}
|
||||
|
||||
copy.SanitizeInvalidGems();
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -56,7 +57,10 @@ namespace Colosseum.Skills
|
||||
|
||||
slotCount = Mathf.Max(0, slotCount);
|
||||
if (socketedGems != null && socketedGems.Length == slotCount)
|
||||
{
|
||||
SanitizeInvalidGems();
|
||||
return;
|
||||
}
|
||||
|
||||
SkillGemData[] resized = new SkillGemData[slotCount];
|
||||
if (socketedGems != null)
|
||||
@@ -69,21 +73,23 @@ namespace Colosseum.Skills
|
||||
}
|
||||
|
||||
socketedGems = resized;
|
||||
SanitizeInvalidGems();
|
||||
}
|
||||
|
||||
public void SetBaseSkill(SkillData skill)
|
||||
{
|
||||
baseSkill = skill;
|
||||
EnsureGemSlotCapacity();
|
||||
SanitizeInvalidGems();
|
||||
}
|
||||
|
||||
public void SetGem(int slotIndex, SkillGemData gem)
|
||||
{
|
||||
EnsureGemSlotCapacity();
|
||||
if (slotIndex < 0 || slotIndex >= socketedGems.Length)
|
||||
return;
|
||||
|
||||
socketedGems[slotIndex] = gem;
|
||||
if (!TrySetGem(slotIndex, gem, out string reason) && gem != null)
|
||||
{
|
||||
string skillName = baseSkill != null ? baseSkill.SkillName : "(없음)";
|
||||
Debug.LogWarning($"[SkillLoadout] 젬 장착 실패 | Skill={skillName} | Slot={slotIndex} | Gem={gem.GemName} | Reason={reason}");
|
||||
}
|
||||
}
|
||||
|
||||
public SkillGemData GetGem(int slotIndex)
|
||||
@@ -95,6 +101,64 @@ namespace Colosseum.Skills
|
||||
return socketedGems[slotIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 지정한 슬롯에 젬을 장착 시도하고, 실패 이유를 반환합니다.
|
||||
/// </summary>
|
||||
public bool TrySetGem(int slotIndex, SkillGemData gem, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
EnsureGemSlotCapacity();
|
||||
|
||||
if (slotIndex < 0 || slotIndex >= socketedGems.Length)
|
||||
{
|
||||
reason = "유효하지 않은 젬 슬롯입니다.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gem == null)
|
||||
{
|
||||
socketedGems[slotIndex] = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!TryValidateGemForSlot(slotIndex, gem, null, out reason))
|
||||
return false;
|
||||
|
||||
socketedGems[slotIndex] = gem;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 로드아웃의 잘못된 젬 조합을 제거합니다.
|
||||
/// </summary>
|
||||
public void SanitizeInvalidGems(bool logWarnings = false)
|
||||
{
|
||||
if (socketedGems == null || socketedGems.Length == 0)
|
||||
return;
|
||||
|
||||
List<SkillGemData> acceptedGems = new List<SkillGemData>(socketedGems.Length);
|
||||
for (int i = 0; i < socketedGems.Length; i++)
|
||||
{
|
||||
SkillGemData gem = socketedGems[i];
|
||||
if (gem == null)
|
||||
continue;
|
||||
|
||||
if (TryValidateGemForSlot(i, gem, acceptedGems, out string reason))
|
||||
{
|
||||
acceptedGems.Add(gem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (logWarnings)
|
||||
{
|
||||
string skillName = baseSkill != null ? baseSkill.SkillName : "(없음)";
|
||||
Debug.LogWarning($"[SkillLoadout] 젬 장착 제약으로 제거됨 | Skill={skillName} | Slot={i} | Gem={gem.GemName} | Reason={reason}");
|
||||
}
|
||||
|
||||
socketedGems[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public float GetResolvedManaCost()
|
||||
{
|
||||
if (baseSkill == null)
|
||||
@@ -347,6 +411,78 @@ namespace Colosseum.Skills
|
||||
abnormalityList.Add(abnormality);
|
||||
}
|
||||
|
||||
private bool TryValidateGemForSlot(int slotIndex, SkillGemData gem, IReadOnlyList<SkillGemData> acceptedGems, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
if (gem == null)
|
||||
return true;
|
||||
|
||||
if (baseSkill == null)
|
||||
{
|
||||
reason = "기반 스킬이 없는 슬롯에는 젬을 장착할 수 없습니다.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!gem.CanAttachToSkill(baseSkill))
|
||||
{
|
||||
reason = $"기반 스킬 분류 제약을 만족하지 않습니다. Skill={baseSkill.BaseTypes}, Allowed={gem.AllowedSkillTypes}";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (acceptedGems != null)
|
||||
{
|
||||
for (int i = 0; i < acceptedGems.Count; i++)
|
||||
{
|
||||
if (!TryValidateGemPair(gem, acceptedGems[i], out reason))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < socketedGems.Length; i++)
|
||||
{
|
||||
if (i == slotIndex)
|
||||
continue;
|
||||
|
||||
SkillGemData otherGem = socketedGems[i];
|
||||
if (otherGem == null)
|
||||
continue;
|
||||
|
||||
if (!TryValidateGemPair(gem, otherGem, out reason))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool TryValidateGemPair(SkillGemData gem, SkillGemData otherGem, out string reason)
|
||||
{
|
||||
reason = string.Empty;
|
||||
if (gem == null || otherGem == null)
|
||||
return true;
|
||||
|
||||
if (gem == otherGem)
|
||||
{
|
||||
reason = "동일한 젬은 하나의 스킬에 여러 개 장착할 수 없습니다.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gem.IsGemIncompatible(otherGem) || otherGem.IsGemIncompatible(gem))
|
||||
{
|
||||
reason = $"{gem.GemName}과 {otherGem.GemName}은 함께 장착할 수 없습니다.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gem.IsCategoryIncompatible(otherGem.Category) || otherGem.IsCategoryIncompatible(gem.Category))
|
||||
{
|
||||
reason = $"{gem.Category} / {otherGem.Category} 분류 조합은 허용되지 않습니다.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private float GetResolvedScalarMultiplier(System.Func<SkillGemData, float> selector)
|
||||
{
|
||||
if (baseSkill == null)
|
||||
|
||||
Reference in New Issue
Block a user