From cad87ac96fd0ac3ec5d70076606ca9cc5fa7ab08 Mon Sep 17 00:00:00 2001
From: Salomo309 <109785084+Salomo309@users.noreply.github.com>
Date: Sat, 11 May 2024 00:45:52 +0700
Subject: [PATCH] refactor: done, tinggal hubung ke weapon

---
 .../Enemy/Jenderal/JenderalMovement.cs        | 269 ++++++++---------
 .../Enemy/Kepala Keroco/KepalaKerocoAttack.cs |   6 +-
 .../Kepala Keroco/KepalaKerocoMovement.cs     | 271 +++++++++---------
 Assets/Scripts/Enemy/Raja/RajaAttack.cs       |  22 +-
 Assets/Scripts/Enemy/Raja/RajaMovement.cs     | 271 +++++++++---------
 5 files changed, 427 insertions(+), 412 deletions(-)

diff --git a/Assets/Scripts/Enemy/Jenderal/JenderalMovement.cs b/Assets/Scripts/Enemy/Jenderal/JenderalMovement.cs
index 0459a68..586372a 100644
--- a/Assets/Scripts/Enemy/Jenderal/JenderalMovement.cs
+++ b/Assets/Scripts/Enemy/Jenderal/JenderalMovement.cs
@@ -4,177 +4,180 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.AI;
 
-public class JenderalMovement : PausibleObject
+namespace Nightmare
 {
-
-    public float visionRange = 10f;
-    public float hearingRange = 20f;
-    public float wanderDistance = 10f;
-    public Vector2 idleTimeRange;
-    [Range(0f, 1f)]
-    public float psychicLevels = 0.2f;
-
-    float currentVision;
-    Transform player;
-    PlayerHealth playerHealth;
-    EnemyHealth enemyHealth;
-    NavMeshAgent nav;
-    public float timer = 0f;
-
-    void Awake()
+    public class JenderalMovement : PausibleObject
     {
-        player = GameObject.FindGameObjectWithTag("Player").transform;
-        playerHealth = player.GetComponent<PlayerHealth>();
-        enemyHealth = GetComponent<EnemyHealth>();
-        nav = GetComponent<NavMeshAgent>();
 
-        StartPausible();
-    }
+        public float visionRange = 10f;
+        public float hearingRange = 20f;
+        public float wanderDistance = 10f;
+        public Vector2 idleTimeRange;
+        [Range(0f, 1f)]
+        public float psychicLevels = 0.2f;
 
-    void OnEnable()
-    {
-        nav.enabled = true;
-        ClearPath();
-        ScaleVision(1f);
-        IsPsychic();
-        timer = 0f;
-    }
+        float currentVision;
+        Transform player;
+        PlayerHealth playerHealth;
+        EnemyHealth enemyHealth;
+        NavMeshAgent nav;
+        public float timer = 0f;
 
-    void ClearPath()
-    {
-        if (nav.hasPath)
-            nav.ResetPath();
-    }
+        void Awake()
+        {
+            player = GameObject.FindGameObjectWithTag("Player").transform;
+            playerHealth = player.GetComponent<PlayerHealth>();
+            enemyHealth = GetComponent<EnemyHealth>();
+            nav = GetComponent<NavMeshAgent>();
 
-    void Update()
-    {
-        if (!isPaused)
+            StartPausible();
+        }
+
+        void OnEnable()
         {
-            // If both the enemy and the player have health left...
-            if (enemyHealth.CurrentHealth() > 0 && playerHealth.currentHealth > 0)
-            {
-                LookForPlayer();
-                WanderOrIdle();
-            }
-            else
+            nav.enabled = true;
+            ClearPath();
+            ScaleVision(1f);
+            IsPsychic();
+            timer = 0f;
+        }
+
+        void ClearPath()
+        {
+            if (nav.hasPath)
+                nav.ResetPath();
+        }
+
+        void Update()
+        {
+            if (!isPaused)
             {
-                nav.enabled = false;
+                // If both the enemy and the player have health left...
+                if (enemyHealth.CurrentHealth() > 0 && playerHealth.currentHealth > 0)
+                {
+                    LookForPlayer();
+                    WanderOrIdle();
+                }
+                else
+                {
+                    nav.enabled = false;
+                }
             }
         }
-    }
 
-    void OnDestroy()
-    {
-        nav.enabled = false;
-        StopPausible();
-    }
+        void OnDestroy()
+        {
+            nav.enabled = false;
+            StopPausible();
+        }
 
-    public override void OnPause()
-    {
-        if (nav.hasPath)
-            nav.isStopped = true;
-    }
+        public override void OnPause()
+        {
+            if (nav.hasPath)
+                nav.isStopped = true;
+        }
 
-    public override void OnUnPause()
-    {
-        if (nav.hasPath)
-            nav.isStopped = false;
-    }
+        public override void OnUnPause()
+        {
+            if (nav.hasPath)
+                nav.isStopped = false;
+        }
 
-    private void LookForPlayer()
-    {
-        TestSense(player.position, currentVision);
-    }
+        private void LookForPlayer()
+        {
+            TestSense(player.position, currentVision);
+        }
 
-    private void HearPoint(Vector3 position)
-    {
-        TestSense(position, hearingRange);
-    }
+        private void HearPoint(Vector3 position)
+        {
+            TestSense(position, hearingRange);
+        }
 
-    private void TestSense(Vector3 position, float senseRange)
-    {
-        if (Vector3.Distance(this.transform.position, position) <= senseRange)
+        private void TestSense(Vector3 position, float senseRange)
         {
-            GoToPosition(position);
+            if (Vector3.Distance(this.transform.position, position) <= senseRange)
+            {
+                GoToPosition(position);
+            }
         }
-    }
 
-    public void GoToPlayer()
-    {
-        GoToPosition(player.position);
-    }
+        public void GoToPlayer()
+        {
+            GoToPosition(player.position);
+        }
 
-    private void GoToPosition(Vector3 position)
-    {
-        timer = -1f;
-        if (!enemyHealth.IsDead())
+        private void GoToPosition(Vector3 position)
         {
-            SetDestination(position);
+            timer = -1f;
+            if (!enemyHealth.IsDead())
+            {
+                SetDestination(position);
+            }
         }
-    }
 
-    private void SetDestination(Vector3 position)
-    {
-        if (nav.isOnNavMesh)
+        private void SetDestination(Vector3 position)
         {
-            nav.SetDestination(position);
+            if (nav.isOnNavMesh)
+            {
+                nav.SetDestination(position);
+            }
         }
-    }
 
-    private void WanderOrIdle()
-    {
-        if (!nav.hasPath)
+        private void WanderOrIdle()
         {
-            if (timer <= 0f)
+            if (!nav.hasPath)
             {
-                SetDestination(GetRandomPoint(wanderDistance, 5));
-                if (nav.pathStatus == NavMeshPathStatus.PathInvalid)
+                if (timer <= 0f)
                 {
-                    ClearPath();
+                    SetDestination(GetRandomPoint(wanderDistance, 5));
+                    if (nav.pathStatus == NavMeshPathStatus.PathInvalid)
+                    {
+                        ClearPath();
+                    }
+                    timer = Random.Range(idleTimeRange.x, idleTimeRange.y);
+                }
+                else
+                {
+                    timer -= Time.deltaTime;
                 }
-                timer = Random.Range(idleTimeRange.x, idleTimeRange.y);
-            }
-            else
-            {
-                timer -= Time.deltaTime;
             }
         }
-    }
 
-    private void IsPsychic()
-    {
-        GoToPlayer();
-    }
+        private void IsPsychic()
+        {
+            GoToPlayer();
+        }
 
-    private Vector3 GetRandomPoint(float distance, int layermask)
-    {
-        Vector3 randomPoint = UnityEngine.Random.insideUnitSphere * distance + this.transform.position; ;
+        private Vector3 GetRandomPoint(float distance, int layermask)
+        {
+            Vector3 randomPoint = UnityEngine.Random.insideUnitSphere * distance + this.transform.position; ;
 
-        NavMeshHit navHit;
-        NavMesh.SamplePosition(randomPoint, out navHit, distance, layermask);
+            NavMeshHit navHit;
+            NavMesh.SamplePosition(randomPoint, out navHit, distance, layermask);
 
-        return navHit.position;
-    }
+            return navHit.position;
+        }
 
-    public void ScaleVision(float scale)
-    {
-        currentVision = visionRange * scale;
-    }
+        public void ScaleVision(float scale)
+        {
+            currentVision = visionRange * scale;
+        }
 
-    private int GetCurrentNavArea()
-    {
-        NavMeshHit navHit;
-        nav.SamplePathPosition(-1, 0.0f, out navHit);
+        private int GetCurrentNavArea()
+        {
+            NavMeshHit navHit;
+            nav.SamplePathPosition(-1, 0.0f, out navHit);
 
-        return navHit.mask;
-    }
+            return navHit.mask;
+        }
 
-    //void OnDrawGizmos()
-    //{
-    //    Vector3 position = this.transform.position;
-    //    Gizmos.color = Color.red;
-    //    Gizmos.DrawWireSphere(position, currentVision);
-    //    Gizmos.color = Color.yellow;
-    //    Gizmos.DrawWireSphere(position, hearingRange);
-    //}
+        //void OnDrawGizmos()
+        //{
+        //    Vector3 position = this.transform.position;
+        //    Gizmos.color = Color.red;
+        //    Gizmos.DrawWireSphere(position, currentVision);
+        //    Gizmos.color = Color.yellow;
+        //    Gizmos.DrawWireSphere(position, hearingRange);
+        //}
+    }
 }
\ No newline at end of file
diff --git a/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoAttack.cs b/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoAttack.cs
index 2f26a94..c33b8ca 100644
--- a/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoAttack.cs	
+++ b/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoAttack.cs	
@@ -5,8 +5,8 @@ public class KepalaKerocoAttack : PausibleObject
 {
     public float timeBetweenAttacks = 0.5f;
     public int attackDamage = 10;
-    public GameObject kerocoPrefab; // Prefab untuk Keroco yang akan dikeluarkan oleh Kepala Keroco
-    public Transform spawnPoint; // Titik spawn untuk Keroco
+    public GameObject kerocoPrefab;
+    public Transform spawnPoint;
 
     private Animator anim;
     private GameObject player;
@@ -97,7 +97,7 @@ public class KepalaKerocoAttack : PausibleObject
     }
 
     void SpawnKeroco()
-    {
+    {   
         if (kerocoPrefab != null && spawnPoint != null)
         {
             Instantiate(kerocoPrefab, spawnPoint.position, spawnPoint.rotation);
diff --git a/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoMovement.cs b/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoMovement.cs
index 55870a0..f0ad1e6 100644
--- a/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoMovement.cs	
+++ b/Assets/Scripts/Enemy/Kepala Keroco/KepalaKerocoMovement.cs	
@@ -4,177 +4,180 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.AI;
 
-public class KepalaKeroco : PausibleObject
+namespace Nightmare
 {
-
-    public float visionRange = 10f;
-    public float hearingRange = 20f;
-    public float wanderDistance = 10f;
-    public Vector2 idleTimeRange;
-    [Range(0f, 1f)]
-    public float psychicLevels = 0.2f;
-
-    float currentVision;
-    Transform player;
-    PlayerHealth playerHealth;
-    EnemyHealth enemyHealth;
-    NavMeshAgent nav;
-    public float timer = 0f;
-
-    void Awake()
+    public class KepalaKeroco : PausibleObject
     {
-        player = GameObject.FindGameObjectWithTag("Player").transform;
-        playerHealth = player.GetComponent<PlayerHealth>();
-        enemyHealth = GetComponent<EnemyHealth>();
-        nav = GetComponent<NavMeshAgent>();
 
-        StartPausible();
-    }
+        public float visionRange = 10f;
+        public float hearingRange = 20f;
+        public float wanderDistance = 10f;
+        public Vector2 idleTimeRange;
+        [Range(0f, 1f)]
+        public float psychicLevels = 0.2f;
 
-    void OnEnable()
-    {
-        nav.enabled = true;
-        ClearPath();
-        ScaleVision(1f);
-        IsPsychic();
-        timer = 0f;
-    }
+        float currentVision;
+        Transform player;
+        PlayerHealth playerHealth;
+        EnemyHealth enemyHealth;
+        NavMeshAgent nav;
+        public float timer = 0f;
 
-    void ClearPath()
-    {
-        if (nav.hasPath)
-            nav.ResetPath();
-    }
+        void Awake()
+        {
+            player = GameObject.FindGameObjectWithTag("Player").transform;
+            playerHealth = player.GetComponent<PlayerHealth>();
+            enemyHealth = GetComponent<EnemyHealth>();
+            nav = GetComponent<NavMeshAgent>();
 
-    void Update()
-    {
-        if (!isPaused)
+            StartPausible();
+        }
+
+        void OnEnable()
         {
-            // If both the enemy and the player have health left...
-            if (enemyHealth.CurrentHealth() > 0 && playerHealth.currentHealth > 0)
-            {
-                LookForPlayer();
-                WanderOrIdle();
-            }
-            else
+            nav.enabled = true;
+            ClearPath();
+            ScaleVision(1f);
+            IsPsychic();
+            timer = 0f;
+        }
+
+        void ClearPath()
+        {
+            if (nav.hasPath)
+                nav.ResetPath();
+        }
+
+        void Update()
+        {
+            if (!isPaused)
             {
-                nav.enabled = false;
+                // If both the enemy and the player have health left...
+                if (enemyHealth.CurrentHealth() > 0 && playerHealth.currentHealth > 0)
+                {
+                    LookForPlayer();
+                    WanderOrIdle();
+                }
+                else
+                {
+                    nav.enabled = false;
+                }
             }
         }
-    }
 
-    void OnDestroy()
-    {
-        nav.enabled = false;
-        StopPausible();
-    }
+        void OnDestroy()
+        {
+            nav.enabled = false;
+            StopPausible();
+        }
 
-    public override void OnPause()
-    {
-        if (nav.hasPath)
-            nav.isStopped = true;
-    }
+        public override void OnPause()
+        {
+            if (nav.hasPath)
+                nav.isStopped = true;
+        }
 
-    public override void OnUnPause()
-    {
-        if (nav.hasPath)
-            nav.isStopped = false;
-    }
+        public override void OnUnPause()
+        {
+            if (nav.hasPath)
+                nav.isStopped = false;
+        }
 
-    private void LookForPlayer()
-    {
-        TestSense(player.position, currentVision);
-    }
+        private void LookForPlayer()
+        {
+            TestSense(player.position, currentVision);
+        }
 
-    private void HearPoint(Vector3 position)
-    {
-        TestSense(position, hearingRange);
-    }
+        private void HearPoint(Vector3 position)
+        {
+            TestSense(position, hearingRange);
+        }
 
-    private void TestSense(Vector3 position, float senseRange)
-    {
-        if (Vector3.Distance(this.transform.position, position) <= senseRange)
+        private void TestSense(Vector3 position, float senseRange)
         {
-            GoToPosition(position);
+            if (Vector3.Distance(this.transform.position, position) <= senseRange)
+            {
+                GoToPosition(position);
+            }
         }
-    }
 
-    public void GoToPlayer()
-    {
-        GoToPosition(player.position);
-    }
+        public void GoToPlayer()
+        {
+            GoToPosition(player.position);
+        }
 
-    private void GoToPosition(Vector3 position)
-    {
-        timer = -1f;
-        if (!enemyHealth.IsDead())
+        private void GoToPosition(Vector3 position)
         {
-            SetDestination(position);
+            timer = -1f;
+            if (!enemyHealth.IsDead())
+            {
+                SetDestination(position);
+            }
         }
-    }
 
-    private void SetDestination(Vector3 position)
-    {
-        if (nav.isOnNavMesh)
+        private void SetDestination(Vector3 position)
         {
-            nav.SetDestination(position);
+            if (nav.isOnNavMesh)
+            {
+                nav.SetDestination(position);
+            }
         }
-    }
 
-    private void WanderOrIdle()
-    {
-        if (!nav.hasPath)
+        private void WanderOrIdle()
         {
-            if (timer <= 0f)
+            if (!nav.hasPath)
             {
-                SetDestination(GetRandomPoint(wanderDistance, 5));
-                if (nav.pathStatus == NavMeshPathStatus.PathInvalid)
+                if (timer <= 0f)
                 {
-                    ClearPath();
+                    SetDestination(GetRandomPoint(wanderDistance, 5));
+                    if (nav.pathStatus == NavMeshPathStatus.PathInvalid)
+                    {
+                        ClearPath();
+                    }
+                    timer = Random.Range(idleTimeRange.x, idleTimeRange.y);
+                }
+                else
+                {
+                    timer -= Time.deltaTime;
                 }
-                timer = Random.Range(idleTimeRange.x, idleTimeRange.y);
-            }
-            else
-            {
-                timer -= Time.deltaTime;
             }
         }
-    }
 
-    private void IsPsychic()
-    {
-        GoToPlayer();
-    }
+        private void IsPsychic()
+        {
+            GoToPlayer();
+        }
 
-    private Vector3 GetRandomPoint(float distance, int layermask)
-    {
-        Vector3 randomPoint = UnityEngine.Random.insideUnitSphere * distance + this.transform.position; ;
+        private Vector3 GetRandomPoint(float distance, int layermask)
+        {
+            Vector3 randomPoint = UnityEngine.Random.insideUnitSphere * distance + this.transform.position; ;
 
-        NavMeshHit navHit;
-        NavMesh.SamplePosition(randomPoint, out navHit, distance, layermask);
+            NavMeshHit navHit;
+            NavMesh.SamplePosition(randomPoint, out navHit, distance, layermask);
 
-        return navHit.position;
-    }
+            return navHit.position;
+        }
 
-    public void ScaleVision(float scale)
-    {
-        currentVision = visionRange * scale;
-    }
+        public void ScaleVision(float scale)
+        {
+            currentVision = visionRange * scale;
+        }
 
-    private int GetCurrentNavArea()
-    {
-        NavMeshHit navHit;
-        nav.SamplePathPosition(-1, 0.0f, out navHit);
+        private int GetCurrentNavArea()
+        {
+            NavMeshHit navHit;
+            nav.SamplePathPosition(-1, 0.0f, out navHit);
 
-        return navHit.mask;
-    }
+            return navHit.mask;
+        }
 
-    //void OnDrawGizmos()
-    //{
-    //    Vector3 position = this.transform.position;
-    //    Gizmos.color = Color.red;
-    //    Gizmos.DrawWireSphere(position, currentVision);
-    //    Gizmos.color = Color.yellow;
-    //    Gizmos.DrawWireSphere(position, hearingRange);
-    //}
-}
+        //void OnDrawGizmos()
+        //{
+        //    Vector3 position = this.transform.position;
+        //    Gizmos.color = Color.red;
+        //    Gizmos.DrawWireSphere(position, currentVision);
+        //    Gizmos.color = Color.yellow;
+        //    Gizmos.DrawWireSphere(position, hearingRange);
+        //}
+    }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Enemy/Raja/RajaAttack.cs b/Assets/Scripts/Enemy/Raja/RajaAttack.cs
index 51cb6e4..2655d85 100644
--- a/Assets/Scripts/Enemy/Raja/RajaAttack.cs
+++ b/Assets/Scripts/Enemy/Raja/RajaAttack.cs
@@ -12,11 +12,11 @@ public class RajaAttack : PausibleObject
     public float playerDamageRange = 10f;
     public float playerSlowdownFactor = 0.5f;
     public int playerDamagePerSecond = 5;
-    public float kerocoSpawnTimer;
+    private float kerocoSpawnTimer;
     private int petIncreaserCount = 0;
 
-    public GameObject kerocoPrefab; 
-    public Transform[] spawnPoints; 
+    public GameObject kerocoPrefab;
+    public Transform spawnPoint;
 
     Animator anim;
     GameObject player;
@@ -112,8 +112,16 @@ public class RajaAttack : PausibleObject
 
     void SlowdownPlayerMovement()
     {
-        // Perlambat gerakan pemain dengan faktor tertentu
-        player.GetComponent<NavMeshAgent>().speed *= playerSlowdownFactor;
+        PlayerMovement playerMovement = player.GetComponent<PlayerMovement>();
+
+        if (playerMovement != null)
+        {
+            playerMovement.speed *= playerSlowdownFactor;
+        }
+        else
+        {
+            Debug.LogError("PlayerMovement component not found!");
+        }
     }
 
     void InflictPlayerDamage()
@@ -124,10 +132,8 @@ public class RajaAttack : PausibleObject
 
     void SpawnKeroco()
     {
-        if (kerocoPrefab != null && spawnPoints != null && spawnPoints.Length > 0)
+        if (kerocoPrefab != null && spawnPoint != null)
         {
-            // Pilih secara acak salah satu titik spawn
-            Transform spawnPoint = spawnPoints[Random.Range(0, spawnPoints.Length)];
             Instantiate(kerocoPrefab, spawnPoint.position, spawnPoint.rotation);
         }
         else
diff --git a/Assets/Scripts/Enemy/Raja/RajaMovement.cs b/Assets/Scripts/Enemy/Raja/RajaMovement.cs
index 2954d3a..6669e14 100644
--- a/Assets/Scripts/Enemy/Raja/RajaMovement.cs
+++ b/Assets/Scripts/Enemy/Raja/RajaMovement.cs
@@ -4,177 +4,180 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.AI;
 
-public class RajaMovement : PausibleObject
+namespace Nightmare
 {
-
-    public float visionRange = 10f;
-    public float hearingRange = 20f;
-    public float wanderDistance = 10f;
-    public Vector2 idleTimeRange;
-    [Range(0f, 1f)]
-    public float psychicLevels = 0.2f;
-
-    float currentVision;
-    Transform player;
-    PlayerHealth playerHealth;
-    EnemyHealth enemyHealth;
-    NavMeshAgent nav;
-    public float timer = 0f;
-
-    void Awake()
+    public class RajaMovement : PausibleObject
     {
-        player = GameObject.FindGameObjectWithTag("Player").transform;
-        playerHealth = player.GetComponent<PlayerHealth>();
-        enemyHealth = GetComponent<EnemyHealth>();
-        nav = GetComponent<NavMeshAgent>();
 
-        StartPausible();
-    }
+        public float visionRange = 10f;
+        public float hearingRange = 20f;
+        public float wanderDistance = 10f;
+        public Vector2 idleTimeRange;
+        [Range(0f, 1f)]
+        public float psychicLevels = 0.2f;
 
-    void OnEnable()
-    {
-        nav.enabled = true;
-        ClearPath();
-        ScaleVision(1f);
-        IsPsychic();
-        timer = 0f;
-    }
+        float currentVision;
+        Transform player;
+        PlayerHealth playerHealth;
+        EnemyHealth enemyHealth;
+        NavMeshAgent nav;
+        public float timer = 0f;
 
-    void ClearPath()
-    {
-        if (nav.hasPath)
-            nav.ResetPath();
-    }
+        void Awake()
+        {
+            player = GameObject.FindGameObjectWithTag("Player").transform;
+            playerHealth = player.GetComponent<PlayerHealth>();
+            enemyHealth = GetComponent<EnemyHealth>();
+            nav = GetComponent<NavMeshAgent>();
 
-    void Update()
-    {
-        if (!isPaused)
+            StartPausible();
+        }
+
+        void OnEnable()
         {
-            // If both the enemy and the player have health left...
-            if (enemyHealth.CurrentHealth() > 0 && playerHealth.currentHealth > 0)
-            {
-                LookForPlayer();
-                WanderOrIdle();
-            }
-            else
+            nav.enabled = true;
+            ClearPath();
+            ScaleVision(1f);
+            IsPsychic();
+            timer = 0f;
+        }
+
+        void ClearPath()
+        {
+            if (nav.hasPath)
+                nav.ResetPath();
+        }
+
+        void Update()
+        {
+            if (!isPaused)
             {
-                nav.enabled = false;
+                // If both the enemy and the player have health left...
+                if (enemyHealth.CurrentHealth() > 0 && playerHealth.currentHealth > 0)
+                {
+                    LookForPlayer();
+                    WanderOrIdle();
+                }
+                else
+                {
+                    nav.enabled = false;
+                }
             }
         }
-    }
 
-    void OnDestroy()
-    {
-        nav.enabled = false;
-        StopPausible();
-    }
+        void OnDestroy()
+        {
+            nav.enabled = false;
+            StopPausible();
+        }
 
-    public override void OnPause()
-    {
-        if (nav.hasPath)
-            nav.isStopped = true;
-    }
+        public override void OnPause()
+        {
+            if (nav.hasPath)
+                nav.isStopped = true;
+        }
 
-    public override void OnUnPause()
-    {
-        if (nav.hasPath)
-            nav.isStopped = false;
-    }
+        public override void OnUnPause()
+        {
+            if (nav.hasPath)
+                nav.isStopped = false;
+        }
 
-    private void LookForPlayer()
-    {
-        TestSense(player.position, currentVision);
-    }
+        private void LookForPlayer()
+        {
+            TestSense(player.position, currentVision);
+        }
 
-    private void HearPoint(Vector3 position)
-    {
-        TestSense(position, hearingRange);
-    }
+        private void HearPoint(Vector3 position)
+        {
+            TestSense(position, hearingRange);
+        }
 
-    private void TestSense(Vector3 position, float senseRange)
-    {
-        if (Vector3.Distance(this.transform.position, position) <= senseRange)
+        private void TestSense(Vector3 position, float senseRange)
         {
-            GoToPosition(position);
+            if (Vector3.Distance(this.transform.position, position) <= senseRange)
+            {
+                GoToPosition(position);
+            }
         }
-    }
 
-    public void GoToPlayer()
-    {
-        GoToPosition(player.position);
-    }
+        public void GoToPlayer()
+        {
+            GoToPosition(player.position);
+        }
 
-    private void GoToPosition(Vector3 position)
-    {
-        timer = -1f;
-        if (!enemyHealth.IsDead())
+        private void GoToPosition(Vector3 position)
         {
-            SetDestination(position);
+            timer = -1f;
+            if (!enemyHealth.IsDead())
+            {
+                SetDestination(position);
+            }
         }
-    }
 
-    private void SetDestination(Vector3 position)
-    {
-        if (nav.isOnNavMesh)
+        private void SetDestination(Vector3 position)
         {
-            nav.SetDestination(position);
+            if (nav.isOnNavMesh)
+            {
+                nav.SetDestination(position);
+            }
         }
-    }
 
-    private void WanderOrIdle()
-    {
-        if (!nav.hasPath)
+        private void WanderOrIdle()
         {
-            if (timer <= 0f)
+            if (!nav.hasPath)
             {
-                SetDestination(GetRandomPoint(wanderDistance, 5));
-                if (nav.pathStatus == NavMeshPathStatus.PathInvalid)
+                if (timer <= 0f)
                 {
-                    ClearPath();
+                    SetDestination(GetRandomPoint(wanderDistance, 5));
+                    if (nav.pathStatus == NavMeshPathStatus.PathInvalid)
+                    {
+                        ClearPath();
+                    }
+                    timer = Random.Range(idleTimeRange.x, idleTimeRange.y);
+                }
+                else
+                {
+                    timer -= Time.deltaTime;
                 }
-                timer = Random.Range(idleTimeRange.x, idleTimeRange.y);
-            }
-            else
-            {
-                timer -= Time.deltaTime;
             }
         }
-    }
 
-    private void IsPsychic()
-    {
-        GoToPlayer();
-    }
+        private void IsPsychic()
+        {
+            GoToPlayer();
+        }
 
-    private Vector3 GetRandomPoint(float distance, int layermask)
-    {
-        Vector3 randomPoint = UnityEngine.Random.insideUnitSphere * distance + this.transform.position; ;
+        private Vector3 GetRandomPoint(float distance, int layermask)
+        {
+            Vector3 randomPoint = UnityEngine.Random.insideUnitSphere * distance + this.transform.position; ;
 
-        NavMeshHit navHit;
-        NavMesh.SamplePosition(randomPoint, out navHit, distance, layermask);
+            NavMeshHit navHit;
+            NavMesh.SamplePosition(randomPoint, out navHit, distance, layermask);
 
-        return navHit.position;
-    }
+            return navHit.position;
+        }
 
-    public void ScaleVision(float scale)
-    {
-        currentVision = visionRange * scale;
-    }
+        public void ScaleVision(float scale)
+        {
+            currentVision = visionRange * scale;
+        }
 
-    private int GetCurrentNavArea()
-    {
-        NavMeshHit navHit;
-        nav.SamplePathPosition(-1, 0.0f, out navHit);
+        private int GetCurrentNavArea()
+        {
+            NavMeshHit navHit;
+            nav.SamplePathPosition(-1, 0.0f, out navHit);
 
-        return navHit.mask;
-    }
+            return navHit.mask;
+        }
 
-    //void OnDrawGizmos()
-    //{
-    //    Vector3 position = this.transform.position;
-    //    Gizmos.color = Color.red;
-    //    Gizmos.DrawWireSphere(position, currentVision);
-    //    Gizmos.color = Color.yellow;
-    //    Gizmos.DrawWireSphere(position, hearingRange);
-    //}
-}
+        //void OnDrawGizmos()
+        //{
+        //    Vector3 position = this.transform.position;
+        //    Gizmos.color = Color.red;
+        //    Gizmos.DrawWireSphere(position, currentVision);
+        //    Gizmos.color = Color.yellow;
+        //    Gizmos.DrawWireSphere(position, hearingRange);
+        //}
+    }
+}
\ No newline at end of file
-- 
GitLab