first
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
// 호감도 비교 연산자. (호감도 [연산자] Value)
|
||||
public enum AffectionCompare
|
||||
{
|
||||
[InspectorName("≥")] AtLeast,
|
||||
[InspectorName(">")] GreaterThan,
|
||||
[InspectorName("≤")] AtMost,
|
||||
[InspectorName("<")] LessThan,
|
||||
[InspectorName("=")] Equal,
|
||||
[InspectorName("≠")] NotEqual,
|
||||
}
|
||||
|
||||
// 다음 조건과 묶는 방식. AND가 OR보다 우선순위가 높다 (A and B or C → (A and B) or C).
|
||||
public enum AffectionJoin
|
||||
{
|
||||
[InspectorName("AND")] And,
|
||||
[InspectorName("OR")] Or,
|
||||
}
|
||||
|
||||
// 호감도 분기 노드가 검사하는 조건 하나. (캐릭터, 연산자, 값) + 다음 조건과의 연결자.
|
||||
// 여러 개를 이어 붙여 조건식을 만든다 — DialogNode.AffectionRequirements 참고.
|
||||
[Serializable]
|
||||
public class AffectionRequirement
|
||||
{
|
||||
// 검사 대상 캐릭터. 비우면 대화 주인 NPC의 호감도를 본다.
|
||||
public CharacterData Character;
|
||||
|
||||
// 호감도를 Value와 어떻게 비교할지
|
||||
public AffectionCompare Compare = AffectionCompare.AtLeast;
|
||||
|
||||
// 비교 기준값
|
||||
public int Value;
|
||||
|
||||
// 다음 조건과 묶는 방식 (마지막 조건에서는 무시된다)
|
||||
public AffectionJoin JoinWithNext = AffectionJoin.And;
|
||||
|
||||
// 이 조건 하나의 성립 여부
|
||||
public bool IsMet(int affection) => Compare switch
|
||||
{
|
||||
AffectionCompare.AtLeast => affection >= Value,
|
||||
AffectionCompare.GreaterThan => affection > Value,
|
||||
AffectionCompare.AtMost => affection <= Value,
|
||||
AffectionCompare.LessThan => affection < Value,
|
||||
AffectionCompare.Equal => affection == Value,
|
||||
AffectionCompare.NotEqual => affection != Value,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user