From 1b74e347bf4bdd9016d4d87c9b82dffb3d45c930 Mon Sep 17 00:00:00 2001 From: nakjun Date: Tue, 14 Jul 2026 18:10:13 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=84=ED=96=89=EB=8F=84=EC=97=90=20?= =?UTF-8?q?=EB=94=B0=EB=A5=B8=20=EB=8B=A4=EC=9D=8C=EC=B1=95=ED=84=B0=20?= =?UTF-8?q?=EB=84=98=EA=B8=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/01_Scenes/MyHouse.unity | 4 +- .../Communication/Dialog/DialogNode.cs | 4 ++ .../Communication/Dialog/DialogPlayer.cs | 4 ++ .../GraphTool/Editor/DialogGraphImporter.cs | 2 + .../Dialog/GraphTool/Editor/DialogLineNode.cs | 3 + .../GraphTool/Editor/DialogStagingNode.cs | 3 + Assets/02_Scripts/Story/ChapterChanger.cs | 51 ++++++++++++++++ .../02_Scripts/Story/ChapterChanger.cs.meta | 2 + .../Chapter1/Chapter1_Carnotaurus4.dlg | 60 +++++++++++++++++++ .../Chapter1/Chapter1_Carnotaurus5.dlg | 36 +++++++++++ .../Prefabs/Interior/Room/Bed5_C1.prefab | 4 +- 11 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 Assets/02_Scripts/Story/ChapterChanger.cs create mode 100644 Assets/02_Scripts/Story/ChapterChanger.cs.meta diff --git a/Assets/01_Scenes/MyHouse.unity b/Assets/01_Scenes/MyHouse.unity index 1ab0b5c5..816b9dc2 100644 --- a/Assets/01_Scenes/MyHouse.unity +++ b/Assets/01_Scenes/MyHouse.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2b326aac592af754083669e98cffe8de993429854fdbccdb00ff99d902afae5d -size 1291419 +oid sha256:1c84ef2eaa29b9db04a66177e157d829e8a1cf2b4382533c41d5e102e6741c6d +size 1291244 diff --git a/Assets/02_Scripts/Communication/Dialog/DialogNode.cs b/Assets/02_Scripts/Communication/Dialog/DialogNode.cs index 3c79f9ec..490efe1a 100644 --- a/Assets/02_Scripts/Communication/Dialog/DialogNode.cs +++ b/Assets/02_Scripts/Communication/Dialog/DialogNode.cs @@ -49,4 +49,8 @@ public class DialogNode : ScriptableObject [Header("Story")] [Tooltip("0이 아니면 이 노드 재생 시 화자(비우면 대화 주인 NPC)의 호감도를 이만큼 증감")] public int Affection; + + [Tooltip("0이 아니면 이 노드 재생 시 메인 진행도를 이만큼 증가. " + + "분기 끝 노드마다 다른 값을 주면 선택지에 따라 진행도를 다르게 줄 수 있다")] + public int Progress; } diff --git a/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs b/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs index 9522f46a..2c6b8cef 100644 --- a/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs +++ b/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs @@ -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) { diff --git a/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogGraphImporter.cs b/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogGraphImporter.cs index ddf0f01e..e249ea94 100644 --- a/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogGraphImporter.cs +++ b/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogGraphImporter.cs @@ -98,6 +98,7 @@ public override void OnImportAsset(AssetImportContext ctx) dn.ForcePlayerLook = GetInputPortValue(gn.GetInputPortByName(DialogLineNode.PORT_FORCELOOK)); dn.WaitForInput = GetInputPortValue(gn.GetInputPortByName(DialogLineNode.PORT_WAITINPUT)); dn.Affection = GetInputPortValue(gn.GetInputPortByName(DialogLineNode.PORT_AFFECTION)); + dn.Progress = GetInputPortValue(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(gn.GetInputPortByName(DialogStagingNode.PORT_LOOKAT)); dn.ForcePlayerLook = GetInputPortValue(gn.GetInputPortByName(DialogStagingNode.PORT_FORCELOOK)); dn.Affection = GetInputPortValue(gn.GetInputPortByName(DialogStagingNode.PORT_AFFECTION)); + dn.Progress = GetInputPortValue(gn.GetInputPortByName(DialogStagingNode.PORT_PROGRESS)); string eventKey = null; gn.GetNodeOptionByName(DialogStagingNode.OPTION_EVENT_KEY)?.TryGetValue(out eventKey); diff --git a/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogLineNode.cs b/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogLineNode.cs index 9a1ebc2a..4dc1b2fa 100644 --- a/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogLineNode.cs +++ b/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogLineNode.cs @@ -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(PORT_WAITINPUT).WithDisplayName("Wait For Input").Build(); context.AddInputPort(PORT_AFFECTION).WithDisplayName("Affection ±") .WithTooltip("0이 아니면 이 대사 재생 시 화자(비우면 대화 주인 NPC)의 호감도를 이만큼 증감").Build(); + context.AddInputPort(PORT_PROGRESS).WithDisplayName("Progress +") + .WithTooltip("0이 아니면 이 대사 재생 시 메인 진행도를 이만큼 증가 (분기 끝 노드에 달아 선택지별로 다르게)").Build(); int choiceCount = 0; GetNodeOptionByName(OPTION_CHOICE_COUNT)?.TryGetValue(out choiceCount); diff --git a/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogStagingNode.cs b/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogStagingNode.cs index a0337aad..93d962d3 100644 --- a/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogStagingNode.cs +++ b/Assets/02_Scripts/Communication/Dialog/GraphTool/Editor/DialogStagingNode.cs @@ -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(PORT_AFFECTION).WithDisplayName("Affection ±") .WithTooltip("0이 아니면 이 연출 재생 시 대상(비우면 대화 주인 NPC)의 호감도를 이만큼 증감").Build(); + context.AddInputPort(PORT_PROGRESS).WithDisplayName("Progress +") + .WithTooltip("0이 아니면 이 연출 재생 시 메인 진행도를 이만큼 증가").Build(); AddExecOutput(context, EXEC_OUT, string.Empty); } diff --git a/Assets/02_Scripts/Story/ChapterChanger.cs b/Assets/02_Scripts/Story/ChapterChanger.cs new file mode 100644 index 00000000..d47a2018 --- /dev/null +++ b/Assets/02_Scripts/Story/ChapterChanger.cs @@ -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 _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; + } +} diff --git a/Assets/02_Scripts/Story/ChapterChanger.cs.meta b/Assets/02_Scripts/Story/ChapterChanger.cs.meta new file mode 100644 index 00000000..c6f9ba60 --- /dev/null +++ b/Assets/02_Scripts/Story/ChapterChanger.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 194c9e600cf7c974fb3e35721e1590b3 \ No newline at end of file diff --git a/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus4.dlg b/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus4.dlg index 816993e1..a896d49c 100644 --- a/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus4.dlg +++ b/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus4.dlg @@ -329,6 +329,7 @@ MonoBehaviour: - ForcePlayerLook - HudAnchor - Affection + - Progress m_ValueList: - rid: 4848514365209968924 - rid: 4848514365209968925 @@ -351,6 +352,7 @@ MonoBehaviour: - rid: 4848514453388656825 - rid: 4848514455607443550 - rid: 4848514548136411248 + - rid: 4848514551248584809 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -508,6 +510,7 @@ MonoBehaviour: - ForcePlayerLook - HudAnchor - Affection + - Progress m_ValueList: - rid: 4848514453388656663 - rid: 4848514453388656664 @@ -525,6 +528,7 @@ MonoBehaviour: - rid: 4848514453388656827 - rid: 4848514455607443551 - rid: 4848514548136411249 + - rid: 4848514551248584810 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -658,6 +662,7 @@ MonoBehaviour: - ForcePlayerLook - HudAnchor - Affection + - Progress m_ValueList: - rid: 4848514453388656678 - rid: 4848514453388656679 @@ -675,6 +680,7 @@ MonoBehaviour: - rid: 4848514453388656829 - rid: 4848514455607443552 - rid: 4848514548136411250 + - rid: 4848514551248584811 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -808,6 +814,7 @@ MonoBehaviour: - ForcePlayerLook - HudAnchor - Affection + - Progress m_ValueList: - rid: 4848514453388656693 - rid: 4848514453388656694 @@ -825,6 +832,7 @@ MonoBehaviour: - rid: 4848514453388656831 - rid: 4848514455607443553 - rid: 4848514548136411251 + - rid: 4848514551248584812 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -958,6 +966,7 @@ MonoBehaviour: - ForcePlayerLook - HudAnchor - Affection + - Progress m_ValueList: - rid: 4848514453388656708 - rid: 4848514453388656709 @@ -975,6 +984,7 @@ MonoBehaviour: - rid: 4848514453388656833 - rid: 4848514455607443554 - rid: 4848514548136411252 + - rid: 4848514551248584813 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1109,6 +1119,7 @@ MonoBehaviour: - ForcePlayerLook - HudAnchor - Affection + - Progress m_ValueList: - rid: 4848514453388656723 - rid: 4848514453388656724 @@ -1126,6 +1137,7 @@ MonoBehaviour: - rid: 4848514453388656835 - rid: 4848514455607443555 - rid: 4848514548136411253 + - rid: 4848514551248584814 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1307,6 +1319,7 @@ MonoBehaviour: - LookAtPlayer - ForcePlayerLook - Affection + - Progress m_ValueList: - rid: 4848514453388656889 - rid: 4848514453388656890 @@ -1318,6 +1331,7 @@ MonoBehaviour: - rid: 4848514453388656896 - rid: 4848514453388656897 - rid: 4848514548136411254 + - rid: 4848514551248584815 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1462,6 +1476,7 @@ MonoBehaviour: - ForcePlayerLook - WaitForInput - Affection + - Progress m_ValueList: - rid: 4848514455607443558 - rid: 4848514455607443559 @@ -1479,6 +1494,7 @@ MonoBehaviour: - rid: 4848514455607443571 - rid: 4848514455607443572 - rid: 4848514548136411255 + - rid: 4848514551248584816 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1626,6 +1642,7 @@ MonoBehaviour: - ForcePlayerLook - WaitForInput - Affection + - Progress m_ValueList: - rid: 4848514455607443613 - rid: 4848514455607443614 @@ -1643,6 +1660,7 @@ MonoBehaviour: - rid: 4848514455607443626 - rid: 4848514455607443627 - rid: 4848514548136411256 + - rid: 4848514551248584817 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1789,6 +1807,7 @@ MonoBehaviour: - ForcePlayerLook - WaitForInput - Affection + - Progress m_ValueList: - rid: 4848514455607443631 - rid: 4848514455607443632 @@ -1806,6 +1825,7 @@ MonoBehaviour: - rid: 4848514455607443644 - rid: 4848514455607443645 - rid: 4848514548136411257 + - rid: 4848514551248584818 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1960,3 +1980,43 @@ MonoBehaviour: type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} data: m_Value: 0 + - rid: 4848514551248584809 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584810 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584811 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584812 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584813 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584814 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584815 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584816 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584817 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584818 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 1 diff --git a/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus5.dlg b/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus5.dlg index 8e09c753..9a355673 100644 --- a/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus5.dlg +++ b/Assets/07_Data/DialogGraph/Chapter1/Chapter1_Carnotaurus5.dlg @@ -197,6 +197,8 @@ MonoBehaviour: - SpeakerNameOverride - ForcePlayerLook - HudAnchor + - Affection + - Progress m_ValueList: - rid: 4848514365209968924 - rid: 4848514365209968925 @@ -213,6 +215,8 @@ MonoBehaviour: - rid: 4848514453388656869 - rid: 4848514453388656825 - rid: 4848514455607443550 + - rid: 4848514551248584819 + - rid: 4848514551248584820 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -359,6 +363,8 @@ MonoBehaviour: - LookAtPlayer - ForcePlayerLook - WaitForInput + - Affection + - Progress m_ValueList: - rid: 4848514455607443649 - rid: 4848514455607443650 @@ -375,6 +381,8 @@ MonoBehaviour: - rid: 4848514455607443661 - rid: 4848514455607443662 - rid: 4848514455607443663 + - rid: 4848514551248584821 + - rid: 4848514551248584822 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -520,6 +528,8 @@ MonoBehaviour: - LookAtPlayer - ForcePlayerLook - WaitForInput + - Affection + - Progress m_ValueList: - rid: 4848514455607443667 - rid: 4848514455607443668 @@ -536,6 +546,8 @@ MonoBehaviour: - rid: 4848514455607443679 - rid: 4848514455607443680 - rid: 4848514455607443681 + - rid: 4848514551248584823 + - rid: 4848514551248584824 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -648,3 +660,27 @@ MonoBehaviour: - rid: 4848514455607443682 type: {class: DialogLineNode, ns: DinoLove.Dialog.GraphTool.Editor, asm: Assembly-CSharp-Editor} data: + - rid: 4848514551248584819 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584820 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584821 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584822 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584823 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 0 + - rid: 4848514551248584824 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: UnityEditor.GraphToolkitModule} + data: + m_Value: 1 diff --git a/Assets/LowPolyInterior2/Prefabs/Interior/Room/Bed5_C1.prefab b/Assets/LowPolyInterior2/Prefabs/Interior/Room/Bed5_C1.prefab index 24cf3acc..6fe2cd22 100644 --- a/Assets/LowPolyInterior2/Prefabs/Interior/Room/Bed5_C1.prefab +++ b/Assets/LowPolyInterior2/Prefabs/Interior/Room/Bed5_C1.prefab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b2c41e3117c4ce1bb97707de2e8b480a046bee5f4a78906aed48ac801a3df085 -size 2774 +oid sha256:e7c4175d4f13c22c11c257039035293f957872486bd200546b84c1dd841f9ceb +size 15289