Added Car Alarm Super Surprise
This commit is contained in:
parent
8dfbd22a9e
commit
f737955a88
10 changed files with 1240 additions and 304 deletions
151
Assets/PreFabs/Cart.prefab
Normal file
151
Assets/PreFabs/Cart.prefab
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &7491510820959603103
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1488588279737489770}
|
||||||
|
- component: {fileID: 1203144855618869351}
|
||||||
|
- component: {fileID: 8413131400950349524}
|
||||||
|
- component: {fileID: 4110432774671697138}
|
||||||
|
- component: {fileID: 6972504037698060136}
|
||||||
|
- component: {fileID: 1843446778422354759}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Cart
|
||||||
|
m_TagString: Cart
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1488588279737489770
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7491510820959603103}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -8, y: 0.75, z: 10}
|
||||||
|
m_LocalScale: {x: 2, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!33 &1203144855618869351
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7491510820959603103}
|
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!23 &8413131400950349524
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7491510820959603103}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: a84c2cb3f4c900345a97055492617a74, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!65 &4110432774671697138
|
||||||
|
BoxCollider:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7491510820959603103}
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_ProvidesContacts: 0
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 3
|
||||||
|
m_Size: {x: 1, y: 1, z: 1}
|
||||||
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!54 &6972504037698060136
|
||||||
|
Rigidbody:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7491510820959603103}
|
||||||
|
serializedVersion: 4
|
||||||
|
m_Mass: 1
|
||||||
|
m_Drag: 0
|
||||||
|
m_AngularDrag: 0
|
||||||
|
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
||||||
|
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
||||||
|
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ImplicitCom: 1
|
||||||
|
m_ImplicitTensor: 1
|
||||||
|
m_UseGravity: 1
|
||||||
|
m_IsKinematic: 0
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_Constraints: 0
|
||||||
|
m_CollisionDetection: 0
|
||||||
|
--- !u!114 &1843446778422354759
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7491510820959603103}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 440c1e39b1656d3429dfd613d4616cae, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
holdDistance: 3
|
||||||
|
moveSpeed: 5
|
||||||
|
floatHeight: 0.75
|
||||||
7
Assets/PreFabs/Cart.prefab.meta
Normal file
7
Assets/PreFabs/Cart.prefab.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4e94005988ff6384b8eca0588b2070ee
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load diff
50
Assets/Scripts/CartSpawner.cs
Normal file
50
Assets/Scripts/CartSpawner.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CartSpawner : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject cartPrefab;
|
||||||
|
public Vector3 spawnAreaCenter;
|
||||||
|
public Vector3 spawnAreaSize;
|
||||||
|
public float spawnInterval = 10f; // Time (seconds) between spawns
|
||||||
|
public int maxCartsInScene = 5; // Prevent too many carts
|
||||||
|
|
||||||
|
private int currentCarts = 0;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(SpawnCartsOverTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Collections.IEnumerator SpawnCartsOverTime()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (currentCarts < maxCartsInScene)
|
||||||
|
{
|
||||||
|
Vector3 spawnPosition = GetRandomPositionInArea();
|
||||||
|
GameObject newCart = Instantiate(cartPrefab, spawnPosition, Quaternion.identity);
|
||||||
|
currentCarts++;
|
||||||
|
|
||||||
|
// When cart is returned/destroyed, decrement the counter
|
||||||
|
CartTracker tracker = newCart.AddComponent<CartTracker>();
|
||||||
|
tracker.spawner = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(spawnInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 GetRandomPositionInArea()
|
||||||
|
{
|
||||||
|
float x = Random.Range(-spawnAreaSize.x / 2, spawnAreaSize.x / 2);
|
||||||
|
float z = Random.Range(-spawnAreaSize.z / 2, spawnAreaSize.z / 2);
|
||||||
|
float y = spawnAreaCenter.y;
|
||||||
|
|
||||||
|
return spawnAreaCenter + new Vector3(x, 0f, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CartRemoved()
|
||||||
|
{
|
||||||
|
currentCarts--;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/CartSpawner.cs.meta
Normal file
11
Assets/Scripts/CartSpawner.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 40621e6d3a4e6ed429913f31cb7221a2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
14
Assets/Scripts/CartTracker.cs
Normal file
14
Assets/Scripts/CartTracker.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class CartTracker : MonoBehaviour
|
||||||
|
{
|
||||||
|
public CartSpawner spawner;
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
if (spawner != null)
|
||||||
|
{
|
||||||
|
spawner.CartRemoved();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/CartTracker.cs.meta
Normal file
11
Assets/Scripts/CartTracker.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d11eb3a23e430834b99cc3ad0b769300
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
35
Assets/Scripts/MainMenuController.cs
Normal file
35
Assets/Scripts/MainMenuController.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class MainMenuController : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GameObject startMenuUI;
|
||||||
|
public GameObject gameUI;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
Time.timeScale = 0f;
|
||||||
|
startMenuUI.SetActive(true);
|
||||||
|
if (gameUI != null)
|
||||||
|
gameUI.SetActive(false);
|
||||||
|
|
||||||
|
Cursor.lockState = CursorLockMode.None;
|
||||||
|
Cursor.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartGame()
|
||||||
|
{
|
||||||
|
startMenuUI.SetActive(false);
|
||||||
|
if (gameUI != null)
|
||||||
|
gameUI.SetActive(true);
|
||||||
|
Time.timeScale = 1f;
|
||||||
|
|
||||||
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
|
Cursor.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void QuitGame()
|
||||||
|
{
|
||||||
|
Debug.Log("Quitting game...");
|
||||||
|
Application.Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/MainMenuController.cs.meta
Normal file
11
Assets/Scripts/MainMenuController.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fd46f649f628e04ba6adc84b937ba97
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -22,7 +22,7 @@ public class PlayerGrabber : MonoBehaviour
|
||||||
|
|
||||||
if (heldCart != null)
|
if (heldCart != null)
|
||||||
{
|
{
|
||||||
heldCart.HoldCart(); // Let it keep following while held
|
heldCart.HoldCart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue