진행도에 따른 다음챕터 넘기기
This commit is contained in:
BIN
Assets/01_Scenes/MyHouse.unity
LFS
BIN
Assets/01_Scenes/MyHouse.unity
LFS
Binary file not shown.
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user