fade to correct scene when current scene doesn't match save file on load
This commit is contained in:
@@ -44,7 +44,6 @@ private void Awake()
|
||||
private void Start()
|
||||
{
|
||||
SaveSystem.Load();
|
||||
SaveSystem.Save(); // save off any corruption fixes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,15 +69,15 @@ private void ReloadReferences()
|
||||
/// <summary>
|
||||
/// Triggers transition to a map point
|
||||
/// </summary>
|
||||
public void GoToMapPoint(MapPoint mapPoint)
|
||||
public void GoToMapPoint(MapPoint mapPoint, bool instantBlackScreen = false)
|
||||
{
|
||||
StartCoroutine(GoToMapPointCoroutine(mapPoint));
|
||||
StartCoroutine(GoToMapPointCoroutine(mapPoint, instantBlackScreen));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes transition to map point (scene and location)
|
||||
/// </summary>
|
||||
private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint, bool instantBlackScreen)
|
||||
{
|
||||
Instance.isTransitioningScenes = true;
|
||||
Instance.PlayerController.SetCharacterControl(false);
|
||||
@@ -89,15 +88,24 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
float fadeTime = 0;
|
||||
Color blackScreenColor = Color.black;
|
||||
|
||||
while (fadeTime < fadeDuration)
|
||||
// Fade to black when instantBlackScreen is false
|
||||
if (!instantBlackScreen)
|
||||
{
|
||||
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
fadeTime += Time.deltaTime;
|
||||
yield return null;
|
||||
while (fadeTime < fadeDuration)
|
||||
{
|
||||
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
fadeTime += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
fadeTime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// instantly make screen black before scene transition
|
||||
blackScreenColor.a = 1;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
}
|
||||
fadeTime = 0;
|
||||
|
||||
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(mapPoint.Scene);
|
||||
while (!asyncLoad.isDone)
|
||||
@@ -126,6 +134,9 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
yield return null;
|
||||
}
|
||||
|
||||
blackScreenColor.a = 0;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
// move character a little more
|
||||
while (fadeTime < moveDuration)
|
||||
{
|
||||
@@ -183,6 +194,7 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
ReloadReferences();
|
||||
|
||||
// Make sure screen is black in new scene
|
||||
blackScreenColor.a = 1;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
SceneDoor door = GameSceneManager.Instance.GetDoorWithId(doorId);
|
||||
@@ -207,6 +219,9 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
yield return null;
|
||||
}
|
||||
|
||||
blackScreenColor.a = 0;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
// move character a little more
|
||||
while (fadeTime < moveDuration)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user