From db576d54112634c16ba28d0be59a9296dec9c824 Mon Sep 17 00:00:00 2001
From: Enderageous <13520012@std.stei.itb.ac.id>
Date: Sat, 15 Apr 2023 12:54:56 +0700
Subject: [PATCH] feat: PetAttack AI

---
 Assets/Prefabs/ShopKeeperCanvas.prefab |  2 +-
 Assets/Scripts/Pets/PetAttack.cs       | 10 +---------
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/Assets/Prefabs/ShopKeeperCanvas.prefab b/Assets/Prefabs/ShopKeeperCanvas.prefab
index 387cad3..faa79eb 100644
--- a/Assets/Prefabs/ShopKeeperCanvas.prefab
+++ b/Assets/Prefabs/ShopKeeperCanvas.prefab
@@ -239,7 +239,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0.5}
   m_AnchorMax: {x: 0, y: 0.5}
-  m_AnchoredPosition: {x: 7694.946, y: 140}
+  m_AnchoredPosition: {x: 7823.336, y: 140}
   m_SizeDelta: {x: 0, y: 0}
   m_Pivot: {x: 0, y: 1}
 --- !u!114 &6427786897761567691
diff --git a/Assets/Scripts/Pets/PetAttack.cs b/Assets/Scripts/Pets/PetAttack.cs
index 0f7214b..3c9096b 100644
--- a/Assets/Scripts/Pets/PetAttack.cs
+++ b/Assets/Scripts/Pets/PetAttack.cs
@@ -8,13 +8,10 @@ public class PetAttack : MonoBehaviour
     public float timeBetweenAttacks = 0.5f;
     public int attackDamage = 10;
 
-    GameObject[] enemy;
-    GameObject[] enemyInRange;
     Animator anim;
     GameObject player;
     PlayerHealth playerHealth;
     EnemyHealth enemyHealth;
-    bool playerInRange;
     bool attacking;
     float timer;
 
@@ -28,7 +25,7 @@ public class PetAttack : MonoBehaviour
 
     void OnTriggerStay(Collider other) 
     {
-     if (enemy.Contains(other.gameObject))
+     if (other.tag == "Enemy")
      {
         Attack(other.gameObject);
      }
@@ -44,11 +41,6 @@ public class PetAttack : MonoBehaviour
             {
                 attacking = true;
             }
-
-            if (playerHealth.currentHealth <= 0)
-            {
-                anim.SetTrigger ("PlayerDead");
-            }
         }
     }
 
-- 
GitLab