diff --git a/Assets/Scenes/TEST.unity b/Assets/Scenes/TEST.unity index 6541659e..4190f9bb 100644 --- a/Assets/Scenes/TEST.unity +++ b/Assets/Scenes/TEST.unity @@ -419,10 +419,67 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ca1a9a3813a058946990c84846f54c17, type: 3} m_Name: m_EditorClassIdentifier: Assembly-CSharp::DeathTrapSpawner - deathTrapPrefab: {fileID: 6121659928201372921, guid: 2489c1d80f2f9074888a06f59f372161, type: 3} - spawnInterval: 10 - minLifetime: 3 - maxLifetime: 8 +--- !u!1001 &1436576813 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: -5076913349690967641, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: SortKey + value: 3478665629 + objectReference: {fileID: 0} + - target: {fileID: 1054594849095937263, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_Name + value: Player + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalPosition.x + value: 2.43947 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalPosition.y + value: -4.20374 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalPosition.z + value: -9.47261 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3} --- !u!1 &1490570703 GameObject: m_ObjectHideFlags: 0 @@ -908,7 +965,8 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - m_RemovedComponents: [] + m_RemovedComponents: + - {fileID: 8714104882223651289, guid: 2489c1d80f2f9074888a06f59f372161, type: 3} m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: [] @@ -920,3 +978,4 @@ SceneRoots: - {fileID: 2120030154} - {fileID: 982050945} - {fileID: 4899204113511701172} + - {fileID: 1436576813} diff --git a/Assets/Scripts/Manager/DeathTrapCollision.cs b/Assets/Scripts/Manager/DeathTrapCollision.cs deleted file mode 100644 index d205b750..00000000 --- a/Assets/Scripts/Manager/DeathTrapCollision.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class DeathTrapCollision : MonoBehaviour { - private void OnTriggerEnter(Collider other) { - // Check if the object colliding with the trap is the player - // Assumes the player character (e.g., Bob) has the tag "Player" - if (other.CompareTag("Player")) { - // Trigger the Game Over event via the GameManager - FindObjectOfType().TriggerGameOver(); - - // Destroy the player object upon collision - Destroy(other.gameObject); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Manager/DeathTrapCollision.cs.meta b/Assets/Scripts/Manager/DeathTrapCollision.cs.meta deleted file mode 100644 index 1de32b94..00000000 --- a/Assets/Scripts/Manager/DeathTrapCollision.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 1746534d206b0fe4b8e895df471d3d56 \ No newline at end of file diff --git a/Assets/Scripts/Trap.meta b/Assets/Scripts/Trap.meta new file mode 100644 index 00000000..859d6ece --- /dev/null +++ b/Assets/Scripts/Trap.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 82bfa2ea8f45df942b2e9d2855a5ff6e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Manager/DeathTrapSpawner.cs b/Assets/Scripts/Trap/TeleportTrap.cs similarity index 52% rename from Assets/Scripts/Manager/DeathTrapSpawner.cs rename to Assets/Scripts/Trap/TeleportTrap.cs index e7a53961..76d80603 100644 --- a/Assets/Scripts/Manager/DeathTrapSpawner.cs +++ b/Assets/Scripts/Trap/TeleportTrap.cs @@ -1,12 +1,8 @@ -using System.Collections; -using System.Collections.Generic; + using UnityEngine; -public class DeathTrapSpawner : MonoBehaviour { - public GameObject deathTrapPrefab; // Prefab for the death trap - public float spawnInterval = 10f; // Time interval between spawns - public float minLifetime = 3f; // Minimum lifetime of the death trap - public float maxLifetime = 8f; // Maximum lifetime of the death trap +public class TeleportTrap : MonoBehaviour { + private Vector3 GetRandomPosition() { Vector3 randomPosition; @@ -38,25 +34,16 @@ public class DeathTrapSpawner : MonoBehaviour { return randomPosition; } - private IEnumerator SpawnDeathTraps() { - while (true) { - // Generate a random spawn position - Vector3 spawnPosition = GetRandomPosition(); + private Vector3 GetPositionTeleport() { + Vector3 spawnPosition = GetRandomPosition(); + return spawnPosition; + } - // Spawn a new death trap at the random position - GameObject deathTrap = Instantiate(deathTrapPrefab, spawnPosition, Quaternion.identity); - - // Determine a random lifetime for the trap and destroy it after that time - float lifetime = Random.Range(minLifetime, maxLifetime); - Destroy(deathTrap, lifetime); - - // Wait for the specified spawn interval before spawning the next trap - yield return new WaitForSeconds(spawnInterval); + private void OnCollisionEnter(Collision collision) + { + if (collision.gameObject.CompareTag("Player")) + { + collision.transform.position = GetPositionTeleport(); } } - - private void Start() { - // Start the coroutine to spawn death traps - StartCoroutine(SpawnDeathTraps()); - } } \ No newline at end of file diff --git a/Assets/Scripts/Manager/DeathTrapSpawner.cs.meta b/Assets/Scripts/Trap/TeleportTrap.cs.meta similarity index 100% rename from Assets/Scripts/Manager/DeathTrapSpawner.cs.meta rename to Assets/Scripts/Trap/TeleportTrap.cs.meta