From 77625e7ad58004bebd93e2c2c79cdcb6a243c017 Mon Sep 17 00:00:00 2001 From: Trey Shaw Date: Sat, 11 Apr 2026 22:04:39 -0500 Subject: [PATCH] fix quest bug checking wrong conditions --- Assets/Scenes/SampleScene.unity | 10 ++- Assets/Scripts/Management/GameManager.cs | 76 +++++++++++++++++++ Assets/Scripts/Management/MapPoint.cs | 10 +++ Assets/Scripts/Management/MapPoint.cs.meta | 2 + .../Management/Questing/QuestRegistry.cs | 10 ++- 5 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 Assets/Scripts/Management/MapPoint.cs create mode 100644 Assets/Scripts/Management/MapPoint.cs.meta diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 2b2ac27..05ab3c3 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1753,7 +1753,7 @@ Transform: serializedVersion: 2 m_LocalRotation: {x: -0.0007883741, y: 0.0012165046, z: -0.0015583121, w: 0.99999774} m_LocalPosition: {x: 10.801, y: 3.6573, z: 4.404} - m_LocalScale: {x: 0.12264277, y: 0.12264277, z: 0.12264277} + m_LocalScale: {x: 0.19202179, y: 0.19202179, z: 0.19202179} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1843688239} @@ -8391,6 +8391,14 @@ PrefabInstance: propertyPath: 'tools.Array.data[3]' value: objectReference: {fileID: 373047378} + - target: {fileID: 2715587763268303228, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3} + propertyPath: m_Lightmapping + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 5056434560497563343, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3} + propertyPath: m_LocalPosition.y + value: -0.78 + objectReference: {fileID: 0} - target: {fileID: 5526037850913171920, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3} propertyPath: m_LocalPosition.x value: -0.60945 diff --git a/Assets/Scripts/Management/GameManager.cs b/Assets/Scripts/Management/GameManager.cs index e3d1187..4252942 100644 --- a/Assets/Scripts/Management/GameManager.cs +++ b/Assets/Scripts/Management/GameManager.cs @@ -57,6 +57,81 @@ private void ReloadReferences() Instance.PlayerManager = GetComponent(); } + #region Map Load Handling + /// + /// Triggers transition to a map point + /// + public void GoToMapPoint(MapPoint mapPoint) + { + StartCoroutine(GoToMapPointCoroutine(mapPoint)); + } + + /// + /// Executes transition to map point (scene and location) + /// + private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint) + { + Instance.isTransitioningScenes = true; + Instance.playerController.SetCharacterControl(false); + + // Fade to black + float fadeDuration = 0.2f; // how long to fade to/from black + float moveDuration = 0.4f; // how long to auto walk into room from the door + float fadeTime = 0; + Color blackScreenColor = Color.black; + + while (fadeTime < fadeDuration) + { + blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration); + blackScreen.color = blackScreenColor; + fadeTime += Time.deltaTime; + yield return null; + } + fadeTime = 0; + + + AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(mapPoint.Scene); + while (!asyncLoad.isDone) + { + // Optional: Update a loading bar with asyncLoad.progress + yield return null; + } + + ReloadReferences(); + + // Make sure screen is black in new scene + blackScreen.color = blackScreenColor; + + if (Instance.playerController != null && GameSceneManager.Instance != null) + { + Instance.playerController.CharacterControllerMove(mapPoint.SpawnPosition - playerController.transform.position); + } + + // Fade back in + while (fadeTime < fadeDuration) + { + blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration); + Instance.blackScreen.color = blackScreenColor; + fadeTime += Time.deltaTime; + + yield return null; + } + + // move character a little more + while (fadeTime < moveDuration) + { + fadeTime += Time.deltaTime; + yield return null; + } + + fadeTime = 0; + + Instance.isTransitioningScenes = false; + Instance.playerController.SetCharacterControl(true); + } + #endregion + + #region Scene Door Handling /// /// Triggers transition to specified scene at the door with the specified ID /// @@ -136,6 +211,7 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId) Instance.isTransitioningScenes = false; Instance.playerController.SetCharacterControl(true); } + #endregion /// /// Are we currently in the middle of a scene transition? diff --git a/Assets/Scripts/Management/MapPoint.cs b/Assets/Scripts/Management/MapPoint.cs new file mode 100644 index 0000000..b10cf4b --- /dev/null +++ b/Assets/Scripts/Management/MapPoint.cs @@ -0,0 +1,10 @@ +using UnityEngine; + +// Gives a location to be teleported to and displayed on a map. This will be used by +// the game manager to allow for fast travel +[System.Serializable] +public class MapPoint +{ + public string Scene; + public Vector3 SpawnPosition; +} diff --git a/Assets/Scripts/Management/MapPoint.cs.meta b/Assets/Scripts/Management/MapPoint.cs.meta new file mode 100644 index 0000000..ebe1d30 --- /dev/null +++ b/Assets/Scripts/Management/MapPoint.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5c03ccad2a919f74d95b0d3a409412b9 \ No newline at end of file diff --git a/Assets/Scripts/Management/Questing/QuestRegistry.cs b/Assets/Scripts/Management/Questing/QuestRegistry.cs index 8548d58..28ae5bd 100644 --- a/Assets/Scripts/Management/Questing/QuestRegistry.cs +++ b/Assets/Scripts/Management/Questing/QuestRegistry.cs @@ -60,12 +60,12 @@ private void Awake() QuestBool[] QID2_List = new QuestBool[1]; // QID2_1_completedQuest3 - QID1_List[0] = new QuestBool(() => + QID2_List[0] = new QuestBool(() => { return CompletedQuests.Contains(3); }); - questBoolMap.Add(2, QID1_List); + questBoolMap.Add(2, QID2_List); #endregion #region 3 - (Story Quest #1.5) First Paycheck @@ -75,17 +75,18 @@ private void Awake() QuestBool[] QID3_List = new QuestBool[1]; // QID3_1_hasEnoughStarshards - QID1_List[0] = new QuestBool(() => + QID3_List[0] = new QuestBool(() => { return GameManager.Instance.Inventory.GetItemQuantity(ItemIdEnum.STAR_SHARD) > 0; }); - questBoolMap.Add(3, QID1_List); + questBoolMap.Add(3, QID3_List); #endregion return questBoolMap; } + #region Save/Load Quest Data // Save completed quests to disk public void SaveQuestData(ref QuestSaveData data) { @@ -113,6 +114,7 @@ public void LoadQuestData(QuestSaveData data) Instance.CompletedQuests = new List(); } } + #endregion } public class QuestBool