save position and cam rotation
This commit is contained in:
@@ -15,11 +15,12 @@ public class GameManager : MonoBehaviour
|
||||
public Inventory Inventory { get; private set; }
|
||||
public Storybools Storybools { get; private set; }
|
||||
public PauseMenu PauseMenu { get; private set; }
|
||||
public PlayerController PlayerController { get; private set; }
|
||||
public Image BlackScreen { get; private set; }
|
||||
|
||||
// Are we currently in a scene transition?
|
||||
private bool isTransitioningScenes = false;
|
||||
private Image blackScreen;
|
||||
private PlayerController playerController;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -38,7 +39,10 @@ private void Awake()
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
ReloadReferences();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SaveSystem.Load();
|
||||
SaveSystem.Save(); // save off any corruption fixes
|
||||
}
|
||||
@@ -48,8 +52,8 @@ private void Awake()
|
||||
/// </summary>
|
||||
private void ReloadReferences()
|
||||
{
|
||||
Instance.blackScreen = GameObject.FindWithTag("BlackScreen").GetComponent<Image>();
|
||||
Instance.playerController = GameObject.FindWithTag("Player").GetComponent<PlayerController>();
|
||||
Instance.BlackScreen = GameObject.FindWithTag("BlackScreen").GetComponent<Image>();
|
||||
Instance.PlayerController = GameObject.FindWithTag("Player").GetComponent<PlayerController>();
|
||||
Instance.DialogueManager = GetComponent<DialogueManager>();
|
||||
Instance.DialogueManager.ReloadReferences();
|
||||
|
||||
@@ -77,7 +81,7 @@ public void GoToMapPoint(MapPoint mapPoint)
|
||||
private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
{
|
||||
Instance.isTransitioningScenes = true;
|
||||
Instance.playerController.SetCharacterControl(false);
|
||||
Instance.PlayerController.SetCharacterControl(false);
|
||||
|
||||
// Fade to black
|
||||
float fadeDuration = 0.2f; // how long to fade to/from black
|
||||
@@ -88,7 +92,7 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
while (fadeTime < fadeDuration)
|
||||
{
|
||||
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
|
||||
blackScreen.color = blackScreenColor;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
fadeTime += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
@@ -105,18 +109,18 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
ReloadReferences();
|
||||
|
||||
// Make sure screen is black in new scene
|
||||
blackScreen.color = blackScreenColor;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
if (Instance.playerController != null && GameSceneManager.Instance != null)
|
||||
if (Instance.PlayerController != null && GameSceneManager.Instance != null)
|
||||
{
|
||||
Instance.playerController.CharacterControllerMove(mapPoint.SpawnPosition - playerController.transform.position);
|
||||
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;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
fadeTime += Time.deltaTime;
|
||||
|
||||
yield return null;
|
||||
@@ -132,7 +136,7 @@ private IEnumerator GoToMapPointCoroutine(MapPoint mapPoint)
|
||||
fadeTime = 0;
|
||||
|
||||
Instance.isTransitioningScenes = false;
|
||||
Instance.playerController.SetCharacterControl(true);
|
||||
Instance.PlayerController.SetCharacterControl(true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -151,7 +155,7 @@ public void EnterSceneDoor(string scene, int door)
|
||||
private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
{
|
||||
Instance.isTransitioningScenes = true;
|
||||
Instance.playerController.SetCharacterControl(false);
|
||||
Instance.PlayerController.SetCharacterControl(false);
|
||||
|
||||
// Fade to black
|
||||
float fadeDuration = 0.2f; // how long to fade to/from black
|
||||
@@ -162,7 +166,7 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
while (fadeTime < fadeDuration)
|
||||
{
|
||||
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
|
||||
blackScreen.color = blackScreenColor;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
fadeTime += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
@@ -179,16 +183,16 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
ReloadReferences();
|
||||
|
||||
// Make sure screen is black in new scene
|
||||
blackScreen.color = blackScreenColor;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
|
||||
SceneDoor door = GameSceneManager.Instance.GetDoorWithId(doorId);
|
||||
|
||||
if (Instance.playerController != null && GameSceneManager.Instance != null)
|
||||
if (Instance.PlayerController != null && GameSceneManager.Instance != null)
|
||||
{
|
||||
if (door != null)
|
||||
{
|
||||
Instance.playerController.CharacterControllerMove(door.gameObject.transform.position - playerController.transform.position);
|
||||
Instance.playerController.DougBody.transform.rotation = door.gameObject.transform.rotation;
|
||||
Instance.PlayerController.CharacterControllerMove(door.gameObject.transform.position - PlayerController.transform.position);
|
||||
Instance.PlayerController.DougBody.transform.rotation = door.gameObject.transform.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,17 +200,17 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
while (fadeTime < fadeDuration)
|
||||
{
|
||||
blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration);
|
||||
Instance.blackScreen.color = blackScreenColor;
|
||||
Instance.BlackScreen.color = blackScreenColor;
|
||||
fadeTime += Time.deltaTime;
|
||||
|
||||
Instance.playerController.WalkInDirection((door.WalkDirection.position - playerController.transform.position).normalized);
|
||||
Instance.PlayerController.WalkInDirection((door.WalkDirection.position - PlayerController.transform.position).normalized);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// move character a little more
|
||||
while (fadeTime < moveDuration)
|
||||
{
|
||||
Instance.playerController.WalkInDirection((door.WalkDirection.position - playerController.transform.position).normalized);
|
||||
Instance.PlayerController.WalkInDirection((door.WalkDirection.position - PlayerController.transform.position).normalized);
|
||||
fadeTime += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
@@ -214,7 +218,7 @@ private IEnumerator EnterSceneDoorCoroutine(string scene, int doorId)
|
||||
fadeTime = 0;
|
||||
|
||||
Instance.isTransitioningScenes = false;
|
||||
Instance.playerController.SetCharacterControl(true);
|
||||
Instance.PlayerController.SetCharacterControl(true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -226,22 +230,6 @@ public bool InSceneTransition()
|
||||
return Instance.isTransitioningScenes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the blackscreen object reference
|
||||
/// </summary>
|
||||
public Image GetBlackScreen()
|
||||
{
|
||||
return Instance.blackScreen;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the playerContoller object reference
|
||||
/// </summary>
|
||||
public PlayerController GetPlayerController()
|
||||
{
|
||||
return Instance.playerController;
|
||||
}
|
||||
|
||||
#region Storybool Save/Load
|
||||
public void SaveStoryBools(ref StoryboolSaveData data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user