Start on merging camera controller. Fix global state manager bug

This commit is contained in:
WillJeynes
2026-08-28 20:42:37 +01:00
parent 74773d7f71
commit 3e5599461d
4 changed files with 311 additions and 26 deletions
+270
View File
@@ -127,6 +127,146 @@ MonoBehaviour:
m_ShadowLayerMask: 1
m_RenderingLayers: 1
m_ShadowRenderingLayers: 1
--- !u!1 &2658980241334070197
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8837663364318141596}
- component: {fileID: 1305966551938095645}
- component: {fileID: 4016467311621144490}
- component: {fileID: 1015659431051486259}
m_Layer: 0
m_Name: CinemachineCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8837663364318141596
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2658980241334070197}
serializedVersion: 2
m_LocalRotation: {x: 0.073581405, y: 0.06576645, z: -0.004868995, w: 0.99510646}
m_LocalPosition: {x: 0.021, y: 0.554, z: -5.19}
m_LocalScale: {x: 0.41152364, y: 0.2469134, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6261725771962263685}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1305966551938095645
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2658980241334070197}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f9dfa5b682dcd46bda6128250e975f58, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineCamera
Priority:
Enabled: 1
m_Value: 10
OutputChannel: 1
StandbyUpdate: 2
m_StreamingVersion: 20241001
m_LegacyPriority: 0
Target:
TrackingTarget: {fileID: 0}
LookAtTarget: {fileID: 0}
CustomLookAtTarget: 0
Lens:
FieldOfView: 60.000004
OrthographicSize: 5
NearClipPlane: 0.3
FarClipPlane: 1000
Dutch: 0
ModeOverride: 0
PhysicalProperties:
GateFit: 2
SensorSize: {x: 21.946, y: 16.002}
LensShift: {x: 0, y: 0}
FocusDistance: 10
Iso: 200
ShutterSpeed: 0.005
Aperture: 16
BladeCount: 5
Curvature: {x: 2, y: 11}
BarrelClipping: 0.25
Anamorphism: 0
BlendHint: 0
--- !u!114 &4016467311621144490
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2658980241334070197}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 90eebaab98e4b44b0ba8c79821e554e1, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineSplineDolly
m_SplineSettings:
Spline: {fileID: 8692689237725241462}
Position: 0
Units: 1
SplineOffset: {x: 0, y: 0, z: 0}
CameraRotation: 0
Damping:
Enabled: 0
Position: {x: 0, y: 0, z: 0}
Angular: 0
AutomaticDolly:
Enabled: 0
Method:
rid: -2
m_LegacyPosition: -1
m_LegacyUnits: 0
m_LegacySpline: {fileID: 0}
references:
version: 2
RefIds:
- rid: -2
type: {class: , ns: , asm: }
--- !u!114 &1015659431051486259
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2658980241334070197}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f38bda98361e1de48a4ca2bd86ea3c17, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineRotationComposer
Composition:
ScreenPosition: {x: 0, y: 0}
DeadZone:
Enabled: 0
Size: {x: 0.2, y: 0.2}
HardLimits:
Enabled: 0
Size: {x: 0.8, y: 0.8}
Offset: {x: 0, y: 0}
CenterOnActivate: 1
TargetOffset: {x: 0, y: 0, z: 0}
Damping: {x: 0.5, y: 0.5}
Lookahead:
Enabled: 0
Time: 0
Smoothing: 0
IgnoreY: 0
--- !u!1 &3755624549931742426
GameObject:
m_ObjectHideFlags: 0
@@ -306,6 +446,8 @@ Transform:
m_LocalScale: {x: 2.43, y: 4.05, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8837663364318141596}
- {fileID: 5450540301096024125}
- {fileID: 34709828658865169}
- {fileID: 6918252568792756431}
m_Father: {fileID: 0}
@@ -348,6 +490,134 @@ MonoBehaviour:
blueMaterial: {fileID: 2100000, guid: d62ae3e529a14d961b7ac9b6967da04e, type: 2}
redMaterial: {fileID: 2100000, guid: 7a46060c77bcaaf79a5c30c1f6001499, type: 2}
isfocussed: 0
doorCamera: {fileID: 1305966551938095645}
doorSplineDolly: {fileID: 4016467311621144490}
--- !u!1 &5594795846395120415
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5450540301096024125}
- component: {fileID: 8692689237725241462}
- component: {fileID: 2817956331921012244}
m_Layer: 0
m_Name: Dolly Spline
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5450540301096024125
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5594795846395120415}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.021, y: 0.554, z: -5.19}
m_LocalScale: {x: 0.4115226, y: 0.24691355, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6261725771962263685}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8692689237725241462
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5594795846395120415}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dab5c7d4c32e743048dfca98e2d5914f, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Splines::UnityEngine.Splines.SplineContainer
m_Spline:
m_EditModeType: 1
m_Knots: []
m_MetaData: []
m_Closed: 0
m_IntData:
m_Data: []
m_FloatData:
m_Data: []
m_Float4Data:
m_Data: []
m_ObjectData:
m_Data: []
m_Splines:
- m_EditModeType: 1
m_Knots:
- Position:
x: 0
y: 0
z: 0
TangentIn:
x: 0
y: 0
z: 0
TangentOut:
x: 0
y: 0
z: 0
Rotation:
value:
x: 0
y: 0
z: 0
w: 1
- Position:
x: -0.19103001
y: -0.0037002563
z: 10.25
TangentIn:
x: 0
y: 0
z: 0
TangentOut:
x: 0
y: 0
z: 0
Rotation:
value:
x: 0
y: 0
z: 0
w: 1
m_MetaData:
- Mode: 4
Tension: 0.5
- Mode: 4
Tension: 0.5
m_Closed: 0
m_IntData:
m_Data: []
m_FloatData:
m_Data: []
m_Float4Data:
m_Data: []
m_ObjectData:
m_Data: []
m_Knots:
m_KnotsLink: []
--- !u!114 &2817956331921012244
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5594795846395120415}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c5342500578afb24a9b83d6343d32a0f, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineSplineSmoother
AutoSmooth: 1
--- !u!1 &8392774035223462151
GameObject:
m_ObjectHideFlags: 0
+5 -5
View File
@@ -223,8 +223,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 17649577}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 37.25, y: -1.21, z: -30.7}
m_LocalRotation: {x: 0, y: -0.017452408, z: 0, w: 0.9998477}
m_LocalPosition: {x: 27.4, y: 3.96, z: -27.6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -2135,8 +2135,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 37.25, y: -1.21, z: -30.7}
m_LocalRotation: {x: 0, y: -0.017452408, z: 0, w: 0.9998477}
m_LocalPosition: {x: 27.4, y: 3.96, z: -27.6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -7902,7 +7902,7 @@ MonoBehaviour:
m_EditorClassIdentifier: '::'
DoorPrefabs:
- key: DEFAULT
value: {fileID: 3986278427006718258, guid: 43b0e5e5fb448dd5f9178e6fc2a66752, type: 3}
value: {fileID: 3986278427006718258, guid: 7fc9336d626a2e876bb11790caa70ce6, type: 3}
GuardPrefabs:
- key: BASE
value: {fileID: 3986278427006718258, guid: ae0fc11a1b5a3cac1928700767c5e8a5, type: 3}
+31 -17
View File
@@ -145,16 +145,21 @@ public class CameraController : MonoBehaviour
{
RemoveHighlight();
currentlyHoveredRenderer = hitRenderer;
if (currentlyHoveredRenderer is SpriteRenderer sprite)
if (
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != null &&
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != currentDoorManager
)
{
originalColour = sprite.color;
sprite.color = highlightColour;
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>().isfocussed = 1;
}
else
if (
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>() != null &&
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>() != currentGuardManager
)
{
originalColour = currentlyHoveredRenderer.material.color;
currentlyHoveredRenderer.material.color = highlightColour;
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>().isfocussed = 1;
}
}
}
@@ -168,15 +173,6 @@ public class CameraController : MonoBehaviour
{
if (currentlyHoveredRenderer != null)
{
if (currentlyHoveredRenderer is SpriteRenderer sprite)
{
sprite.color = originalColour;
}
else
{
currentlyHoveredRenderer.material.color = originalColour;
}
if (
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != null &&
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != currentDoorManager
@@ -227,20 +223,25 @@ public class CameraController : MonoBehaviour
if (talkButton != null) talkButton.gameObject.SetActive(false);
if (doorButton != null) doorButton.gameObject.SetActive(false);
UnsetAll();
if (guard != null)
{
currentGuardManager = guard;
guard.isfocussed = 2;
if (talkButton != null) talkButton.gameObject.SetActive(true);
}
else if (door != null)
{
currentDoorManager = door;
door.isfocussed = 2;
if (doorButton != null) doorButton.gameObject.SetActive(true);
}
}
else
{
ReturnToMainCamera();
UnsetAll();
}
}
@@ -293,7 +294,7 @@ public class CameraController : MonoBehaviour
if (activeDoor.type == "LIFE")
{
Debug.Log("Safe door chosen! Advancing to the next level.");
GlobalStateManager.Instance.SetLevelCompleted(GlobalStateManager.Instance.LevelIntended);
GlobalStateManager.Instance.SetLevelCompleted();
}
else if (activeDoor.type == "DEATH")
{
@@ -324,6 +325,19 @@ public class CameraController : MonoBehaviour
if (talkButton != null) talkButton.gameObject.SetActive(false);
if (doorButton != null) doorButton.gameObject.SetActive(false);
}
private void UnsetAll()
{
foreach (var doorManager in LevelLoader.Instance.Doors)
{
doorManager.isfocussed = 0;
}
foreach (var doorManager in LevelLoader.Instance.Guards)
{
doorManager.isfocussed = 0;
}
}
private void ResetCameraPositions()
{
+5 -4
View File
@@ -35,14 +35,15 @@ public class GlobalStateManager : Singleton<GlobalStateManager>
public void SetLevelCompleted(int level)
public void SetLevelCompleted()
{
if (level > HighestLevel)
if (LevelIntended == HighestLevel)
{
PlayerPrefs.SetInt("HighestLevel", level);
LevelIntended++;
HighestLevel++;
PlayerPrefs.SetInt("HighestLevel", HighestLevel);
PlayerPrefs.Save();
LevelIntended = level + 1;
//Reload game scene to start next level??
SceneManager.LoadScene(1);
}