Warp traps and tidying up the house

This commit is contained in:
2025-12-04 10:53:21 +00:00
parent e0c93be280
commit 00a433132b
38 changed files with 4036 additions and 192 deletions

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 30b3db05cf5720444aeb29bf0fd2822e
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: c435e24017975524c8b66a69bbf99db5
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: b3fc281979327fd4ea48ab0add748e35
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: d3e2c5f35d74ee747b5552d0fc607ffc
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 1a2fa0d484805034b8010c35e5e296b4
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,109 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor; // Required for the buttons to appear
#endif
public class DebugControlPanel : MonoBehaviour
{
[Header("Target Scripts")]
public FrontDoorEvent frontDoorScript;
public StairWarp stairWarpScript;
// We don't need to drag in GameManager since it's a Singleton (GameManager.Instance)
[Header("Status")]
public string lastAction = "None";
// --- HELPER FUNCTIONS FOR THE BUTTONS ---
public void TestDoorbell()
{
if (frontDoorScript != null)
{
frontDoorScript.TriggerEvent();
lastAction = "Triggered Doorbell Sequence";
}
else Debug.LogError("Front Door Script not assigned!");
}
public void TestNightmare()
{
if (GameManager.Instance != null)
{
GameManager.Instance.TriggerNightmareMode();
lastAction = "Triggered Nightmare Mode";
}
else Debug.LogError("GameManager not found!");
}
public void ForceWarp()
{
// Note: You must change 'WarpPlayer' to PUBLIC in StairWarp.cs for this to work
if (stairWarpScript != null)
{
// We pass the player object to the warp script manually for testing
GameObject player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
// Assuming you changed WarpPlayer to public, otherwise this line errors
stairWarpScript.WarpPlayer(player);
lastAction = "Forced Stair Warp";
}
}
}
public void ToggleAllLights()
{
if (GameManager.Instance != null)
{
foreach (LightSwitch sw in GameManager.Instance.allSwitches)
{
sw.Interact(); // Manually click every switch
}
lastAction = "Toggled All Lights";
}
}
}
// --- THE EDITOR MAGIC ---
// This part tells Unity how to draw the inspector for this specific script
#if UNITY_EDITOR
[CustomEditor(typeof(DebugControlPanel))]
public class DebugControlPanelEditor : Editor
{
public override void OnInspectorGUI()
{
// Draw the default variables (the slots to drag scripts into)
DrawDefaultInspector();
// Get reference to the script
DebugControlPanel myScript = (DebugControlPanel)target;
GUILayout.Space(20); // Add some spacing
GUILayout.Label("Event Triggers", EditorStyles.boldLabel);
// Draw Buttons
if (GUILayout.Button("Trigger Doorbell Event"))
{
myScript.TestDoorbell();
}
if (GUILayout.Button("Trigger Nightmare Mode"))
{
myScript.TestNightmare();
}
if (GUILayout.Button("Toggle All Lights"))
{
myScript.ToggleAllLights();
}
GUILayout.Space(10);
if (GUILayout.Button("Force Warp Player"))
{
myScript.ForceWarp();
}
}
}
#endif

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5e7c43ef1e9c4ea4285a66d4b9b1b630

View File

@@ -45,7 +45,7 @@ public class DoorController : MonoBehaviour, IInteractable
{
PlaySound(stuckSound);
// Optional: Add a tiny visual "shake" here if you want advanced polish
return;
return;
}
// 2. Toggle State

View File

@@ -0,0 +1,165 @@
using UnityEngine;
using System.Collections;
public class FrontDoorEvent : MonoBehaviour, IInteractable
{
[Header("Door Settings")]
public float openAngle = 90f;
public float smoothSpeed = 2f;
[Header("Audio Clips")]
public AudioSource doorSource;
public AudioClip doorbellClip;
public AudioClip voiceClip; // <--- NEW: The voice line
[Tooltip("IMPORTANT: This must be a SINGLE knock sound, not a loop!")]
public AudioClip singleKnockClip;
public AudioClip doorOpenSound;
// windSound is removed
[Header("Timeline Settings")]
public float timeBeforeVoice = 3f; // Ring for 3 seconds
public float timeAfterVoice = 3f; // Ring for 3 seconds AFTER voice, then knock
[Header("Knocking Settings")]
[Range(0.1f, 1f)] public float heavyPitch = 0.8f;
public float totalKnockingDuration = 8f;
public float startDelay = 1.0f;
public float endDelay = 0.1f;
// State
private bool isOpen = false;
private bool eventActive = false;
private Quaternion initialRotation;
private Quaternion targetRotation;
void Start()
{
initialRotation = transform.localRotation;
targetRotation = initialRotation;
if(GameManager.Instance != null) GameManager.Instance.frontDoor = this;
}
void Update()
{
transform.localRotation = Quaternion.Slerp(transform.localRotation, targetRotation, Time.deltaTime * smoothSpeed);
}
public void TriggerEvent()
{
if(eventActive || isOpen) return;
eventActive = true;
StartCoroutine(TheHauntingSequence());
}
IEnumerator TheHauntingSequence()
{
// --- PHASE 1: INITIAL RINGING ---
doorSource.pitch = 1f;
doorSource.volume = 0.5f;
doorSource.clip = doorbellClip;
doorSource.loop = true;
doorSource.Play();
// Wait...
float timer = 0f;
while (timer < timeBeforeVoice && !isOpen)
{
timer += Time.deltaTime;
yield return null;
}
if (isOpen) yield break;
// --- PHASE 2: THE VOICE ---
if (voiceClip != null)
{
doorSource.Stop(); // Cut the bell
doorSource.loop = false;
// Play Voice
doorSource.PlayOneShot(voiceClip);
// Wait for the exact length of the voice clip
float voiceTimer = 0f;
while (voiceTimer < voiceClip.length && !isOpen)
{
voiceTimer += Time.deltaTime;
yield return null;
}
}
if (isOpen) yield break;
// --- PHASE 3: RESUME RINGING ---
doorSource.clip = doorbellClip;
doorSource.loop = true;
doorSource.Play();
timer = 0f;
while (timer < timeAfterVoice && !isOpen)
{
timer += Time.deltaTime;
yield return null;
}
if (isOpen) yield break;
// --- PHASE 4: AGGRESSIVE KNOCKING (The Drummer Method) ---
doorSource.Stop();
doorSource.loop = false;
doorSource.pitch = heavyPitch; // Drop pitch for bass
float knockTimer = 0f;
while (knockTimer < totalKnockingDuration && !isOpen)
{
float progress = knockTimer / totalKnockingDuration;
// Volume Up
float currentVol = Mathf.Lerp(0.4f, 1f, progress);
doorSource.PlayOneShot(singleKnockClip, currentVol);
// Speed Up (Reduce Delay)
float currentDelay = Mathf.Lerp(startDelay, endDelay, progress);
// Wait for delay
float subTimer = 0f;
while(subTimer < currentDelay)
{
subTimer += Time.deltaTime;
knockTimer += Time.deltaTime;
if(isOpen) yield break;
yield return null;
}
}
// --- PHASE 5: SILENCE ---
Debug.Log("Knocking finished. Dead silence.");
}
public void Interact()
{
if (isOpen) return;
// Player Opened the Door!
isOpen = true;
eventActive = false;
// Open Visuals
targetRotation = initialRotation * Quaternion.Euler(0, openAngle, 0);
// Audio Reset
doorSource.Stop();
doorSource.pitch = 1f;
doorSource.volume = 1f;
// Just play the open sound, NO wind following it
doorSource.PlayOneShot(doorOpenSound);
// Trigger Nightmare Mode
if(GameManager.Instance != null) GameManager.Instance.TriggerNightmareMode();
}
public string GetDescription()
{
if (eventActive) return "Press [E] to <color=red>Check Noise</color>";
return isOpen ? "" : "Press [E] to Open";
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 48ce9e6b570caba4cb19ff957d7791a4

View File

@@ -6,6 +6,11 @@ public class GameManager : MonoBehaviour
public static GameManager Instance;
public List<LightSwitch> allSwitches = new List<LightSwitch>();
[Header("Front Door Event")]
public FrontDoorEvent frontDoor; // Assigned automatically by the door script
public int lightsOffToTriggerDoor = 4; // Event happens after 4 lights turned off
private int lightsTurnedOffCounter = 0;
void Awake()
{
if (Instance == null) Instance = this;
@@ -19,16 +24,18 @@ public class GameManager : MonoBehaviour
public void CheckLights()
{
bool anyLightsOn = false;
int currentOffCount = 0;
foreach (LightSwitch sw in allSwitches)
{
if (sw.isLightOn) anyLightsOn = true;
if (!sw.isLightOn) currentOffCount++;
}
if (!anyLightsOn)
// Check if we hit the threshold for the doorbell
if (currentOffCount >= lightsOffToTriggerDoor && frontDoor != null)
{
Debug.Log("All lights are off. Player can go to bed.");
// You can enable the "Bed" interaction collider here
frontDoor.TriggerEvent();
// Set to null so it doesn't trigger twice
frontDoor = null;
}
}
@@ -57,4 +64,24 @@ public class GameManager : MonoBehaviour
}
return false;
}
public void TriggerNightmareMode()
{
Debug.Log("NOBODY IS HOME. NIGHTMARE MODE ACTIVE.");
foreach(LightSwitch sw in allSwitches)
{
// 1. Turn all lights back ON
sw.ForceLightOn();
// 2. Increase Difficulty (59% increase)
// If chance was 0.1 (10%), it becomes roughly 0.16
sw.malfunctionChance += (sw.malfunctionChance * 0.59f);
// Cap it so it's not impossible (e.g., max 50% fail rate)
if (sw.malfunctionChance > 0.5f) sw.malfunctionChance = 0.5f;
// 3. Make random scares more frequent
sw.subsequentEventChance += 10f;
}
}
}

View File

@@ -4,12 +4,12 @@ public class HauntedPhone : MonoBehaviour
{
public AudioSource phoneAudioSource;
public AudioClip ringSound;
private bool isRinging = false;
void Start()
{
if(phoneAudioSource == null) phoneAudioSource = GetComponent<AudioSource>();
if (phoneAudioSource == null) phoneAudioSource = GetComponent<AudioSource>();
phoneAudioSource.loop = true; // Make sure the ringing loops!
}

View File

@@ -4,12 +4,12 @@ public class HauntedPram : MonoBehaviour
{
public AudioSource pramAudioSource, babyAudioSource;
public AudioClip creakSound, babyCrySound;
private bool isCreaking = false, isCrying = false;
void Start()
{
if(pramAudioSource == null) pramAudioSource = GetComponent<AudioSource>();
if (pramAudioSource == null) pramAudioSource = GetComponent<AudioSource>();
pramAudioSource.loop = true; // Make sure the creaking loops!
}

View File

@@ -5,14 +5,14 @@ public class HauntedTV : MonoBehaviour
public AudioSource tvAudioSource, tvLaughAudioSource, watcherAudioSource;
public AudioClip tvLaughSound, tvSound, watcherLaughSound;
public Light tvLight;
private bool isOn = false;
void Start()
{
if(tvAudioSource == null) tvAudioSource = GetComponent<AudioSource>();
if (tvAudioSource == null) tvAudioSource = GetComponent<AudioSource>();
tvAudioSource.loop = true; // Make sure the static loops!
if(watcherAudioSource == null) watcherAudioSource = GetComponent<AudioSource>();
if (watcherAudioSource == null) watcherAudioSource = GetComponent<AudioSource>();
watcherAudioSource.loop = true; // Make sure the laugh loops!
if (tvLight != null) tvLight.enabled = false;
}

View File

@@ -5,9 +5,9 @@ public class HeadBobber : MonoBehaviour
[Header("Settings")]
public float bobSpeed = 14f; // How fast the head bobs
public float bobAmount = 0.05f; // How high/low the head goes
[Tooltip("Reference to the parent player object")]
public CharacterController playerController;
public CharacterController playerController;
private float defaultPosY = 0;
private float timer = 0;

View File

@@ -4,10 +4,10 @@ public class InfiniteStairs : MonoBehaviour
{
[Header("Settings")]
[Tooltip("How many times must they climb before the loop breaks?")]
public int loopsRequired = 3;
public int loopsRequired = 3;
[Tooltip("Drag an empty GameObject here. Position it lower down the stairs.")]
public Transform resetPoint;
public Transform[] resetPoint;
private int currentLoops = 0;
@@ -26,12 +26,14 @@ public class InfiniteStairs : MonoBehaviour
// 2. Teleport
// We keep their Rotation exactly the same, only changing Position
CharacterController cc = other.GetComponent<CharacterController>();
// You must disable CC briefly to teleport, or it sometimes fights back
if (cc != null) cc.enabled = false;
other.transform.position = resetPoint.position + offset;
foreach (Transform resetPoint in resetPoint)
{
other.transform.position = resetPoint.position + offset;
}
if (cc != null) cc.enabled = true;
// 3. Increment Loop

View File

@@ -5,7 +5,7 @@ public class InteractionUI : MonoBehaviour
{
public static InteractionUI Instance; // Singleton for easy access
public TextMeshProUGUI promptText;
void Awake()
{
if (Instance == null) Instance = this;
@@ -14,7 +14,7 @@ public class InteractionUI : MonoBehaviour
void Start()
{
// Hide text at start
if(promptText != null) promptText.text = "";
if (promptText != null) promptText.text = "";
}
public void UpdatePrompt(string message)

View File

@@ -6,7 +6,7 @@ public class LightSwitch : MonoBehaviour, IInteractable
[Header("Settings")]
public Light[] linkedLight;
public bool isLightOn = true;
[Header("Audio")]
public AudioSource audioSource;
public AudioClip switchClickSound;
@@ -14,7 +14,7 @@ public class LightSwitch : MonoBehaviour, IInteractable
[Header("Horror Mechanics")]
[Range(0f, 1f)] public float malfunctionChance = 0.1f;
// --- NEW EVENT SYSTEM ---
[Header("Event System")]
[Tooltip("If true, the Special Events below will fire on the first interaction.")]
@@ -40,7 +40,7 @@ public class LightSwitch : MonoBehaviour, IInteractable
{
if (audioSource == null) audioSource = GetComponent<AudioSource>();
UpdateLightState();
if(GameManager.Instance != null) GameManager.Instance.RegisterSwitch(this);
if (GameManager.Instance != null) GameManager.Instance.RegisterSwitch(this);
}
public void Interact()
@@ -49,15 +49,15 @@ public class LightSwitch : MonoBehaviour, IInteractable
if (Random.value < malfunctionChance)
{
PlaySound(malfunctionSound);
return;
return;
}
// 2. Toggle Light
isLightOn = !isLightOn;
PlaySound(switchClickSound);
UpdateLightState();
if(GameManager.Instance != null) GameManager.Instance.CheckLights();
if (GameManager.Instance != null) GameManager.Instance.CheckLights();
// 3. HANDLE EVENTS
HandleEvents();
@@ -94,14 +94,14 @@ public class LightSwitch : MonoBehaviour, IInteractable
public void ForceLightOn()
{
isLightOn = true;
PlaySound(switchClickSound);
PlaySound(switchClickSound);
UpdateLightState();
}
void UpdateLightState()
{
foreach(var linkedLight in linkedLight)
if(linkedLight != null) linkedLight.enabled = isLightOn;
foreach (var linkedLight in linkedLight)
if (linkedLight != null) linkedLight.enabled = isLightOn;
}
void PlaySound(AudioClip clip)

View File

@@ -1,5 +1,5 @@
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
@@ -10,7 +10,7 @@ public class PlayerController : MonoBehaviour
[Header("Look Settings")]
public float mouseSensitivity = 10f;
public float maxLookAngle = 70f;
public float maxLookAngle = 70f;
[Header("Interaction")]
public float interactionDistance = 3f;
@@ -19,12 +19,12 @@ public class PlayerController : MonoBehaviour
// Components
private CharacterController controller;
private Transform cameraTransform;
// State
private float verticalRotation = 0f;
private Vector3 velocity; // Stores our falling speed
private bool isGrounded; // Are we touching the floor?
// Inputs
private InputSystem_Actions inputActions;
private Vector2 moveInput;
@@ -34,7 +34,7 @@ public class PlayerController : MonoBehaviour
inputActions = new InputSystem_Actions();
controller = GetComponent<CharacterController>();
cameraTransform = Camera.main.transform;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
@@ -52,11 +52,13 @@ public class PlayerController : MonoBehaviour
HandleGravity(); // <--- NEW GRAVITY FUNCTION
HandleMovement();
HandleLook();
UpdateInteractionUI();
UpdateInteractionUI();
}
void HandleGravity()
{
// If the trap disabled our controller, do not apply gravity!
if (controller == null || !controller.enabled) return;
// Check if the controller thinks it's on the ground
isGrounded = controller.isGrounded;
@@ -75,6 +77,7 @@ public class PlayerController : MonoBehaviour
void HandleMovement()
{
if (controller == null || !controller.enabled) return;
Vector3 move = transform.right * moveInput.x + transform.forward * moveInput.y;
controller.Move(move * moveSpeed * Time.deltaTime);
}
@@ -83,11 +86,11 @@ public class PlayerController : MonoBehaviour
// For brevity, I am not pasting the repeated Look/Interact code here,
// but ensure you keep those functions in your file!
// If you need the full paste again, let me know.
// ------------------------------------------------------------------------
// PASTE YOUR HandleLook, UpdateInteractionUI, and TryInteract HERE
// ------------------------------------------------------------------------
void HandleLook()
{
Vector2 rawInput = inputActions.Player.Look.ReadValue<Vector2>();
@@ -127,7 +130,7 @@ public class PlayerController : MonoBehaviour
if (interactable != null)
{
interactable.Interact();
if (InteractionUI.Instance != null)
if (InteractionUI.Instance != null)
InteractionUI.Instance.UpdatePrompt(interactable.GetDescription());
}
}

View File

@@ -0,0 +1,66 @@
using UnityEngine;
public class StairWarp : MonoBehaviour
{
[Header("Standard Warps")]
public Transform[] randomRooms;
[Header("Special Traps")]
public TVRoomTrap tvTrapScript; // <--- ASSIGN THIS IN INSPECTOR
[Range(0, 100)] public float trapChance = 10f; // 10% chance for the TV Trap
[Header("General Settings")]
[Range(0, 100)] public float warpChance = 30f;
public AudioSource audioSource;
public AudioClip warpWhooshSound;
private bool hasTriggered = false;
public void WarpPlayer(GameObject player)
{
// 1. Check for SPECIAL TRAP first
// If we have the script assigned and roll the dice successfully...
if (tvTrapScript != null && Random.Range(0, 100) < trapChance)
{
Debug.Log("TRIGGERING TV TRAP!");
tvTrapScript.TriggerTrap(player);
return; // Exit function, do not do normal warp
}
// 2. Normal Room Warp (Your existing logic)
if (randomRooms.Length == 0) return;
Transform target = randomRooms[Random.Range(0, randomRooms.Length)];
CharacterController cc = player.GetComponent<CharacterController>();
if (cc != null) cc.enabled = false;
player.transform.position = target.position;
player.transform.rotation = target.rotation;
if (cc != null) cc.enabled = true;
if (audioSource != null && warpWhooshSound != null)
audioSource.PlayOneShot(warpWhooshSound);
Debug.Log("Player warped to: " + target.name);
}
// (Keep your OnTriggerEnter / OnTriggerExit logic the same,
// just make sure OnTriggerEnter calls WarpPlayer(other.gameObject))
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player") && !hasTriggered)
{
hasTriggered = true;
if (Random.Range(0, 100) < warpChance)
{
WarpPlayer(other.gameObject);
}
}
}
void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player")) hasTriggered = false;
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1625fad95a27da744bea569f094bc36f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,15 +1,15 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.SceneManagement;
public class StaircaseCurse : MonoBehaviour
{
[Header("Don't Look Back Settings")]
[Range(-1f, 1f)] public float killThreshold = -0.2f;
public GameObject blackScreenPanel;
[Range(-1f, 1f)] public float killThreshold = -0.2f;
public GameObject blackScreenPanel;
[Header("Spooky Audio System")]
[Tooltip("Drag empty GameObjects with AudioSources from around the map here")]
public AudioSource[] environmentalSources;
public AudioSource[] environmentalSources;
public AudioClip[] scaryClips; // Whispers, footsteps, wood creaks
[Tooltip("Minimum seconds between random noises")]
public float minSoundDelay = 2f;
@@ -37,7 +37,7 @@ public class StaircaseCurse : MonoBehaviour
if (GameManager.Instance != null && !GameManager.Instance.AreAnyLightsOn())
{
CheckPlayerFacing();
// 2. HANDLE RANDOM AUDIO
HandleAudio();
}
@@ -46,7 +46,7 @@ public class StaircaseCurse : MonoBehaviour
void HandleAudio()
{
soundTimer -= Time.deltaTime;
if (soundTimer <= 0)
{
PlayRandomSound();
@@ -88,11 +88,11 @@ public class StaircaseCurse : MonoBehaviour
{
isDead = true;
if (blackScreenPanel != null) blackScreenPanel.SetActive(true);
// Disable controls
if (playerTransform.GetComponent<PlayerController>())
playerTransform.GetComponent<PlayerController>().enabled = false;
Invoke("RestartLevel", 3f);
}

View File

@@ -0,0 +1,69 @@
using UnityEngine;
using System.Collections;
public class TVRoomTrap : MonoBehaviour
{
[Header("Warp Locations")]
public Transform tvRoomSpawn; // Where they get trapped (TV Room)
public Transform mainHallSpawn; // Where they escape to (Hallway)
[Header("Room Events")]
public HauntedTV tvScript; // Reference to the TV script
public HauntedPram pramScript; // Reference to the Pram script
[Tooltip("How long they are trapped in the room")]
public float trapDuration = 3.0f;
[Header("Audio")]
public AudioSource trapAudioSource;
public AudioClip warpInSound;
public AudioClip warpOutSound;
// Call this function to start the nightmare
public void TriggerTrap(GameObject player)
{
StartCoroutine(TrapSequence(player));
}
IEnumerator TrapSequence(GameObject player)
{
CharacterController cc = player.GetComponent<CharacterController>();
// 1. DISABLE CONTROLS & PHYSICS
// We disable the CC so it doesn't fight the teleportation
if (cc != null) cc.enabled = false;
// 2. WARP TO TV ROOM
player.transform.position = tvRoomSpawn.position;
player.transform.rotation = tvRoomSpawn.rotation;
// Play Entry Sound
if(trapAudioSource && warpInSound) trapAudioSource.PlayOneShot(warpInSound);
// 3. FORCE TV SCARE
if (tvScript != null && pramScript != null)
{
pramScript.StartAllSounds();
tvScript.StartEvent();
}
// 4. WAIT (The 2 seconds of panic)
yield return new WaitForSeconds(trapDuration);
// 5. WARP TO MAIN HALL
player.transform.position = mainHallSpawn.position;
player.transform.rotation = mainHallSpawn.rotation;
// 6. FORCE TV SCARE
if (tvScript != null && pramScript != null)
{
pramScript.StopAllSounds();
tvScript.StopEvent();
}
// Play Exit Sound
if(trapAudioSource && warpOutSound) trapAudioSource.PlayOneShot(warpOutSound);
// 7. RE-ENABLE CONTROLS
if (cc != null) cc.enabled = true;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 15388158d6be9ad4795d02366d9a5db9

View File

@@ -50,7 +50,7 @@ public class WinZone : MonoBehaviour
{
blackScreenPanel.SetActive(true);
CanvasGroup cg = blackScreenPanel.GetComponent<CanvasGroup>();
// If no CanvasGroup exists, add one
if (cg == null) cg = blackScreenPanel.AddComponent<CanvasGroup>();

View File

@@ -10,7 +10,7 @@ public class CarouselController : MonoBehaviour
[Header("Base Platform")]
public GameObject Platform;
[Header("Cranks")]
public Transform[] Cranks;
@@ -23,7 +23,7 @@ public class CarouselController : MonoBehaviour
//rotate cranks based on ride speed
foreach (Transform crank in Cranks)
{
crank.Rotate(Vector3.forward * (rideSpeed*1.25f) * Time.deltaTime * 10);
crank.Rotate(Vector3.forward * (rideSpeed * 1.25f) * Time.deltaTime * 10);
}
}
}

View File

@@ -51,13 +51,13 @@ public class clownEntranceController : MonoBehaviour
//Apply rotation to each eye
foreach (Transform eyeball in eyeballs)
{
eyeball.localRotation = Quaternion.Slerp(eyeball.localRotation, targetRotation, elapsedTime);
yield return null;
}
}
// Delay before next eye movement
yield return new WaitForSeconds(Random.Range(frequency * 0.75f, frequency * 1.5f));
yield return new WaitForSeconds(Random.Range(frequency * 0.75f, frequency * 1.5f));
}
}

View File

@@ -8,7 +8,7 @@ public class ClownGameController : MonoBehaviour
private float timeCounter = 0.0f;
public float rotationAmount = 40f;
[Range(0,5)]
[Range(0, 5)]
public float speed = 0.5f;
private void Update()

View File

@@ -33,10 +33,10 @@ public class FerrisWheelController : MonoBehaviour
//chair rocking motion
foreach (Transform chair in chairs)
{
{
timeCounter += rockingSpeed * Time.deltaTime;
// rotation speed added to reduce/add more motion depending on ferris wheel speed
float rockingOffset = Mathf.Sin(timeCounter) * rockingAmplitude * (rotationSpeed/10);
float rockingOffset = Mathf.Sin(timeCounter) * rockingAmplitude * (rotationSpeed / 10);
chair.localRotation = Quaternion.Euler(0, 0, rockingOffset);
}
}

View File

@@ -4,7 +4,7 @@ using UnityEngine;
public class SimpleRotateCarnival : MonoBehaviour
{
public bool rotX;
public float rotXSpeed = 50f;
public bool rotY;
@@ -31,5 +31,5 @@ public class SimpleRotateCarnival : MonoBehaviour
}
}

View File

@@ -8,20 +8,20 @@ public class TeaCupController : MonoBehaviour
public GameObject teaPot;
public Transform[] teaCups;
[Range(-60,60)]
public float rideSpeed = 15.0f;
[Range(-60, 60)]
public float rideSpeed = 15.0f;
void Update()
{
//main platform rotation speed
platform.transform.Rotate(Vector3.up * rideSpeed * Time.deltaTime);
//centre ornament (teapot) rotation speed
teaPot.transform.Rotate(Vector3.down * (rideSpeed*0.5f) * Time.deltaTime);
teaPot.transform.Rotate(Vector3.down * (rideSpeed * 0.5f) * Time.deltaTime);
//tea cup rotation's in relation to set ride speed
foreach (Transform teacup in teaCups)
{
teacup.Rotate(Vector3.up * (rideSpeed * 1.5f ) * Time.deltaTime);
}
{
teacup.Rotate(Vector3.up * (rideSpeed * 1.5f) * Time.deltaTime);
}
}
}

View File

@@ -50,7 +50,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 74bf1351d85e78747b7b513adae3b9de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@@ -83,6 +83,7 @@ Material:
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AddPrecomputedVelocity: 0
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
@@ -114,6 +115,7 @@ Material:
- _Surface: 0
- _UVSec: 0
- _WorkflowMode: 1
- _XRMotionVectorsPass: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}