진행도에 따른 다음챕터 넘기기
This commit is contained in:
@@ -49,4 +49,8 @@ public class DialogNode : ScriptableObject
|
||||
[Header("Story")]
|
||||
[Tooltip("0이 아니면 이 노드 재생 시 화자(비우면 대화 주인 NPC)의 호감도를 이만큼 증감")]
|
||||
public int Affection;
|
||||
|
||||
[Tooltip("0이 아니면 이 노드 재생 시 메인 진행도를 이만큼 증가. " +
|
||||
"분기 끝 노드마다 다른 값을 주면 선택지에 따라 진행도를 다르게 줄 수 있다")]
|
||||
public int Progress;
|
||||
}
|
||||
|
||||
@@ -425,6 +425,10 @@ private async Awaitable PlayNode(DialogNode node)
|
||||
StoryManager.Instance.AddAffection(affectionTarget, node.Affection);
|
||||
}
|
||||
|
||||
// 메인 진행도 증가 — 분기 끝 노드마다 다른 값을 주면 선택지에 따라 진행도가 달라진다
|
||||
if (node.Progress != 0)
|
||||
StoryManager.Instance.MainProgress += node.Progress;
|
||||
|
||||
// 전용 BGM: 설정돼 있으면 교체, 비어 있으면 기본 BGM으로 복귀
|
||||
if (SoundManager.Instance != null)
|
||||
{
|
||||
|
||||
@@ -98,6 +98,7 @@ public override void OnImportAsset(AssetImportContext ctx)
|
||||
dn.ForcePlayerLook = GetInputPortValue<bool>(gn.GetInputPortByName(DialogLineNode.PORT_FORCELOOK));
|
||||
dn.WaitForInput = GetInputPortValue<bool>(gn.GetInputPortByName(DialogLineNode.PORT_WAITINPUT));
|
||||
dn.Affection = GetInputPortValue<int>(gn.GetInputPortByName(DialogLineNode.PORT_AFFECTION));
|
||||
dn.Progress = GetInputPortValue<int>(gn.GetInputPortByName(DialogLineNode.PORT_PROGRESS));
|
||||
|
||||
string eventKey = null;
|
||||
line.GetNodeOptionByName(DialogLineNode.OPTION_EVENT_KEY)?.TryGetValue(out eventKey);
|
||||
@@ -145,6 +146,7 @@ static void FillStagingNode(DialogStagingNode gn, DialogNode dn)
|
||||
dn.LookAtPlayer = GetInputPortValue<bool>(gn.GetInputPortByName(DialogStagingNode.PORT_LOOKAT));
|
||||
dn.ForcePlayerLook = GetInputPortValue<bool>(gn.GetInputPortByName(DialogStagingNode.PORT_FORCELOOK));
|
||||
dn.Affection = GetInputPortValue<int>(gn.GetInputPortByName(DialogStagingNode.PORT_AFFECTION));
|
||||
dn.Progress = GetInputPortValue<int>(gn.GetInputPortByName(DialogStagingNode.PORT_PROGRESS));
|
||||
|
||||
string eventKey = null;
|
||||
gn.GetNodeOptionByName(DialogStagingNode.OPTION_EVENT_KEY)?.TryGetValue(out eventKey);
|
||||
|
||||
@@ -28,6 +28,7 @@ internal class DialogLineNode : DialogGraphNode
|
||||
public const string PORT_FORCELOOK = "ForcePlayerLook";
|
||||
public const string PORT_WAITINPUT = "WaitForInput";
|
||||
public const string PORT_AFFECTION = "Affection";
|
||||
public const string PORT_PROGRESS = "Progress";
|
||||
public const string PORT_QUESTION = "ChoiceQuestion";
|
||||
|
||||
public const string OPTION_CHOICE_COUNT = "ChoiceCount";
|
||||
@@ -77,6 +78,8 @@ protected override void OnDefinePorts(IPortDefinitionContext context)
|
||||
context.AddInputPort<bool>(PORT_WAITINPUT).WithDisplayName("Wait For Input").Build();
|
||||
context.AddInputPort<int>(PORT_AFFECTION).WithDisplayName("Affection ±")
|
||||
.WithTooltip("0이 아니면 이 대사 재생 시 화자(비우면 대화 주인 NPC)의 호감도를 이만큼 증감").Build();
|
||||
context.AddInputPort<int>(PORT_PROGRESS).WithDisplayName("Progress +")
|
||||
.WithTooltip("0이 아니면 이 대사 재생 시 메인 진행도를 이만큼 증가 (분기 끝 노드에 달아 선택지별로 다르게)").Build();
|
||||
|
||||
int choiceCount = 0;
|
||||
GetNodeOptionByName(OPTION_CHOICE_COUNT)?.TryGetValue(out choiceCount);
|
||||
|
||||
@@ -20,6 +20,7 @@ internal class DialogStagingNode : DialogGraphNode
|
||||
public const string PORT_LOOKAT = "LookAtPlayer";
|
||||
public const string PORT_FORCELOOK = "ForcePlayerLook";
|
||||
public const string PORT_AFFECTION = "Affection";
|
||||
public const string PORT_PROGRESS = "Progress";
|
||||
|
||||
public const string OPTION_EVENT_KEY = "EventKey";
|
||||
|
||||
@@ -51,6 +52,8 @@ protected override void OnDefinePorts(IPortDefinitionContext context)
|
||||
.WithTooltip("플레이어가 대상 캐릭터를 바라봄").Build();
|
||||
context.AddInputPort<int>(PORT_AFFECTION).WithDisplayName("Affection ±")
|
||||
.WithTooltip("0이 아니면 이 연출 재생 시 대상(비우면 대화 주인 NPC)의 호감도를 이만큼 증감").Build();
|
||||
context.AddInputPort<int>(PORT_PROGRESS).WithDisplayName("Progress +")
|
||||
.WithTooltip("0이 아니면 이 연출 재생 시 메인 진행도를 이만큼 증가").Build();
|
||||
|
||||
AddExecOutput(context, EXEC_OUT, string.Empty);
|
||||
}
|
||||
|
||||
51
Assets/02_Scripts/Story/ChapterChanger.cs
Normal file
51
Assets/02_Scripts/Story/ChapterChanger.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
// 스토리 진행도(MainProgress)에 따라 다음 씬을 골라 전환한다.
|
||||
// EventZoneTrigger / 대화 노드 이벤트 / 버튼 등에서 NextChapterScene()을 연결해 사용.
|
||||
public class ChapterChanger : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct ChapterEntry
|
||||
{
|
||||
[Tooltip("진행도가 이 값 이상이면 이 씬으로 (조건을 만족하는 항목 중 가장 높은 것이 선택됨)")]
|
||||
[Min(0)] public int MinProgress;
|
||||
|
||||
[Tooltip("전환할 씬 이름 (Build Settings에 등록돼 있어야 함)")]
|
||||
public string SceneName;
|
||||
}
|
||||
|
||||
[Tooltip("진행도 구간별 다음 씬. 예) 0→Chapter1, 3→Chapter2, 7→Chapter3 (순서는 상관없음)")]
|
||||
[SerializeField] private List<ChapterEntry> _chapters = new();
|
||||
|
||||
// 현재 진행도에 맞는 씬을 골라 페이드 아웃과 함께 전환
|
||||
// (시야/스카이박스 페이드와 로딩 화면은 SceneLoadManager가 처리)
|
||||
public void NextChapterScene()
|
||||
{
|
||||
int progress = StoryManager.Instance != null ? StoryManager.Instance.MainProgress : 0;
|
||||
|
||||
string sceneName = ResolveScene(progress);
|
||||
if (string.IsNullOrEmpty(sceneName))
|
||||
{
|
||||
Debug.LogWarning($"[ChapterChanger] 진행도 {progress}에 맞는 씬이 없음: {name}");
|
||||
return;
|
||||
}
|
||||
|
||||
SceneLoadManager.Instance.RequestSceneChange(sceneName);
|
||||
}
|
||||
|
||||
// 진행도 이하의 MinProgress 중 가장 높은 항목의 씬 이름 (없으면 null)
|
||||
private string ResolveScene(int progress)
|
||||
{
|
||||
string best = null;
|
||||
int bestMin = int.MinValue;
|
||||
foreach (var entry in _chapters)
|
||||
{
|
||||
if (string.IsNullOrEmpty(entry.SceneName)) continue;
|
||||
if (entry.MinProgress > progress || entry.MinProgress < bestMin) continue;
|
||||
bestMin = entry.MinProgress;
|
||||
best = entry.SceneName;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Story/ChapterChanger.cs.meta
Normal file
2
Assets/02_Scripts/Story/ChapterChanger.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 194c9e600cf7c974fb3e35721e1590b3
|
||||
Reference in New Issue
Block a user