initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class ActivateObjectAfterDelay : MonoBehaviour
|
||||
{
|
||||
// Time delay in seconds
|
||||
public float delay = 5.0f;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
// Start the coroutine
|
||||
StartCoroutine(ActivationRoutine());
|
||||
}
|
||||
|
||||
// Coroutine to activate child objects after a delay
|
||||
private IEnumerator ActivationRoutine()
|
||||
{
|
||||
// Wait for the specified delay
|
||||
yield return new WaitForSeconds(delay);
|
||||
|
||||
// Activate all child objects
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
child.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42677bf45c23e4b6597a41235dd51157
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
public class CheckCodeEntered : MonoBehaviour
|
||||
{
|
||||
public InputField codeInputField; // Reference to the Input Field
|
||||
public ParticleSystem correctEffect; // Reference to the GameObject to activate
|
||||
public AudioSource correctSound; // Reference to the Audio Source
|
||||
public AudioSource incorrectSound; // Reference to the Audio Source
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Add listener for when the value of the text in the input field changes
|
||||
codeInputField.onValueChanged.AddListener(OnInputFieldChanged);
|
||||
}
|
||||
|
||||
private void OnInputFieldChanged(string text)
|
||||
{
|
||||
// Check if the input field has exactly 4 characters
|
||||
if (text.Length == 4)
|
||||
{
|
||||
ValidateCode();
|
||||
// Start the coroutine to clear the input field after a delay
|
||||
StartCoroutine(ClearInputFieldAfterDelay(0.5f));
|
||||
}
|
||||
else if (text.Length > 4)
|
||||
{
|
||||
// If more than 4 characters are entered, truncate the text
|
||||
codeInputField.text = text.Substring(0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator ClearInputFieldAfterDelay(float delay)
|
||||
{
|
||||
// Wait for the specified delay
|
||||
yield return new WaitForSeconds(delay);
|
||||
|
||||
// Clear the input field and reset it for new input
|
||||
codeInputField.text = "";
|
||||
codeInputField.ActivateInputField();
|
||||
}
|
||||
|
||||
public void ValidateCode()
|
||||
{
|
||||
if (codeInputField != null)
|
||||
{
|
||||
string code = codeInputField.text;
|
||||
if (code == "2004")
|
||||
{
|
||||
// Activate the GameObject
|
||||
correctEffect.Play();
|
||||
// Play correct sound
|
||||
correctSound.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Play incorrect sound
|
||||
incorrectSound.Play();
|
||||
|
||||
// Start the shake animation
|
||||
StartCoroutine(ShakeInputField(0.5f, 0.1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coroutine for shaking the input field
|
||||
private IEnumerator ShakeInputField(float duration, float magnitude)
|
||||
{
|
||||
Vector3 originalPosition = codeInputField.transform.localPosition;
|
||||
float elapsed = 0.0f;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
float x = originalPosition.x + Random.Range(-50f, 50f) * magnitude;
|
||||
codeInputField.transform.localPosition = new Vector3(x, originalPosition.y, originalPosition.z);
|
||||
|
||||
elapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
codeInputField.transform.localPosition = originalPosition;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51357fbc908ae41a1969ba8f2c421267
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class CustomSceneManager : MonoBehaviour
|
||||
{
|
||||
// Static reference to the instance of our SceneManager
|
||||
public static CustomSceneManager instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Check if instance already exists
|
||||
if (instance == null)
|
||||
{
|
||||
// If not, set instance to this
|
||||
instance = this;
|
||||
}
|
||||
else if (instance != this)
|
||||
{
|
||||
// If instance already exists and it's not this, then destroy this to enforce the singleton.
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
// Set this to not be destroyed when reloading scene
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Check if the user is on a non-main scene and presses the Escape key
|
||||
if (SceneManager.GetActiveScene().buildIndex != 0 && Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
// Load the main scene (assuming the main scene is at build index 0)
|
||||
LoadScene(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// General method to load scenes based on build index
|
||||
private void LoadScene(int sceneIndex)
|
||||
{
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e082e8f53c38e48f58c33e81e7fe0d95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorController : MonoBehaviour
|
||||
{
|
||||
private Animator doorAnimator;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
doorAnimator = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Debug.Log("Open the door");
|
||||
doorAnimator.SetTrigger("Door_Open");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78d1990d1a22e479fbef01ccee59622f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LoadSceneByIndex : MonoBehaviour
|
||||
{
|
||||
// General method to load scenes based on build index
|
||||
public void LoadScene(int sceneIndex)
|
||||
{
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf8e0821bf13549cd8cf9cb0c116f46c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlaySoundAtRandomIntervals : MonoBehaviour
|
||||
{
|
||||
public float minSeconds = 5f; // Minimum interval to wait before playing sound.
|
||||
public float maxSeconds = 15f; // Maximum interval to wait before playing sound.
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
StartCoroutine(PlaySound());
|
||||
}
|
||||
|
||||
private IEnumerator PlaySound()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
float waitTime = Random.Range(minSeconds, maxSeconds);
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efb7247c0c3fe4f72bfa3eb83a43e505
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SimpleCameraController : MonoBehaviour
|
||||
{
|
||||
public float moveSpeed = 3.0f; // Movement speed
|
||||
public float rotationSpeed = 100.0f; // Rotation speed for A/D keys in degrees per second
|
||||
public float mouseSensitivity = 1.0f; // Mouse look sensitivity
|
||||
|
||||
private float rotationX = 0.0f; // Rotation around the X axis (up and down look)
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Movement
|
||||
float moveForward = Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime;
|
||||
|
||||
// Translate only on the X-Z plane (global Y remains unchanged)
|
||||
Vector3 moveDirection = new Vector3(transform.forward.x, 0.0f, transform.forward.z).normalized;
|
||||
transform.Translate(moveDirection * moveForward, Space.World);
|
||||
|
||||
// Rotation with A/D keys
|
||||
float turn = Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime;
|
||||
transform.Rotate(0, turn, 0, Space.World); // Rotate around the global Y axis
|
||||
|
||||
// Mouse Look
|
||||
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
|
||||
|
||||
rotationX -= mouseY; // Subtracting to invert the up and down look
|
||||
rotationX = Mathf.Clamp(rotationX, -90f, 90f); // Clamp the up and down look to avoid flipping
|
||||
|
||||
transform.localEulerAngles = new Vector3(rotationX, transform.localEulerAngles.y, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa7720d1c6c9d4766aedcef4986abdc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class StarterSceneStar : MonoBehaviour
|
||||
{
|
||||
[Header("Effects")]
|
||||
public GameObject particleEffectPrefab; // Assign particle system prefab in Inspector
|
||||
|
||||
[Header("Motion Settings")]
|
||||
public float rotationSpeed = 100f; // Rotation speed in degrees per second
|
||||
public float bobbingAmount = 0.5f; // Amplitude of bobbing motion
|
||||
public float bobbingSpeed = 2f; // Speed of bobbing motion
|
||||
|
||||
private Vector3 startPosition;
|
||||
private float timer;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Remember the original position of the GameObject
|
||||
startPosition = transform.position;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Rotate the object around its up axis
|
||||
transform.Rotate(Vector3.forward, rotationSpeed * Time.deltaTime);
|
||||
|
||||
// Create a bobbing motion up and down
|
||||
timer += Time.deltaTime * bobbingSpeed;
|
||||
float newY = startPosition.y + Mathf.Sin(timer) * bobbingAmount;
|
||||
transform.position = new Vector3(transform.position.x, newY, transform.position.z);
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
// Check if the colliding object has the "Player" tag
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
// Instantiate the particle effect
|
||||
if (particleEffectPrefab != null)
|
||||
{
|
||||
Instantiate(particleEffectPrefab, transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
// Destroy the star
|
||||
Destroy(gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55fcea8a4058c4d1aa6ca8fea4168f51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System; // Required for Type handling
|
||||
|
||||
public class UpdateCollectibleCount : MonoBehaviour
|
||||
{
|
||||
private TextMeshProUGUI collectibleText; // Reference to the TextMeshProUGUI component
|
||||
|
||||
void Start()
|
||||
{
|
||||
collectibleText = GetComponent<TextMeshProUGUI>();
|
||||
if (collectibleText == null)
|
||||
{
|
||||
Debug.LogError("UpdateCollectibleCount script requires a TextMeshProUGUI component on the same GameObject.");
|
||||
return;
|
||||
}
|
||||
UpdateCollectibleDisplay(); // Initial update on start
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateCollectibleDisplay();
|
||||
}
|
||||
|
||||
private void UpdateCollectibleDisplay()
|
||||
{
|
||||
int totalCollectibles = 0;
|
||||
|
||||
// Check and count objects of type Collectible
|
||||
Type collectibleType = Type.GetType("Collectible");
|
||||
if (collectibleType != null)
|
||||
{
|
||||
totalCollectibles += UnityEngine.Object.FindObjectsByType(collectibleType, FindObjectsSortMode.None).Length;
|
||||
}
|
||||
|
||||
// Optionally, check and count objects of type Collectible2D as well if needed
|
||||
Type collectible2DType = Type.GetType("Collectible2D");
|
||||
if (collectible2DType != null)
|
||||
{
|
||||
totalCollectibles += UnityEngine.Object.FindObjectsByType(collectible2DType, FindObjectsSortMode.None).Length;
|
||||
}
|
||||
|
||||
// Update the collectible count display
|
||||
collectibleText.text = $"Collectibles remaining: {totalCollectibles}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12b990e8d7f314383856263e97f1c328
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user