diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/IRestaurantMovementConstraint.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/IRestaurantMovementConstraint.cs new file mode 100644 index 000000000..462d87b94 --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/IRestaurantMovementConstraint.cs @@ -0,0 +1,7 @@ +namespace DDD +{ + public interface IRestaurantMovementConstraint + { + public bool IsBlockingMovement(); + } +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterAnimation.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterAnimation.cs index b2dd01dc4..51ea4eeb4 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterAnimation.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterAnimation.cs @@ -38,5 +38,11 @@ private void OnDash(float dashTime) { _spineController.PlayAnimationDuration(RestaurantPlayerAnimation.Dash, false, duration:dashTime); } + + public bool IsPlayingAnimation() + { + // TODO : Implement this + return false; + } } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovement.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovement.cs index 52c2b8e1e..3493afb94 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovement.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovement.cs @@ -4,6 +4,25 @@ namespace DDD { public class RestaurantCharacterMovement : MonoBehaviour { - + private RestaurantCharacterMovementConstraint _constraint; + private void Awake() + { + _constraint = gameObject.AddComponent(); + } + + public virtual bool CanMove() + { + // Get all components implements IRestaurantMovementConstraint + var constraints = GetComponents(); + // TODO : Maybe need optimize GetComponents? + foreach (var movementConstraint in constraints) + { + if (movementConstraint.IsBlockingMovement()) + { + return false; + } + } + return true; + } } } \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovementConstraint.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovementConstraint.cs new file mode 100644 index 000000000..443d24ae1 --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantCharacterMovementConstraint.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +namespace DDD +{ + public class RestaurantCharacterMovementConstraint : MonoBehaviour, IRestaurantMovementConstraint + { + public bool IsBlockingMovement() + { + if (GetComponent().IsPlayingAnimation()) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs index c44b4e954..f8296bd76 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/RestaurantPlayerMovement.cs @@ -118,7 +118,10 @@ private void HandleMovement() } } - private bool CanMove() => _playerDataSo.IsMoveEnabled && !_isDashing; + public override bool CanMove() + { + return base.CanMove() && _playerDataSo.IsMoveEnabled && !_isDashing; + } private void Move() {