Merge pull request 'feature/movement_constraint' (#12) from feature/movement_constraint into develop
Reviewed-on: #12
This commit is contained in:
commit
ba5ad6513a
@ -19,3 +19,4 @@ MonoBehaviour:
|
||||
- {fileID: 7665229218737596710, guid: 71b177c2a18314c588da30429451666a, type: 3}
|
||||
- {fileID: 622422277636247943, guid: d95124918e5a4a246abb0d378b14d3fa, type: 3}
|
||||
- {fileID: 5136368050551183548, guid: 0aa6654feb91ef040b8b99d4f64688fc, type: 3}
|
||||
- {fileID: 8500549904376788358, guid: d81cf4649bf54485a8b0da7a235f3817, type: 3}
|
||||
|
@ -0,0 +1,7 @@
|
||||
namespace DDD
|
||||
{
|
||||
public interface IRestaurantMovementConstraint
|
||||
{
|
||||
public bool IsBlockingMovement();
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59144c6942834360adc33f456812201c
|
||||
timeCreated: 1752733543
|
@ -38,5 +38,11 @@ private void OnDash(float 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
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3af7fa0aab2d45b19f78c34b028732b3
|
||||
timeCreated: 1752733503
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user