From 90c0e3b4314587fb3ea7b24264eabc6242d782a1 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Tue, 22 Feb 2022 00:04:15 +0300 Subject: [PATCH] IPausable added to BasicEnemies --- Assets/Scripts/AI/BasicPatrollingEnemyAI.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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;