Nuclear Mystery
A downloadable game for Windows
You've arrived at Atomic Lake - now transformed into a tourist attraction. However, who knows what memories are hidden in this place? Take a trip of memory and uncover a secret that touches your heart.
Game Level Model:
Game Scripts:
1. UI Fade In and Out
using System.Collections; using UnityEngine; public class UIFadeInandOut : MonoBehaviour { public CanvasGroup uiElement; public float fadeDuration = 1.5f; public float displayDuration = 2f; private bool isFading = false; private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player") && !isFading) { StartCoroutine(FadeInAndOut()); } } IEnumerator FadeInAndOut() { isFading = true; float elapsedTime = 0f; while (elapsedTime < fadeDuration) { elapsedTime += Time.deltaTime; uiElement.alpha = Mathf.Clamp01(elapsedTime / fadeDuration); yield return null; } uiElement.alpha = 1f; yield return new WaitForSeconds(displayDuration); elapsedTime = 0f; while (elapsedTime < fadeDuration) { elapsedTime += Time.deltaTime; uiElement.alpha = Mathf.Clamp01(1f - (elapsedTime / fadeDuration)); } uiElement.alpha = 0f; isFading = false; } }
2. Book UI
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class BookText : MonoBehaviour { public GameObject bookUI; public GameObject guideE; public Button closebutton; public bool isBookOpen = false; public bool comein; public GameObject player; public AudioSource openbook; public AudioSource closebook; void Start() { closebutton.onClick.AddListener(ClosebookUI); } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { guideE.SetActive(true); comein = true; } } private void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) { guideE.SetActive(false); comein = false; bookUI.SetActive(false); } } void Update() { if (comein && Input.GetKeyDown(KeyCode.E)) { if (!isBookOpen) { OpenBook(); } else { ClosebookUI(); } } } void OpenBook() { guideE.SetActive(false); openbook.Play(); bookUI.SetActive(true); isBookOpen = true; } void ClosebookUI() { closebook.Play(); bookUI.SetActive(false); isBookOpen = false; } }
3. Sound Detect Trap Block
using System.Collections; using UnityEngine; public class ItemDetector : MonoBehaviour { public GameObject[] blocks; public AudioSource audioSource; public Material closeMaterial; public Material defaultMaterial; public float detectionDistance = 5f; void Update() { CheckBlocksDistance(); } void CheckBlocksDistance() { foreach (GameObject block in blocks) { float distance = Vector3.Distance(transform.position, block.transform.position); if (distance < detectionDistance) { block.GetComponent<Renderer>().material = closeMaterial; StartCoroutine(Wait()); IEnumerator Wait() { yield return new WaitForSeconds(1.5f); block.GetComponent<Renderer>().material = defaultMaterial; yield return new WaitForSeconds(0.5f); block.GetComponent<Renderer>().enabled = false; } audioSource.volume = Mathf.Clamp01(1 - (distance / detectionDistance)); } else { block.GetComponent<Renderer>().material = defaultMaterial; audioSource.volume = 0; } } } }
4. Light Trap Switch
using System.Collections; using UnityEngine; public class StopwatchController : MonoBehaviour { public GameObject[] lights; public Vector3[] rotationAngles; public GameObject[] traps; public AudioSource play; private bool isRotated = false; private Vector3[] originalRotations; void Start() { if (rotationAngles.Length != lights.Length) { Debug.LogError("Objects to rotate and rotation angles arrays must have the same length!"); return; } originalRotations = new Vector3[lights.Length]; for (int i = 0; i < lights.Length; i++) { originalRotations[i] = lights[i].transform.eulerAngles; } if (traps.Length >= 4) { traps[0].SetActive(true); traps[1].SetActive(false); traps[2].SetActive(true); traps[3].SetActive(false); } } void Update() { if (Input.GetMouseButtonDown(0)) { play.Play(); if (!isRotated) { RotateObjects(); } else { ResetObjectsRotation(); } isRotated = !isRotated; ToggleTraps(); } } void RotateObjects() { for (int i = 0; i < lights.Length; i++) { lights[i].transform.eulerAngles -= rotationAngles[i]; } } void ResetObjectsRotation() { for (int i = 0; i < lights.Length; i++) { lights[i].transform.eulerAngles = originalRotations[i]; } } void ToggleTraps() { if (traps.Length >= 4) { bool trap1Active = traps[0].activeSelf; bool trap2Active = traps[1].activeSelf; bool trap3Active = traps[2].activeSelf; bool trap4Active = traps[3].activeSelf; traps[0].SetActive(!trap1Active); traps[1].SetActive(!trap2Active); traps[2].SetActive(!trap3Active); traps[3].SetActive(!trap4Active); } } }
5. Final Door Open
using System.Collections; using System.Collections.Generic; using Unity.Burst.Intrinsics; using Unity.VisualScripting; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; public class opendoorfinal : MonoBehaviour { public GameObject OpenUI; public bool comein; public Animator dooropen; public AudioSource play; public GameObject door; public Volume globalvolume; public GameObject daylightvolume; public GameObject doortrigger; public VolumeProfile volumeprofile; private ColorAdjustments color; public float transitionDuration = 3f; public void Start() { globalvolume.profile.TryGet(out color); } public void Postprocessvolume() { globalvolume.profile = volumeprofile; } IEnumerator ChangeSaturationGradually(float startValue, float endValue, float duration) { float elapsedTime = 0f; while (elapsedTime < duration) { float currentSaturation = Mathf.Lerp(startValue, endValue, elapsedTime / duration); color.saturation.value = currentSaturation; elapsedTime += Time.deltaTime; yield return null; } color.saturation.value = endValue; } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { OpenUI.SetActive(true); comein = true; } } void Update() { if (comein && Input.GetKeyDown(KeyCode.E)) { Destroy(OpenUI); StartCoroutine(ChangeSaturationGradually(-100f, 0f, transitionDuration)); RenderSettings.fog = false; daylightvolume.SetActive(true); dooropen.SetBool("Open", true); play.Play(); StartCoroutine(Mute()); IEnumerator Mute() { yield return new WaitForSeconds(1.5f); door.GetComponent<AudioSource>().enabled = false; doortrigger.GetComponent<BoxCollider>().enabled = false; } } } }
Download
Download
Nuclear_Mystery 113 MB
Leave a comment
Log in with itch.io to leave a comment.