2026-07-05 대화시스템 수정
This commit is contained in:
41
Assets/02_Scripts/Communication/Dialog/DialogCondition.cs
Normal file
41
Assets/02_Scripts/Communication/Dialog/DialogCondition.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
// DialogGroup 하나가 활성화되기 위한 조건 묶음. 모든 항목을 만족해야 한다(AND).
|
||||
// 값이 0이거나 목록이 비어있으면 그 항목은 조건 없음으로 통과된다.
|
||||
[Serializable]
|
||||
public class DialogCondition
|
||||
{
|
||||
[Tooltip("메인 진행도가 이 값 이상이어야 함 (0 = 조건 없음)")]
|
||||
[Min(0)] public int MinMainProgress;
|
||||
|
||||
[Tooltip("이 NPC의 호감도가 이 값 이상이어야 함 (0 = 조건 없음)")]
|
||||
[Min(0)] public int MinAffection;
|
||||
|
||||
[Tooltip("먼저 완료했어야 하는 대화들 (전부 완료 필요)")]
|
||||
public List<DialogGroup> RequiredDialogs = new();
|
||||
|
||||
[Tooltip("골랐어야 하는 선택지 Code들 (전부 필요)")]
|
||||
public List<string> RequiredChoiceCodes = new();
|
||||
|
||||
// affectionTarget: 호감도 조건을 검사할 캐릭터 (보통 대화를 거는 NPC 자신)
|
||||
public bool IsMet(CharacterData affectionTarget)
|
||||
{
|
||||
if (StoryState.MainProgress < MinMainProgress)
|
||||
return false;
|
||||
|
||||
if (MinAffection > 0 && StoryState.GetAffection(affectionTarget) < MinAffection)
|
||||
return false;
|
||||
|
||||
foreach (var group in RequiredDialogs)
|
||||
if (group != null && !StoryState.IsDialogCompleted(group.name))
|
||||
return false;
|
||||
|
||||
foreach (var code in RequiredChoiceCodes)
|
||||
if (!string.IsNullOrEmpty(code) && !StoryState.HasChosen(code))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user