diff --git a/Assets/Scripts/Const.cs b/Assets/Scripts/Const.cs index 2020483a9..c055019e6 100644 --- a/Assets/Scripts/Const.cs +++ b/Assets/Scripts/Const.cs @@ -1300,6 +1300,10 @@ public void NewGame() { SceneTransitionHandler sth = newGameIndicator.AddComponent(); sth.saveGameIndex = -1; + sth.diffCombatCarryover = Const.a.difficultyCombat; + sth.diffCyberCarryover = Const.a.difficultyCyber; + sth.diffPuzzleCarryover = Const.a.difficultyPuzzle; + sth.diffMissionCarryover = Const.a.difficultyMission; Cursor.lockState = CursorLockMode.None; DontDestroyOnLoad(newGameIndicator); // 4b.2. loadingScreen.SetActive(true); @@ -1322,9 +1326,33 @@ public void GoIntoGame(Stopwatch loadTimer) { GameObject freshGame = GameObject.Find("GameNotYetStarted"); if (freshGame != null) Utils.SafeDestroy(freshGame); GameObject saveIndicator = GameObject.Find("NewGameIndicator"); - if (saveIndicator != null) Utils.SafeDestroy(saveIndicator); + if (saveIndicator != null) { + SceneTransitionHandler sth = saveIndicator.GetComponent(); + UnityEngine.Debug.Log("Acquiring sth data"); + if (sth != null) { + if (sth.setActiveAtNext) { + Const.a.difficultyCombat = sth.diffCombatCarryover; + Const.a.difficultyMission = sth.diffMissionCarryover; + Const.a.difficultyPuzzle = sth.diffPuzzleCarryover; + Const.a.difficultyCyber = sth.diffCyberCarryover; + } + } + Utils.SafeDestroy(saveIndicator); + } GameObject loadIndicator = GameObject.Find("LoadGameIndicator"); - if (loadIndicator != null) Utils.SafeDestroy(loadIndicator); + if (loadIndicator != null) { + SceneTransitionHandler sth = loadIndicator.GetComponent(); + UnityEngine.Debug.Log("Acquiring sth data"); + if (sth != null) { + if (sth.setActiveAtNext) { + Const.a.difficultyCombat = sth.diffCombatCarryover; + Const.a.difficultyMission = sth.diffMissionCarryover; + Const.a.difficultyPuzzle = sth.diffPuzzleCarryover; + Const.a.difficultyCyber = sth.diffCyberCarryover; + } + } + Utils.SafeDestroy(loadIndicator); + } Cursor.visible = true; Utils.Deactivate(loadingScreen); Utils.Deactivate(MainMenuHandler.a.IntroVideo); diff --git a/Assets/Scripts/SceneTransitionHandler.cs b/Assets/Scripts/SceneTransitionHandler.cs index 24a5d8800..3623576ea 100644 --- a/Assets/Scripts/SceneTransitionHandler.cs +++ b/Assets/Scripts/SceneTransitionHandler.cs @@ -4,19 +4,29 @@ public class SceneTransitionHandler : MonoBehaviour { private bool transitionActive; - private bool setActiveAtNext; + public bool setActiveAtNext; private bool loadActive; public int saveGameIndex; private AsyncOperation unloaderStatus; private int sceneIndexToLoad; private float loadDelayFinished; + public int diffCombatCarryover; + public int diffCyberCarryover; + public int diffPuzzleCarryover; + public int diffMissionCarryover; void Update() { if (setActiveAtNext) { setActiveAtNext = false; - Const.a.Awake(); Scene mainScene = SceneManager.GetSceneByName("CitadelScene"); - if (mainScene != null) SceneManager.SetActiveScene(mainScene); // Must delay by 1 frame. + if (mainScene != null) SceneManager.SetActiveScene(mainScene); + Const.a.Awake(); + Const.a.difficultyCombat = diffCombatCarryover; + Const.a.difficultyMission = diffMissionCarryover; + Const.a.difficultyPuzzle = diffPuzzleCarryover; + Const.a.difficultyCyber = diffCyberCarryover; + Debug.Log("Const.a.difficultyCombat " + Const.a.difficultyCombat.ToString()); + // Must delay by 1 frame. Scene loadScene = SceneManager.GetSceneByName("LoadScene"); Debug.Log("Unloading LoadScene"); //if (loadScene != null) SceneManager.UnloadSceneAsync(loadScene); @@ -51,4 +61,4 @@ public void Reload(int scenedex, ref AsyncOperation aso) { transitionActive = true; setActiveAtNext = false; } -} \ No newline at end of file +}