IPausable added to BasicEnemies
This commit is contained in:
parent
db33696e0c
commit
90c0e3b431
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue