deaths door

This commit is contained in:
Thomas wilkins
2026-08-29 20:35:22 +01:00
parent a8efa23974
commit 1c4ed1639e
3 changed files with 339 additions and 40 deletions
+46 -40
View File
@@ -169,52 +169,58 @@ public class CameraController : MonoBehaviour
}
    private IEnumerator DoorSequenceRoutine(DoorManager activeDoor)
    {
        isSequencePlaying = true;
        RemoveHighlight();
       
        activeDoor.doorSplineDolly.CameraPosition = 0f;
        activeDoor.doorCamera.Priority = 30;
{
isSequencePlaying = true;
RemoveHighlight();
// 1. Determine which camera and track to use based on the door type
bool isDeathDoor = activeDoor.type == "DEATH" && activeDoor.deathCamera != null;
CinemachineCamera activeCam = isDeathDoor ? activeDoor.deathCamera : activeDoor.doorCamera;
CinemachineSplineDolly activeDolly = isDeathDoor ? activeDoor.deathSplineDolly : activeDoor.doorSplineDolly;
        yield return new WaitForSeconds(0.5f);
// 2. Reset the chosen track and boost its priority
activeDolly.CameraPosition = 0f;
activeCam.Priority = 30;
        float pushSpeed = 0.5f;
       
        // Push the camera through the doorway safely
        while (activeDoor != null && activeDoor.doorSplineDolly != null && activeDoor.doorSplineDolly.CameraPosition < 1f)
        {
            activeDoor.doorSplineDolly.CameraPosition += pushSpeed * Time.deltaTime;
            yield return null;
        }
yield return new WaitForSeconds(0.5f);
        // Cache the type just in case the door is destroyed during level generation
        string doorType = activeDoor != null ? activeDoor.type : "";
// 3. Push the camera (You might want to speed this up for the death drop!)
float pushSpeed = 0.5f;
while (activeDoor != null && activeDolly != null && activeDolly.CameraPosition < 1f)
{
activeDolly.CameraPosition += pushSpeed * Time.deltaTime;
yield return null;
}
        // Drop the door camera's priority BEFORE we update the level
        if (activeDoor != null && activeDoor.doorCamera != null)
        {
            activeDoor.doorCamera.Priority = inactivePriority;
        }
string doorType = activeDoor != null ? activeDoor.type : "";
        // Trigger your level update logic
        if (doorType == "LIFE")
        {
            Debug.Log("Safe door chosen! Advancing to the next level.");
            GlobalStateManager.Instance.SetLevelCompleted();
        }
        else if (doorType == "DEATH")
        {
            Debug.Log("Wrong door! Teleporting back to start.");
            // Your death logic goes here!
        }
        else
        {
            Debug.LogWarning($"Door type '{doorType}' is not recognised.");
        }
// 4. Safely drop the camera's priority
if (activeCam != null)
{
activeCam.Priority = inactivePriority;
}
        // Play the intro sequence for the newly generated room
        yield return StartCoroutine(IntroSequenceRoutine());
    }
// 5. Trigger the appropriate level logic
if (doorType == "LIFE")
{
Debug.Log("Safe door chosen! Advancing to the next level.");
GlobalStateManager.Instance.SetLevelCompleted();
}
else if (doorType == "DEATH")
{
Debug.Log("Wrong door! Teleporting back to start.");
// Insert your death/teleport logic here
}
else
{
Debug.LogWarning($"Door type '{doorType}' is not recognised.");
}
// 6. Play the intro sweep for the newly generated room or restart
yield return StartCoroutine(IntroSequenceRoutine());
}
    private void HandleEdgeNudge()
    {
+3
View File
@@ -25,6 +25,9 @@ public class DoorManager : MonoBehaviour, IDescribable
public CinemachineCamera doorCamera;
public CinemachineSplineDolly doorSplineDolly;
public CinemachineCamera deathCamera;
public CinemachineSplineDolly deathSplineDolly;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()