diff --git a/Assets/Quirky Series Ultimate/FREE/Prefabs/Colobus.prefab b/Assets/Quirky Series Ultimate/FREE/Prefabs/Colobus.prefab index 009c8407c51afbb37f5c50c5bf46dc1236207e43..d9939f87a0696366ca07a1deb86168de1f703bc6 100644 --- a/Assets/Quirky Series Ultimate/FREE/Prefabs/Colobus.prefab +++ b/Assets/Quirky Series Ultimate/FREE/Prefabs/Colobus.prefab @@ -595,7 +595,7 @@ GameObject: - component: {fileID: 4750033175939967768} m_Layer: 6 m_Name: Colobus - m_TagString: Untagged + m_TagString: Pet m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -888,6 +888,7 @@ MonoBehaviour: startingHealth: 100 sinkSpeed: 2.5 deathClip: {fileID: 8300000, guid: d36a393bca4582043982db9089e1694f, type: 3} + healthSlider: {fileID: 0} --- !u!114 &4750033175939967768 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Quirky Series Ultimate/FREE/Prefabs/Gecko.prefab b/Assets/Quirky Series Ultimate/FREE/Prefabs/Gecko.prefab index 816e12ef6756cf0a003dcd477b16f81d4b425866..ccc5a0736d17ac36b928a5e954c175556b1aa9c3 100644 --- a/Assets/Quirky Series Ultimate/FREE/Prefabs/Gecko.prefab +++ b/Assets/Quirky Series Ultimate/FREE/Prefabs/Gecko.prefab @@ -402,7 +402,7 @@ GameObject: - component: {fileID: 8511865338824139242} m_Layer: 6 m_Name: Gecko - m_TagString: Untagged + m_TagString: Pet m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -695,6 +695,7 @@ MonoBehaviour: startingHealth: 100 sinkSpeed: 2.5 deathClip: {fileID: 0} + healthSlider: {fileID: 0} --- !u!114 &244745341400185104 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Level01.unity b/Assets/Scenes/Level01.unity index 7cd18be87cd5413da41a768e966dd94eef8c3f02..7903e3d592bb79270fccf8d5e892d320e77f0c62 100644 --- a/Assets/Scenes/Level01.unity +++ b/Assets/Scenes/Level01.unity @@ -11409,7 +11409,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Pet 2 + m_text: Gecko m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 5302535af1044152a457ed104f1f4b91, type: 2} m_sharedMaterial: {fileID: 2164040, guid: 5302535af1044152a457ed104f1f4b91, type: 2} @@ -12625,7 +12625,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Pet 1 + m_text: Colobus m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 5302535af1044152a457ed104f1f4b91, type: 2} m_sharedMaterial: {fileID: 2164040, guid: 5302535af1044152a457ed104f1f4b91, type: 2} @@ -17304,6 +17304,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 645013070751802181, guid: cefda5744f2acb54d8f08973a10bee1e, type: 3} + propertyPath: healthSlider + value: + objectReference: {fileID: 918813968} - target: {fileID: 6842458599697738422, guid: cefda5744f2acb54d8f08973a10bee1e, type: 3} propertyPath: m_Name value: Gecko @@ -17414,6 +17418,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 262469637662761712, guid: 84b7c8441f160174fa5c6f94cf397f0a, type: 3} + propertyPath: healthSlider + value: + objectReference: {fileID: 927042515} - target: {fileID: 4992758198669102562, guid: 84b7c8441f160174fa5c6f94cf397f0a, type: 3} propertyPath: m_LocalPosition.x value: -1.0720851 diff --git a/Assets/Scripts/Enemy/EnemyAttack.cs b/Assets/Scripts/Enemy/EnemyAttack.cs index 395a1b7fc039bde0fc0ba5341b9a84b022c6d157..7e3309e94d96f231de098fd5aa19fb762cfbd3bd 100644 --- a/Assets/Scripts/Enemy/EnemyAttack.cs +++ b/Assets/Scripts/Enemy/EnemyAttack.cs @@ -12,6 +12,8 @@ namespace Nightmare GameObject player; PlayerHealth playerHealth; EnemyHealth enemyHealth; + PetHealth petHealth; + bool petInRange; bool playerInRange; float timer; @@ -39,6 +41,11 @@ namespace Nightmare // ... the player is in range. playerInRange = true; } + else if (other.gameObject.CompareTag("Pet") && !other.isTrigger) + { + petHealth = other.gameObject.GetComponent<PetHealth>(); + petInRange = true; + } } void OnTriggerExit (Collider other) @@ -49,6 +56,10 @@ namespace Nightmare // ... the player is no longer in range. playerInRange = false; } + else if (other.gameObject.CompareTag("Pet") && !other.isTrigger) + { + petInRange = false; + } } void Update () @@ -60,7 +71,7 @@ namespace Nightmare timer += Time.deltaTime; // If the timer exceeds the time between attacks, the player is in range and this enemy is alive... - if(timer >= timeBetweenAttacks && playerInRange && enemyHealth.CurrentHealth() > 0) + if(timer >= timeBetweenAttacks && (playerInRange || petInRange) && enemyHealth.CurrentHealth() > 0) { // ... attack. Attack (); @@ -79,11 +90,21 @@ namespace Nightmare // Reset the timer. timer = 0f; - // If the player has health to lose... - if(playerHealth.currentHealth > 0) + // Taking Damage + if (playerInRange) + { + if (playerHealth.currentHealth > 0) + { + playerHealth.TakeDamage(attackDamage); + } + } + + if (petInRange) { - // ... damage the player. - playerHealth.TakeDamage (attackDamage); + if (petHealth.CurrentHealth() > 0) + { + petHealth.TakeDamage(attackDamage); + } } } } diff --git a/Assets/Scripts/Pet/PetHealth.cs b/Assets/Scripts/Pet/PetHealth.cs index 092f3098279d492b456fd44b350d8eea8e585538..29fabba90deffd265ae6fde662570a05ca5ae8c1 100644 --- a/Assets/Scripts/Pet/PetHealth.cs +++ b/Assets/Scripts/Pet/PetHealth.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.UI; namespace Nightmare { @@ -7,6 +8,7 @@ namespace Nightmare public int startingHealth = 100; public float sinkSpeed = 2.5f; public AudioClip deathClip; + public Slider healthSlider; int currentHealth; Animator anim; @@ -57,15 +59,12 @@ namespace Nightmare { petAudio.Play(); currentHealth -= amount; + healthSlider.value = currentHealth; if (IsDead()) { Death(); } - else - { - petMovement.GoToPlayer(); - } } } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 3a4eb6b8dda8a2a42d5591e5ac87d12362df609c..5b6aa1124a343d1d62e6ee9defd8aed9de88608e 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -11,6 +11,7 @@ TagManager: - ZomBoss - Weapon - DropLootTracker + - Pet layers: - Default - TransparentFX