Added Start Menu, -Added CartSpawner, -Added Get Car Key Objective

This commit is contained in:
apolloxyx 2025-05-08 22:17:04 -04:00
parent f737955a88
commit e7f50f7108
100 changed files with 5304 additions and 16 deletions

View file

@ -1,35 +1,57 @@
using UnityEngine;
using TMPro; // Import for TextMeshPro
using TMPro;
public class CartReturnZone : MonoBehaviour
{
public TMP_Text scoreText; // Reference to the TMP text
public AudioSource returnSound; // Sound to play when cart is returned
public CarAlarm carAlarm; // Reference to the CarAlarm script
public TMP_Text scoreText; // UI score display
public AudioSource returnSound; // Cart return sound
public CarAlarm carAlarm; // Car alarm script
public GameObject keyPrefab; // The key object to spawn
public Transform keySpawnPoint; // Where to spawn the key
public int cartsNeeded = 2; // How many to trigger car alarm
public int cartsToEndDay = 10; // How many to spawn keys
private int score = 0;
public int cartsNeeded = 2; // Number of carts required to trigger alarm
private int cartsReturned = 0; // Counter for returned carts
private int cartsReturned = 0;
private bool keysSpawned = false;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Cart"))
{
score++;
scoreText.text = "Score: " + score; // Update the TMP UI
scoreText.text = "Score: " + score;
returnSound.Play(); // Play sound when cart is returned
returnSound.Play();
// Increase the cart return counter
cartsReturned++;
// Check if enough carts have been returned
if (cartsReturned >= cartsNeeded)
if (cartsReturned == cartsNeeded)
{
carAlarm?.TriggerAlarm(); // Trigger the alarm
carAlarm?.TriggerAlarm();
}
if (score >= cartsToEndDay && !keysSpawned)
{
SpawnKeys();
}
// Optionally: Destroy or deactivate the cart when it's returned
Destroy(other.gameObject);
}
}
private void SpawnKeys()
{
if (keyPrefab != null && keySpawnPoint != null)
{
Instantiate(keyPrefab, keySpawnPoint.position, Quaternion.identity);
keysSpawned = true;
Debug.Log("Keys spawned near the car.");
}
else
{
Debug.LogWarning("Key prefab or spawn point is not assigned!");
}
}
}

View file

@ -0,0 +1,32 @@
using UnityEngine;
using TMPro;
public class Day1CarExitTrigger : MonoBehaviour
{
public GameObject dayCompleteUI; // UI panel that shows "Day 1 Complete!"
public TMP_Text messageText; // Optional text to show messages
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
if (KeyPickup.hasKeys)
{
if (dayCompleteUI != null)
dayCompleteUI.SetActive(true);
if (messageText != null)
messageText.text = "Day 1 Complete!";
Debug.Log("Day complete! Player has keys.");
Time.timeScale = 0f;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
else
{
if (messageText != null)
messageText.text = "You need to find your keys near the car!";
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af1bf7877d7405047afe9a3a59f3ea63
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,16 @@
using UnityEngine;
public class KeyPickup : MonoBehaviour
{
public static bool hasKeys = false;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
hasKeys = true;
Debug.Log("Picked up the keys!");
Destroy(gameObject);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1afb084224635154cb35b554337852ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -14,6 +14,8 @@ public class MainMenuController : MonoBehaviour
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
Debug.Log("Main menu started — cursor should be visible.");
}
public void StartGame()
@ -21,10 +23,12 @@ public class MainMenuController : MonoBehaviour
startMenuUI.SetActive(false);
if (gameUI != null)
gameUI.SetActive(true);
Time.timeScale = 1f;
Time.timeScale = 1f;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
Debug.Log("Game started — cursor locked.");
}
public void QuitGame()