Files
HauntedBloodlines/Assets/Scripts/Managers/Game/DanielLoopManager.cs
2025-05-29 22:31:40 +03:00

600 lines
27 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using System;
using System.Collections;
public class DanielLoopManager : MonoBehaviour
{
// 1. Define the 18 loop states
public enum DanielLoopState
{
Loop1,
Loop2,
Loop3,
Loop4,
Loop5,
Loop6,
Loop7,
Loop8,
Loop9,
Loop10,
Loop11,
Loop12,
Loop13,
Loop14,
Loop15,
Loop16,
Loop17,
Loop18
}
[Header("Daniel Loops Setup")]
[Tooltip("Check if we're loading a saved game in the Daniel Loops section")]
public bool isLoadingDanielLoops;
// Current loop state (start at Loop1 or load from save)
public DanielLoopState currentDanielLoopState = DanielLoopState.Loop1;
private void Awake()
{
// Ensure this DanielLoopManager is known to the GameManager
if (GameManager.GetInstance() != null)
{
GameManager.GetInstance().danielLoopManager = this;
}
// Check if we are loading a saved game
if (LoadManager.GetInstance() != null && LoadManager.GetInstance().LoadingGame)
{
isLoadingDanielLoops = true;
}
}
/// <summary>
/// Called by GameManager to activate this managers logic.
/// </summary>
public void Activate()
{
Debug.Log("Daniel Loops Manager Activated: Initializing Daniel Loops.");
TryLoadSavedState();
UpdateStoryline();
}
/// <summary>
/// Called by GameManager to deactivate this managers logic.
/// </summary>
public void Deactivate()
{
Debug.Log("Daniel Loops Manager Deactivated.");
StopAllCoroutines();
SaveStorylineState();
CleanupPlayerSettings();
// Notify GameManager this entire section is complete (optional).
// Typically you do this upon finishing the last loop, but you can do it here if needed.
// NotifyCompletion();
}
/// <summary>
/// Main method that checks the current loop state and performs the necessary logic.
/// </summary>
public void UpdateStoryline()
{
switch (currentDanielLoopState)
{
case DanielLoopState.Loop1:
Debug.Log("Player is in Loop 1");
#region Loop1Description
/* TODO:
================================================================================
LOOP 1: DANIELS OFFICE
================================================================================
Puzzle Name: Memory Box & The Heart Keepsake
Story Focus:
- Show Daniel & Medeas early love; minimal horror with slight foreshadowing.
Puzzle Mechanics:
1) Find a locked Memory Box on Daniels desk containing:
- A love note
- A small bottle of wine
- A piece of Medeas ring
2) Search old letters to uncover a simple combination // “91120”
3) Unlocking the box reveals a hidden compartment holding
Daniels “Heart” Keepsake (body-part token). //placeholder cube with heart
Body-Part Collection:
- Heart Keepsake (symbolic or physically heart-like).
Jump Scare:
- Reflection in the office window:
Medeas silhouette appears for a second and vanishes.
Time Travel / Ghost Realm (Optional):
- Subtle flicker in a photo/mirror, hinting future paranormal events.
*/
#endregion
break;
case DanielLoopState.Loop2:
Debug.Log("Player is in Loop 2");
#region Loop2Description
/*================================================================================
LOOP 2: PARENTS BEDROOM
================================================================================
Puzzle Name: Fragrant Secrets
Story Focus:
- Depict early marriage & Medeas longing for luxury.
Puzzle Mechanics:
1) A wardrobe locked by a scent-based mechanism:
- Each drawer labeled by flower/perfume notes.
2) Find matching perfume bottles scattered around
(vanity table, side drawers, etc.).
3) Insert the correct bottle into each drawers slot
based on subtle hints in notes or a perfume catalog.
4) The final drawer unlocks, revealing a mannequin hand
wearing Daniels wedding ring.
Body-Part Collection:
- Mannequin Hand (with ring).
Jump Scare:
- Wardrobe door swings open, and in the mirror inside,
Medeas face momentarily appears behind the player.
Time Travel / Ghost Realm (Optional):
- Small flash of the bedroom in a happier, well-lit past
upon solving the puzzle.
*/
#endregion
break;
case DanielLoopState .Loop3:
Debug.Log("Player is in Loop 3");
#region Loop3Description
/*
================================================================================
LOOP 3: HALLWAY #1
================================================================================
Puzzle Name: Whispers in the Hall (Portrait Puzzle)
Story Focus:
- Introduce the children; financial strain emerges.
Puzzle Mechanics:
1) The hallway is lined with family portraits
(children at various ages, possibly mislabeled).
2) Each portrait “whispers” a memory or clue
when the player inspects it closely.
3) Reorganize/rotate the portraits in correct chronological order:
- Hints: ages, subtle time stamps, hidden text on frames.
4) Completing the sequence unlocks a panel in the wall
revealing a mannequin foot (Daniels foot).
Body-Part Collection:
- Mannequin Foot.
Jump Scare:
- Hallway extends or warps momentarily,
child laughter distorts into a sudden scream.
Time Travel / Ghost Realm (Optional):
- Occasionally, the hallway flickers to show the children
running past in an echo of the past.
*/
#endregion
break;
case DanielLoopState.Loop4:
Debug.Log("Player is in Loop 4");
/*
================================================================================
LOOP 4: DANIELS OFFICE (REVISITED)
================================================================================
Puzzle Name: Candlelight Ritual
Story Focus:
- Reveal Medeas desperation; partial sign of her occult practices.
Puzzle Mechanics:
1) The once-normal office is dark, lit by scattered candles.
2) Strange symbols on the walls/floor correspond to a ritual sequence.
3) Light specific candles in the correct order (hints via diaries/notes).
4) A hidden drawer in Daniels desk unlocks upon success,
containing Daniels eyes in a sealed jar.
Body-Part Collection:
- Daniels Eyes (jar with eerie glow).
Jump Scare:
- On grabbing the jar, a loud heartbeat sound triggers,
followed by Medeas chanting from nearby.
Time Travel / Ghost Realm (Optional):
- If the player attempts to time-travel,
they might see the office in a half-finished ritual scene
with Medea collecting ingredients.
*/
break;
case DanielLoopState.Loop5:
Debug.Log("Player is in Loop 5");
/*
================================================================================
LOOP 5:
================================================================================
Puzzle Name: Echoes of an Affair
Story Focus:
- Daniels affair escalates; guilt begins to consume him.
Puzzle Mechanics:
1) The hallway walls are plastered with torn letters, hotel receipts, etc.
2) Arrange these documents on a “timeline board”
(slots labeled with dates or event names).
3) Correct placement unlocks a small wall safe,
containing an “audio recorder” playing Daniels confessions—his Voice.
Body-Part Collection:
- Daniels Voice (symbolic soul fragment or a recorder device).
Jump Scare:
- As the puzzle completes, lights flicker,
and a figure resembling either Medea or the mistress sprints by.
Time Travel / Ghost Realm (Optional):
- Certain letters only visible or readable in ghostly overlay
to confirm affair details.
*/
break;
case DanielLoopState.Loop6:
Debug.Log("Player is in Loop 6");
/*
================================================================================
LOOP 6: PARENTS BEDROOM (REVISITED)
================================================================================
Puzzle Name: Bloodstained Bedspread
Story Focus:
- The affair intensifies; Medea shows more overt possession.
Puzzle Mechanics:
1) The bedspread has cryptic bloodstains forming runic patterns.
2) Player must trace these patterns with special chalk found in a drawer.
3) Each correct tracing reveals more of Medeas rage
and ends by shifting the bed frame, exposing a mannequin arm (Daniels Arm).
Body-Part Collection:
- Mannequin Arm.
Jump Scare:
- Upon finishing the tracing, a ghostly replay
of Medea attacking Daniel on the bed flashes before the player.
Time Travel / Ghost Realm (Optional):
- The bed might appear pristine in a “past overlay,”
then flicker back to the bloodstained present.
*/
break;
case DanielLoopState.Loop7:
Debug.Log("Player is in Loop 7");
/*
================================================================================
LOOP 7: HALLWAY #3
================================================================================
Puzzle Name: Circuitry of Despair
Story Focus:
- Financial ruin & isolation intensify.
Puzzle Mechanics:
1) Hallway lights are out; a circuit breaker box is mounted near the center.
2) Player must rewire color-coded cables/fuses to restore partial power.
3) Each correct wire lights another segment of the hallway,
revealing cryptic writing or clues.
4) Final segment reveals a recess containing Daniels torso (mannequin core).
Body-Part Collection:
- Daniels Torso.
Jump Scare:
- Incorrect wiring unleashes sparks,
momentary ghostly apparitions crowd the hallway.
Time Travel / Ghost Realm (Optional):
- A short trip to the past might show the hallway intact,
revealing the original wiring diagram.
*/
break;
case DanielLoopState.Loop8:
Debug.Log("Player is in Loop 8");
/*
================================================================================
LOOP 8: DANIELS OFFICE (RITUAL CONFRONTATION)
================================================================================
Puzzle Name: Poltergeist Press
Story Focus:
- Personal loss, Medeas malevolence escalates; violent confrontations.
Puzzle Mechanics:
1) Office objects float in a poltergeist storm (books, chairs, etc.).
2) Use a “binding lens” or artifact to calm each floating object,
returning them to their rightful place.
3) Each restored object reveals part of a ritual code.
When complete, a hidden panel under the desk opens with Daniels jaw.
Body-Part Collection:
- Daniels Jaw (symbol of his final pleas or words).
Jump Scare:
- When the last object is stabilized, the door slams shut
and Medeas possessed form briefly appears behind the glass panel.
Time Travel / Ghost Realm (Optional):
- Objects might be anchored in the ghost realm,
forcing the player to alternate realities to fully dispel them.
*/
break;
case DanielLoopState.Loop9:
Debug.Log("Player is in Loop 9");
/* --------------------------------------------------------------------------------
LOOP 9: DANIELS OFFICE “BLACKLIGHT RUNES” PUZZLE
--------------------------------------------------------------------------------
Story Focus:
- Corruption deepens; the office is fully tainted by Medeas rituals.
- Daniels notes suggest hidden runes visible only under special light.
Puzzle Mechanics:
1) The entire office is draped in torn pages from a ritual manuscript.
2) A blacklight lantern must be found (possibly in a locked cabinet).
3) Activating the blacklight reveals invisible runes or sigils on the walls/floor.
4) Player must trace or “connect” these runes in the correct order
to unlock a hidden safe/drawer.
5) Inside the safe: another body-part (e.g., Daniels Skull) or a piece of it.
Time Travel / Ghost Realm:
- Flickers of the past show Daniel researching frantically,
scrawling runes in desperation to protect himself.
Jump Scare:
- When the last rune is drawn, the lights strobe and a nightmarish reflection
of Medea stands behind the player in the blacklight glow.*/
break;
case DanielLoopState.Loop10:
Debug.Log("Player is in Loop 10");
/* --------------------------------------------------------------------------------
LOOP 10: HALLWAY “RED LIGHT, GREEN LIGHT” (PENDULUM / STEALTH)
--------------------------------------------------------------------------------
Story Focus:
- Medeas sadistic side emerges, turning the hallway into a deadly game zone.
- The hallway is longer, twisted, with flickering lights at each end.
Puzzle Mechanics:
1) Medea periodically switches the corridor lights from green to red:
- Green = Player can move forward.
- Red = Player must freeze or risk Medeas instant attack.
2) Obstacles: furniture, broken floorboards, or pendulum traps
(giant swinging blades).
3) The player times movements carefully to reach the end of the hallway.
4) Final door: locked behind a small lever puzzle or code.
Completing it yields Daniels next body-part (e.g., a Spine piece).
Time Travel / Ghost Realm:
- Failing the stealth might fling the player into a ghost realm briefly,
where they see visions of Daniel cowering from Medea.
Jump Scare:
- Moving on Red triggers a sudden lunge from Medea or a stealth kill scene.*/
break;
case DanielLoopState.Loop11:
Debug.Log("Player is in Loop 11");
/* --------------------------------------------------------------------------------
LOOP 11: PARENTS BEDROOM “EXORCISM CIRCLE” OR MIRROR LABYRINTH
--------------------------------------------------------------------------------
Story Focus:
- Confronting the true depth of Medeas possession and hints of exorcism.
Puzzle Mechanics (Two Options):
A) Exorcism Circle:
- Player finds chalk outlines on the bedroom floor and partial scriptures
indicating an exorcism attempt.
- Must place candles, recite lines (in correct order), and align certain
items (e.g., holy symbol, childrens photo, ring) to activate the circle.
- Successful completion reveals a hidden nook under the bed or in a closet
containing Daniels Lungs (symbolizing his suffocated cries).
B) Mirror Labyrinth:
- The bedrooms walls are lined with tall mirrors, distorting space.
- Some mirrors reflect a different “version” of the room (ghost realm).
- The player navigates by stepping “into” mirrors when aligned correctly.
- The final mirror leads to a secret chamber or hidden wardrobe with
the body-part inside.
Time Travel / Ghost Realm:
- Essential for navigating mirrored illusions or for glimpsing the correct
exorcism incantation in the past.
Jump Scare:
- If the incantation is read wrong or a mirror is used incorrectly,
Medeas demonic reflection appears, lunging at the player.*/
break;
case DanielLoopState.Loop12:
Debug.Log("Player is in Loop 12");
/* --------------------------------------------------------------------------------
LOOP 12: HALLWAY “SHATTERED MIRROR” & ULTIMATE CONFRONTATION
--------------------------------------------------------------------------------
Story Focus:
- The affairs tragic climax; final revelations about Daniels downfall.
Puzzle Mechanics:
1) The hallway is blocked by a large, shattered mirror.
2) Collect mirror shards scattered around (some in ghost realm, some hidden
under debris).
3) Each shard, when inspected, shows a partial memory:
- Daniels final confrontation with Medea, the childrens terror, or the
mistresss final words.
4) Reassembling the mirror fully reveals a “window” into the moment Daniel
is mortally wounded. The puzzles completion grants another piece of
Daniels body (e.g., his Hands).
Time Travel / Ghost Realm:
- Placing shards might require traveling between the corridors past/present
states or using a ghostly overlay to find pieces that dont exist physically
in the present.
Jump Scare:
- Once the mirror is restored, an intense cutscene of Daniels final fight
with Medea briefly plays, concluding with Medeas distorted scream echoing
in the hallway.*/
break;
case DanielLoopState.Loop13:
Debug.Log("Player is in Loop 13");
/* Loop 13:
* “House of Horrors” puzzle, combining illusions from all previous puzzles
in the hallway or bedroom. The environment might shift unpredictably
between each loops theme.
* A forced chase scene where the player must hide or outrun Medea while
grabbing a crucial item (Daniels Blood Vial, symbolizing his ultimate end).*/
break;
case DanielLoopState.Loop14:
Debug.Log("Player is in Loop 14");
/*Daniels Office final meltdown: Broken desks, swirling shadows.
* Possibly an “audio puzzle” where phone lines are crossed with spirit voices.
* The last puzzle piece might be intangible—Daniels Soul Fragment trapped
in a sealed notebook or safe.*/
break;
case DanielLoopState.Loop15:
Debug.Log("Player is in Loop 15");
/* The “Tragic End” puzzle: The player tries one final, desperate act
(burning the ritual book, or an exorcism attempt). Ultimately reveals
Daniels final body-part or essence.
*/
break;
case DanielLoopState.Loop16:
Debug.Log("Player is in Loop 16");
/* Loop 16: Mannequin Stand or Ritual Altar
- Player places each collected body-part (heart, eyes, skull, etc.)
in designated slots or hooks. Each piece may require solving a short
“locking mechanism” (like rotating runic rings or repeating a memory
sequence) to attach it properly.*/
break;
case DanielLoopState.Loop17:
Debug.Log("Player is in Loop 17");
/* - A deep-dive puzzle into Medeas memories/psyche, potentially in
Parents Bedroom or an otherworldly version of it.
- The environment is flooded with regrets, illusions, and diaries
revealing her motivations. The final living confrontation between
Daniel and Medea might be shown in full.*/
break;
case DanielLoopState.Loop18:
Debug.Log("Daniel is in Loop 18 (final loop).");
/* The final door opens in the hallway or office, leading to a place
beyond the usual map (an attic or basement labyrinth).
- A confrontation: the fully reconstructed Daniel, Medea (possessed
or remorseful), and the malevolent force.
- Possible endings:
* The cycle repeats: The house resets, leaving the player trapped.
* Daniels spirit is freed, laying his soul to rest.
* Medea is either destroyed by or liberated from the entity.
*/
// Possibly call NotifyCompletion() when done:
NotifyCompletion();
break;
default:
Debug.Log("Unhandled Daniel Loop State: " + currentDanielLoopState);
break;
}
// Save whenever we enter a new state
SaveStorylineState();
}
/// <summary>
/// Moves to the next loop state, if available.
/// </summary>
public void UpdateToNextLoopState()
{
DanielLoopState[] allStates = (DanielLoopState[])Enum.GetValues(typeof(DanielLoopState));
int currentIndex = Array.IndexOf(allStates, currentDanielLoopState);
if (currentIndex < allStates.Length - 1)
{
// Move to the next loop
currentDanielLoopState = allStates[currentIndex + 1];
UpdateStoryline();
}
else
{
Debug.Log("All Daniel Loops are complete.");
// Once the last loop finishes, notify the GameManager to move on:
NotifyCompletion();
}
}
/// <summary>
/// Attempt to load the saved Daniel loop state from GameProgressManager.
/// </summary>
private void TryLoadSavedState()
{
var gameProgressManager = GameProgressManager.GetInstance();
if (gameProgressManager == null) return;
if (Enum.TryParse(gameProgressManager.currentStorylineState, out DanielLoopState savedState))
{
currentDanielLoopState = savedState;
Debug.Log("Loaded Daniel Loop State from save: " + savedState);
}
else
{
Debug.LogWarning("No valid saved Daniel loop state found. Starting at Loop1.");
currentDanielLoopState = DanielLoopState.Loop1;
}
// After loading, were no longer in a loading phase
isLoadingDanielLoops = false;
}
/// <summary>
/// Saves the current Daniel loop state to GameProgressManager.
/// </summary>
private void SaveStorylineState()
{
var gameProgressManager = GameProgressManager.GetInstance();
if (gameProgressManager == null) return;
gameProgressManager.currentStorylineState = currentDanielLoopState.ToString();
}
/// <summary>
/// Performs any final logic, then notifies GameManager this section is complete.
/// </summary>
private void NotifyCompletion()
{
// This triggers a transition in the GameManager
GameManager.GetInstance().OnStorySectionComplete(GameManager.StoryState.DanielLoops);
}
/// <summary>
/// Resets or cleans up player settings if needed.
/// </summary>
private void CleanupPlayerSettings()
{
var playerManager = PlayerManager.GetInstance();
if (playerManager != null)
{
// Example: disable player movement if transitioning states
// playerManager.DisablePlayerMovement();
}
Debug.Log("Cleaned up settings specific to Daniel Loops.");
}
}