Building out Golf Level and mission states and improved AI

This commit is contained in:
2026-09-01 16:33:49 +01:00
parent 04047ddf57
commit 5f76d7b002
63 changed files with 102312 additions and 1834 deletions

View File

@@ -0,0 +1,58 @@
using UnityEngine;
using System.Collections;
using ArcadeVP;
public class SafeHouseTrigger : MonoBehaviour
{
[Tooltip("Optional: Drag your GarageDoor script here so it shuts behind you when you park.")]
public GarageDoor garageDoor;
private bool triggered = false;
private void OnTriggerEnter(Collider other)
{
// Ignore if the game is already over or we already triggered this
if (triggered || GameManager.Instance == null || GameManager.Instance.isGameOver) return;
ArcadeVehicleController vehicle = null;
// Check if the object entering the trigger is the Player directly
if (other.CompareTag("Player"))
{
vehicle = other.GetComponent<ArcadeVehicleController>();
if (vehicle == null) vehicle = other.GetComponentInParent<ArcadeVehicleController>();
}
else
{
// Also check if a child collider of the player entered
vehicle = other.GetComponentInParent<ArcadeVehicleController>();
}
if (vehicle != null && vehicle.CompareTag("Player"))
{
triggered = true;
StartCoroutine(WaitToStopAndClose(vehicle));
}
}
private IEnumerator WaitToStopAndClose(ArcadeVehicleController vehicle)
{
// Wait until the car has essentially stopped moving (speed < 1 m/s)
while (vehicle.carBody != null && vehicle.carBody.linearVelocity.magnitude > 1f)
{
yield return null;
}
// Shut the garage door!
if (garageDoor != null)
{
garageDoor.CloseDoor();
// Wait 2.5 seconds for the door to visually close before ending the level
yield return new WaitForSeconds(2.5f);
}
// Complete the level
GameManager.Instance.EnterSafeHouse();
}
}