From 06ffe6ef6662431d20f03dea1c5ec82630c782b5 Mon Sep 17 00:00:00 2001 From: haziqam <103514359+haziqam@users.noreply.github.com> Date: Tue, 7 May 2024 20:35:51 +0700 Subject: [PATCH] fix: spawner Co-authored-by: NAME 13521043@std.stei.itb.ac.id --- .../Assets/Code/Scripts/EnemyController.cs | 32 ++++++++++--------- .../Assets/Code/Scripts/KerocoBehaviour.cs | 6 ++-- .../Assets/Level/Prefabs/Keroco.prefab | 5 ++- .../Assets/Level/Scenes/Main.unity | 5 +-- ..._Nature_Free_URP_12.1.13.unitypackage.meta | 7 ---- ...T_Nature_Free_URP_14.0.9.unitypackage.meta | 7 ---- ...T_Nature_Free_URP_16.0.5.unitypackage.meta | 7 ---- .../com.unity.probuilder/Settings.json | 5 +++ 8 files changed, 30 insertions(+), 44 deletions(-) delete mode 100644 IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_12.1.13.unitypackage.meta delete mode 100644 IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_14.0.9.unitypackage.meta delete mode 100644 IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_16.0.5.unitypackage.meta diff --git a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs index 7f3276df..45edfd61 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/EnemyController.cs @@ -5,47 +5,49 @@ using UnityEngine; public class EnemyController : MonoBehaviour { - public GameObject EnemyKerocoRef; - public GameObject EnemyKeroco; - public int xPos; - public int yPos; - public int zPos; - public int kerocoCount; + private GameObject EnemyKerocoRef; + private int xPos = 18; + private int yPos = 80; + private int zPos = -9; + public int kerocoCount = 0; public int kerocoCountMax = 5; // Start is called before the first frame update - + void Start() { + EnemyKerocoRef = Instantiate(GameObject.Find("Keroco")); + EnemyKerocoRef.SetActive(false); StartCoroutine(KerocoDrop()); - //EnemyKeroco = EnemyKerocoRef; } IEnumerator KerocoDrop() { Debug.Log("in thread: " + kerocoCount); - while (kerocoCount < kerocoCountMax) + while (true) { if (kerocoCount < kerocoCountMax) { - xPos = Random.Range(1, 50); - zPos = Random.Range(1, 31); - Instantiate(EnemyKeroco, new Vector3(xPos, yPos, zPos), Quaternion.identity); - yield return new WaitForSeconds(0.1f); + //xPos = Random.Range(1, 50); + //zPos = Random.Range(1, 31); + GameObject newKeroco = Instantiate(EnemyKerocoRef, new Vector3(xPos, yPos, zPos), Quaternion.identity); + newKeroco.SetActive(true); + newKeroco.GetComponent<CombatBehavior>().health = 50; kerocoCount++; } + yield return new WaitForSeconds(0.1f); } } public void DecrementKeroco() { kerocoCount--; - Debug.Log(kerocoCount); + Debug.Log("keroco count: " + kerocoCount); } // Update is called once per frame void Update() { - + } } diff --git a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/KerocoBehaviour.cs b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/KerocoBehaviour.cs index 38de4c4b..7b0fcd35 100644 --- a/IF3210-2024-Unity-AFK/Assets/Code/Scripts/KerocoBehaviour.cs +++ b/IF3210-2024-Unity-AFK/Assets/Code/Scripts/KerocoBehaviour.cs @@ -9,7 +9,7 @@ public class KerocoBehaviour : MonoBehaviour public Transform target; public float attackRange = 5.0f; public float speed = 3.0f; - public GameObject Controller; + private GameObject Controller; NavMeshAgent agent; Animator playerAnimator; @@ -18,6 +18,7 @@ public class KerocoBehaviour : MonoBehaviour void Start() { agent = GetComponent<NavMeshAgent>(); + Controller = GameObject.Find("Controller"); playerAnimator = GetComponent<Animator>(); playerAnimator.SetBool("IsChasing", true); } @@ -34,12 +35,11 @@ public class KerocoBehaviour : MonoBehaviour Vector3 lookAt = target.position; lookAt.y = transform.forward.y; transform.LookAt(lookAt); - + // Fix x-axis rotation to 0 Quaternion currentRotation = transform.rotation; Quaternion newRotation = Quaternion.Euler(0, currentRotation.eulerAngles.y, currentRotation.eulerAngles.z); transform.rotation = newRotation; - } else { diff --git a/IF3210-2024-Unity-AFK/Assets/Level/Prefabs/Keroco.prefab b/IF3210-2024-Unity-AFK/Assets/Level/Prefabs/Keroco.prefab index 4fa6ef9e..c28b55b4 100644 --- a/IF3210-2024-Unity-AFK/Assets/Level/Prefabs/Keroco.prefab +++ b/IF3210-2024-Unity-AFK/Assets/Level/Prefabs/Keroco.prefab @@ -2723,8 +2723,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8b8f358403013ce4d8d45925db5ac8df, type: 3} m_Name: m_EditorClassIdentifier: - health: 50 - Controller: {fileID: 7065110366914443508, guid: aa6f29a441791614eb4b0f78ec563f40, type: 3} + health: 0 --- !u!136 &174494366588434632 CapsuleCollider: m_ObjectHideFlags: 0 @@ -2782,7 +2781,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c58bf39b95fb2144cbaf4dcf7efe2100, type: 3} m_Name: m_EditorClassIdentifier: - target: {fileID: 957227382899443712, guid: 96674196a45debf4ba0a3fada63f2b22, type: 3} + target: {fileID: 0} attackRange: 5 speed: 3 --- !u!114 &6077615853408305588 diff --git a/IF3210-2024-Unity-AFK/Assets/Level/Scenes/Main.unity b/IF3210-2024-Unity-AFK/Assets/Level/Scenes/Main.unity index 614e95f4..f55bb452 100644 --- a/IF3210-2024-Unity-AFK/Assets/Level/Scenes/Main.unity +++ b/IF3210-2024-Unity-AFK/Assets/Level/Scenes/Main.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.7341055, g: 0.68551, b: 0.6916617, a: 1} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -4953,7 +4953,7 @@ PrefabInstance: - target: {fileID: 3402518154619197484, guid: 7c133b828d3b7114098e2855f9afe261, type: 3} propertyPath: Controller value: - objectReference: {fileID: 2023143898} + objectReference: {fileID: 0} - target: {fileID: 5443179323524176954, guid: 7c133b828d3b7114098e2855f9afe261, type: 3} propertyPath: m_LocalPosition.x value: 19.58 @@ -5591,3 +5591,4 @@ SceneRoots: - {fileID: 11205413} - {fileID: 1341964652} - {fileID: 2095108084} + - {fileID: 7721921063603110246} diff --git a/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_12.1.13.unitypackage.meta b/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_12.1.13.unitypackage.meta deleted file mode 100644 index 907f0b2f..00000000 --- a/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_12.1.13.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: fae09cfceda875146a4f9a54fa30589e -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_14.0.9.unitypackage.meta b/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_14.0.9.unitypackage.meta deleted file mode 100644 index 447413ca..00000000 --- a/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_14.0.9.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: bd960d1781917284bb89077cf66b65fe -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_16.0.5.unitypackage.meta b/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_16.0.5.unitypackage.meta deleted file mode 100644 index a4d8a8b9..00000000 --- a/IF3210-2024-Unity-AFK/Assets/Polytope Studio/Lowpoly_Environments/SRP/PT_Nature_Free_URP_16.0.5.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b2b57b8ebc2bca44eacd6d991d27ea97 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/IF3210-2024-Unity-AFK/ProjectSettings/Packages/com.unity.probuilder/Settings.json b/IF3210-2024-Unity-AFK/ProjectSettings/Packages/com.unity.probuilder/Settings.json index 1521b161..61ce685a 100644 --- a/IF3210-2024-Unity-AFK/ProjectSettings/Packages/com.unity.probuilder/Settings.json +++ b/IF3210-2024-Unity-AFK/ProjectSettings/Packages/com.unity.probuilder/Settings.json @@ -35,6 +35,11 @@ "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "key": "editor.toolbarIconGUI", "value": "{\"m_Value\":false}" + }, + { + "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", + "key": "experimental.enabled", + "value": "{\"m_Value\":false}" } ] } -- GitLab