diff --git a/Assets/Doug.prefab b/Assets/Doug.prefab
index f416f5f..decc4fa 100644
--- a/Assets/Doug.prefab
+++ b/Assets/Doug.prefab
@@ -3142,6 +3142,7 @@ MonoBehaviour:
walkSpeed: 2
sprintMultiplier: 1.5
gravity: 1
+ cameraController: {fileID: 5478143440182735446}
--- !u!114 &5478143440182735446
MonoBehaviour:
m_ObjectHideFlags: 0
diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity
index d134e4b..cddccf4 100644
--- a/Assets/Scenes/SampleScene.unity
+++ b/Assets/Scenes/SampleScene.unity
@@ -1426,17 +1426,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::SunRotation
offset: 270
---- !u!114 &415981849 stripped
-MonoBehaviour:
- m_CorrespondingSourceObject: {fileID: 6038027350876930962, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
- m_PrefabInstance: {fileID: 7959480261809233915}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 0}
- m_Enabled: 1
- m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: 70102eddcaad3044d9ac0ec62519caad, type: 3}
- m_Name:
- m_EditorClassIdentifier: Assembly-CSharp::GrappleGun
--- !u!1 &419915067
GameObject:
m_ObjectHideFlags: 0
@@ -3643,6 +3632,17 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
+--- !u!114 &1733921841 stripped
+MonoBehaviour:
+ m_CorrespondingSourceObject: {fileID: 5478143440182735446, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
+ m_PrefabInstance: {fileID: 7959480261809233915}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 34a2af7866b6ecc4ab5f2b6222f7dbe2, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Assembly-CSharp::CameraController
--- !u!1 &1735546792
GameObject:
m_ObjectHideFlags: 0
@@ -4483,17 +4483,9 @@ PrefabInstance:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1480974628599415149, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
- propertyPath: tools.Array.size
- value: 5
- objectReference: {fileID: 0}
- - target: {fileID: 1480974628599415149, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
- propertyPath: 'tools.Array.data[4]'
+ propertyPath: cameraController
value:
- objectReference: {fileID: 415981849}
- - target: {fileID: 5056434560497563343, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
- propertyPath: m_LocalPosition.y
- value: -0.78
- objectReference: {fileID: 0}
+ objectReference: {fileID: 1733921841}
- target: {fileID: 5526037850913171920, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
propertyPath: m_LocalPosition.x
value: -0.60945
@@ -4534,10 +4526,6 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- - target: {fileID: 5907675754202653673, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
- propertyPath: ball
- value:
- objectReference: {fileID: 7664016258760507437, guid: 0b0365667a94c474bb3cc42312aac1db, type: 3}
- target: {fileID: 9054701043111961555, guid: 0fd9b22e9158e474a96c42de5ee0d85f, type: 3}
propertyPath: m_Name
value: Doug
diff --git a/Assets/Scripts/Dialogue/CameraController.cs b/Assets/Scripts/Management/CameraController.cs
similarity index 77%
rename from Assets/Scripts/Dialogue/CameraController.cs
rename to Assets/Scripts/Management/CameraController.cs
index dd268dd..ac81035 100644
--- a/Assets/Scripts/Dialogue/CameraController.cs
+++ b/Assets/Scripts/Management/CameraController.cs
@@ -5,7 +5,7 @@
public class CameraController : MonoBehaviour
{
- private float camTargetRotation = 0;
+ public float camTargetRotation { get; private set; } = 0;
private bool isCamRotating = false;
public Transform playerCamHome;
@@ -28,6 +28,20 @@ public void RotateCam()
}
}
+ ///
+ /// Set cam rotation immediately
+ ///
+ public void SnapToRotation(float rotation)
+ {
+ playerCamHome.RotateAround(
+ transform.position,
+ Vector3.up,
+ rotation
+ );
+
+ camTargetRotation = rotation;
+ }
+
///
/// Move cam to desired rotation (every frame)
///
diff --git a/Assets/Scripts/Dialogue/CameraController.cs.meta b/Assets/Scripts/Management/CameraController.cs.meta
similarity index 100%
rename from Assets/Scripts/Dialogue/CameraController.cs.meta
rename to Assets/Scripts/Management/CameraController.cs.meta
diff --git a/Assets/Scripts/Management/GameManager.cs b/Assets/Scripts/Management/GameManager.cs
index 8318d32..3b3feb3 100644
--- a/Assets/Scripts/Management/GameManager.cs
+++ b/Assets/Scripts/Management/GameManager.cs
@@ -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()
///
private void ReloadReferences()
{
- Instance.blackScreen = GameObject.FindWithTag("BlackScreen").GetComponent();
- Instance.playerController = GameObject.FindWithTag("Player").GetComponent();
+ Instance.BlackScreen = GameObject.FindWithTag("BlackScreen").GetComponent();
+ Instance.PlayerController = GameObject.FindWithTag("Player").GetComponent();
Instance.DialogueManager = GetComponent();
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;
}
- ///
- /// Get the blackscreen object reference
- ///
- public Image GetBlackScreen()
- {
- return Instance.blackScreen;
- }
-
- ///
- /// Get the playerContoller object reference
- ///
- public PlayerController GetPlayerController()
- {
- return Instance.playerController;
- }
-
#region Storybool Save/Load
public void SaveStoryBools(ref StoryboolSaveData data)
{
diff --git a/Assets/Scripts/Management/GameManager.cs.meta b/Assets/Scripts/Management/GameManager.cs.meta
index 592eb43..0dacaa9 100644
--- a/Assets/Scripts/Management/GameManager.cs.meta
+++ b/Assets/Scripts/Management/GameManager.cs.meta
@@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
- executionOrder: -1
+ executionOrder: -500
icon: {instanceID: 0}
userData:
assetBundleName:
diff --git a/Assets/Scripts/Management/PlayerController.cs b/Assets/Scripts/Management/PlayerController.cs
index 1e134ab..9ad3899 100644
--- a/Assets/Scripts/Management/PlayerController.cs
+++ b/Assets/Scripts/Management/PlayerController.cs
@@ -15,8 +15,8 @@ public class PlayerController : MonoBehaviour
public float gravity = 10;
Interactable nearestInteractable;
+ public CameraController cameraController;
private CharacterController characterController;
- private CameraController cameraController;
private Vector3 moveDir;
private bool hasControl = true; // set this to false if we want to stop reading player inputs
private bool canUseTools = true; // set this to false if we want to stop reading player tool use
diff --git a/Assets/Scripts/Management/PlayerManager.cs b/Assets/Scripts/Management/PlayerManager.cs
index a22721e..2185360 100644
--- a/Assets/Scripts/Management/PlayerManager.cs
+++ b/Assets/Scripts/Management/PlayerManager.cs
@@ -1,4 +1,5 @@
using UnityEngine;
+using UnityEngine.SceneManagement;
// Handles scene-persistent player data
public class PlayerManager : MonoBehaviour
@@ -9,11 +10,21 @@ public class PlayerManager : MonoBehaviour
public void SavePlayerData(ref PlayerSaveData data)
{
data.activeToolIndex = GameManager.Instance.PlayerManager.CurrentToolIndex;
+ data.camRotation = GameManager.Instance.PlayerController.cameraController.camTargetRotation;
+ data.dougPosition = GameManager.Instance.PlayerController.transform.position;
+ data.currentScene = SceneManager.GetActiveScene().name;
}
public void LoadPlayerData(PlayerSaveData data)
{
+ /*if (data.currentScene != null && data.currentScene != SceneManager.GetActiveScene().name)
+ {
+ SceneManager.LoadScene(data.currentScene);
+ }*/
+
GameManager.Instance.PlayerManager.CurrentToolIndex = data.activeToolIndex;
+ GameManager.Instance.PlayerController.cameraController.SnapToRotation(data.camRotation);
+ GameManager.Instance.PlayerController.transform.position = data.dougPosition;
}
#endregion
}
@@ -22,4 +33,7 @@ public void LoadPlayerData(PlayerSaveData data)
public struct PlayerSaveData
{
public int activeToolIndex;
+ public float camRotation;
+ public Vector3 dougPosition;
+ public string currentScene;
}
diff --git a/Assets/Scripts/Management/TeleportHandler.cs b/Assets/Scripts/Management/TeleportHandler.cs
index 27f09da..956fec6 100644
--- a/Assets/Scripts/Management/TeleportHandler.cs
+++ b/Assets/Scripts/Management/TeleportHandler.cs
@@ -41,7 +41,7 @@ IEnumerator EnterRoomCoroutine(RoomDoor door)
while (fadeTime < fadeDuration)
{
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
- GameManager.Instance.GetBlackScreen().color = blackScreenColor;
+ GameManager.Instance.BlackScreen.color = blackScreenColor;
fadeTime += Time.deltaTime;
yield return null;
}
@@ -53,7 +53,7 @@ IEnumerator EnterRoomCoroutine(RoomDoor door)
while (fadeTime < fadeDuration)
{
blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration);
- GameManager.Instance.GetBlackScreen().color = blackScreenColor;
+ GameManager.Instance.BlackScreen.color = blackScreenColor;
playerController.WalkInDirection((door.linkedDoor.WalkDirection.position - playerController.transform.position).normalized);
fadeTime += Time.deltaTime;
diff --git a/Assets/Scripts/Tools/Ballgun.cs b/Assets/Scripts/Tools/Ballgun.cs
index 2773636..7832317 100644
--- a/Assets/Scripts/Tools/Ballgun.cs
+++ b/Assets/Scripts/Tools/Ballgun.cs
@@ -13,7 +13,7 @@ public override void Use()
newBall.transform.position = transform.position;
Vector3 direction = transform.forward * shootForce;
- direction += GameManager.Instance.GetPlayerController().GetVelocity();
+ direction += GameManager.Instance.PlayerController.GetVelocity();
newBall.GetComponent().AddForce(direction, ForceMode.Impulse);
diff --git a/Assets/Scripts/Tools/GrappleGun.cs b/Assets/Scripts/Tools/GrappleGun.cs
index 26daba5..2b2c2fd 100644
--- a/Assets/Scripts/Tools/GrappleGun.cs
+++ b/Assets/Scripts/Tools/GrappleGun.cs
@@ -21,7 +21,7 @@ private void Start()
IEnumerator GoToTarget(Vector3 target)
{
- GameManager.Instance.GetPlayerController().SetCharacterControl(false);
+ GameManager.Instance.PlayerController.SetCharacterControl(false);
isMoving = true;
Vector3 startPosition = hook.transform.position;
float elapsedTime = 0f;
@@ -45,7 +45,7 @@ IEnumerator GoToTarget(Vector3 target)
IEnumerator MovePlayerToTarget(Vector3 target)
{
- Transform player = GameManager.Instance.GetPlayerController().transform;
+ Transform player = GameManager.Instance.PlayerController.transform;
Vector3 startPosition = player.position;
float elapsedTime = 0f;
@@ -66,12 +66,12 @@ IEnumerator MovePlayerToTarget(Vector3 target)
isMoving = false;
stuckInTarget = false;
- GameManager.Instance.GetPlayerController().SetCharacterControl(true);
+ GameManager.Instance.PlayerController.SetCharacterControl(true);
}
IEnumerator ShootAndMiss()
{
- GameManager.Instance.GetPlayerController().SetCharacterControl(false);
+ GameManager.Instance.PlayerController.SetCharacterControl(false);
isMoving = true;
@@ -92,7 +92,7 @@ IEnumerator ShootAndMiss()
isMoving = false;
stuckInTarget = false;
- GameManager.Instance.GetPlayerController().SetCharacterControl(true);
+ GameManager.Instance.PlayerController.SetCharacterControl(true);
}
public override void Use()
@@ -105,7 +105,7 @@ public override void Use()
isMoving = false;
stuckInTarget = false;
- GameManager.Instance.GetPlayerController().SetCharacterControl(true);
+ GameManager.Instance.PlayerController.SetCharacterControl(true);
}
else
{
diff --git a/Assets/Scripts/Tools/ThrowableHand.cs b/Assets/Scripts/Tools/ThrowableHand.cs
index caf9312..dc94945 100644
--- a/Assets/Scripts/Tools/ThrowableHand.cs
+++ b/Assets/Scripts/Tools/ThrowableHand.cs
@@ -18,7 +18,7 @@ public class ThrowableHand : Tool
private void Update()
{
- if (GameManager.Instance.GetPlayerController() != null)
+ if (GameManager.Instance.PlayerController != null)
{
SetGroundPlane();
DrawTargetProjection();
@@ -29,10 +29,10 @@ private void SetGroundPlane()
{
if (handGroundPlane == null)
{
- handGroundPlane = new Plane(Vector3.up, -GameManager.Instance.GetPlayerController().DougBody.transform.position.y);
+ handGroundPlane = new Plane(Vector3.up, -GameManager.Instance.PlayerController.DougBody.transform.position.y);
}
- handGroundPlane.distance = -GameManager.Instance.GetPlayerController().DougBody.transform.position.y;
+ handGroundPlane.distance = -GameManager.Instance.PlayerController.DougBody.transform.position.y;
handGroundPlane.normal = Vector3.up;
}
@@ -73,7 +73,7 @@ public override void Use()
newBomb.transform.position = transform.position;
Vector3 direction = transform.forward * throwForce * forceModifier;
- direction += GameManager.Instance.GetPlayerController().GetVelocity();
+ direction += GameManager.Instance.PlayerController.GetVelocity();
direction.y = loft;
newBomb.GetComponent().AddForce(direction, ForceMode.Impulse);