feature/movement_constraint #12
@ -0,0 +1,7 @@
|
|||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public interface IRestaurantMovementConstraint
|
||||||
|
{
|
||||||
|
public bool IsBlockingMovement();
|
||||||
|
}
|
||||||
|
}
|
@ -38,5 +38,11 @@ private void OnDash(float dashTime)
|
|||||||
{
|
{
|
||||||
_spineController.PlayAnimationDuration(RestaurantPlayerAnimation.Dash, false, duration:dashTime);
|
_spineController.PlayAnimationDuration(RestaurantPlayerAnimation.Dash, false, duration:dashTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsPlayingAnimation()
|
||||||
|
{
|
||||||
|
// TODO : Implement this
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,25 @@ namespace DDD
|
|||||||
{
|
{
|
||||||
public class RestaurantCharacterMovement : MonoBehaviour
|
public class RestaurantCharacterMovement : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private RestaurantCharacterMovementConstraint _constraint;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_constraint = gameObject.AddComponent<RestaurantCharacterMovementConstraint>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool CanMove()
|
||||||
|
{
|
||||||
|
// Get all components implements IRestaurantMovementConstraint
|
||||||
|
var constraints = GetComponents<IRestaurantMovementConstraint>();
|
||||||
|
// TODO : Maybe need optimize GetComponents?
|
||||||
|
foreach (var movementConstraint in constraints)
|
||||||
|
{
|
||||||
|
if (movementConstraint.IsBlockingMovement())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DDD
|
||||||
|
{
|
||||||
|
public class RestaurantCharacterMovementConstraint : MonoBehaviour, IRestaurantMovementConstraint
|
||||||
|
{
|
||||||
|
public bool IsBlockingMovement()
|
||||||
|
{
|
||||||
|
if (GetComponent<RestaurantCharacterAnimation>().IsPlayingAnimation())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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()
|
private void Move()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user