diff --git a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs index 96ab67b..93b5f92 100644 --- a/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs +++ b/Assets/Scripts/AI/BasicPatrollingEnemyAI.cs @@ -1,9 +1,10 @@ using Movement; +using Pausable; using UnityEngine; namespace AI { - public class BasicPatrollingEnemyAI : MonoBehaviour + public class BasicPatrollingEnemyAI : MonoBehaviour, IPausable { [SerializeField] protected bool isMovingRight = false; @@ -14,6 +15,12 @@ namespace AI protected CollisionChecker leftGroundChecker = null; protected CollisionChecker rightGroundChecker = null; + #region IPausable + public bool IsPaused { get; protected set; } = false; + public virtual void Pause() => IsPaused = true; + public virtual void Resume() => IsPaused = false; + #endregion + // If moving Right, and either there's no more ground to move into or there is a wall at the Right side of the enemy OR // If moving Left, and either there's no more ground to move into or there is a wall at the Left side of the enemy @@ -33,6 +40,9 @@ namespace AI protected virtual void FixedUpdate() { + if (IsPaused) + return; + if (ShouldChangeDirection) isMovingRight = !isMovingRight;