IPausable added to BasicEnemies

This commit is contained in:
Syntriax 2022-02-22 00:04:15 +03:00
parent db33696e0c
commit 90c0e3b431
1 changed files with 11 additions and 1 deletions

View File

@ -1,9 +1,10 @@
using Movement; using Movement;
using Pausable;
using UnityEngine; using UnityEngine;
namespace AI namespace AI
{ {
public class BasicPatrollingEnemyAI : MonoBehaviour public class BasicPatrollingEnemyAI : MonoBehaviour, IPausable
{ {
[SerializeField] protected bool isMovingRight = false; [SerializeField] protected bool isMovingRight = false;
@ -14,6 +15,12 @@ namespace AI
protected CollisionChecker leftGroundChecker = null; protected CollisionChecker leftGroundChecker = null;
protected CollisionChecker rightGroundChecker = 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 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 // 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() protected virtual void FixedUpdate()
{ {
if (IsPaused)
return;
if (ShouldChangeDirection) if (ShouldChangeDirection)
isMovingRight = !isMovingRight; isMovingRight = !isMovingRight;