From b9d524dc7472a3f10e444f50cc41dc3789c61049 Mon Sep 17 00:00:00 2001 From: sumertayoga <13520021@std.stei.itb.ac.id> Date: Sat, 15 Apr 2023 13:41:57 +0700 Subject: [PATCH] update wiz stat and pet sound --- My project/Assets/Prefabs/Wizard.prefab | 4 ++-- My project/Assets/Scripts/Pet/PetHealth.cs | 9 ++++++--- My project/Assets/Scripts/Pet/PetManager.cs | 8 ++++---- .../Assets/Scripts/Pet/WizardController.cs | 17 +++++++++-------- My project/Assets/Scripts/Pet/WizardHealth.cs | 9 ++++++--- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/My project/Assets/Prefabs/Wizard.prefab b/My project/Assets/Prefabs/Wizard.prefab index d6a992a..7e7bb93 100644 --- a/My project/Assets/Prefabs/Wizard.prefab +++ b/My project/Assets/Prefabs/Wizard.prefab @@ -1793,7 +1793,7 @@ NavMeshAgent: m_Acceleration: 8 avoidancePriority: 50 m_AngularSpeed: 120 - m_StoppingDistance: 7 + m_StoppingDistance: 9 m_AutoTraverseOffMeshLink: 1 m_AutoBraking: 1 m_AutoRepath: 1 @@ -7928,6 +7928,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: eedd0e136b375a047bd0f49cbc28eace, type: 3} m_Name: m_EditorClassIdentifier: - damagePerShot: 30 + damagePerShot: 60 timeBetweenBullets: 0.15 range: 100 diff --git a/My project/Assets/Scripts/Pet/PetHealth.cs b/My project/Assets/Scripts/Pet/PetHealth.cs index d708fa8..6639eab 100644 --- a/My project/Assets/Scripts/Pet/PetHealth.cs +++ b/My project/Assets/Scripts/Pet/PetHealth.cs @@ -50,9 +50,12 @@ public class PetHealth : MonoBehaviour StartCoroutine(Death()); } } - StateController.petCurrentHealth = currentHealth; - petAudio.clip = hurtClip; - petAudio.Play(); + if(currentHealth > 0) + { + StateController.petCurrentHealth = currentHealth; + petAudio.clip = hurtClip; + petAudio.Play(); + } } public IEnumerator Death() diff --git a/My project/Assets/Scripts/Pet/PetManager.cs b/My project/Assets/Scripts/Pet/PetManager.cs index bc08b60..2a99403 100644 --- a/My project/Assets/Scripts/Pet/PetManager.cs +++ b/My project/Assets/Scripts/Pet/PetManager.cs @@ -27,10 +27,10 @@ public class PetManager : MonoBehaviour void Update() { - int spawnEnemy = 0; - if(Input.GetKeyDown(KeyCode.P) && !CheatController.isCheatEnabled){ - SpawnPet(spawnEnemy); - } + // int spawnEnemy = 0; + // if(Input.GetKeyDown(KeyCode.P) && !CheatController.isCheatEnabled){ + // SpawnPet(spawnEnemy); + // } } public void SpawnPet(int tag){ diff --git a/My project/Assets/Scripts/Pet/WizardController.cs b/My project/Assets/Scripts/Pet/WizardController.cs index e798904..a4f54c9 100644 --- a/My project/Assets/Scripts/Pet/WizardController.cs +++ b/My project/Assets/Scripts/Pet/WizardController.cs @@ -25,8 +25,8 @@ public class WizardController : MonoBehaviour void Update() { - colliderInSight = Physics.OverlapSphere(transform.position, 10, whatIsEnemy); - colliderInAttack = Physics.OverlapSphere(transform.position, 7, whatIsEnemy); + colliderInSight = Physics.OverlapSphere(transform.position, 12, whatIsEnemy); + colliderInAttack = Physics.OverlapSphere(transform.position, 9, whatIsEnemy); if(colliderInSight?.Length > 0) { @@ -59,12 +59,12 @@ public class WizardController : MonoBehaviour } transform.LookAt(enemy); - if(!alreadyAttacked) + if(!alreadyAttacked && enemy.GetComponent<EnemyHealth>().currentHealth > 0) { StartCoroutine(wizShooting.Shoot()); alreadyAttacked = true; - Invoke(nameof(ResetAttack), 1f); + Invoke(nameof(ResetAttack), 0.7f); } } @@ -75,8 +75,9 @@ public class WizardController : MonoBehaviour void ChaseEnemy(Transform enemy) { - nav.stoppingDistance = 7; - nav.SetDestination(colliderInSight[0].gameObject.transform.position); + if(enemy.GetComponent<EnemyHealth>().currentHealth <= 0) return; + nav.stoppingDistance = 9; + nav.SetDestination(enemy.position); if(nav.remainingDistance < nav.stoppingDistance) { anim.SetBool("isWalking", false); @@ -89,8 +90,8 @@ public class WizardController : MonoBehaviour void FollowPlayer() { - nav.stoppingDistance = 5; - if(Vector3.Distance(nav.transform.position, player.position) <= 5) + nav.stoppingDistance = 7; + if(Vector3.Distance(nav.transform.position, player.position) <= nav.stoppingDistance) { anim.SetBool("isWalking", false); return; diff --git a/My project/Assets/Scripts/Pet/WizardHealth.cs b/My project/Assets/Scripts/Pet/WizardHealth.cs index 71f4ff3..27779d1 100644 --- a/My project/Assets/Scripts/Pet/WizardHealth.cs +++ b/My project/Assets/Scripts/Pet/WizardHealth.cs @@ -51,9 +51,12 @@ public class WizardHealth : MonoBehaviour StartCoroutine(Death()); } } - petAudio.clip = hurtClip; - petAudio.Play(); - StateController.petCurrentHealth = currentHealth; + if(currentHealth > 0) + { + StateController.petCurrentHealth = currentHealth; + petAudio.clip = hurtClip; + petAudio.Play(); + } } public IEnumerator Death() -- GitLab