1
This commit is contained in:
@@ -212,6 +212,55 @@ namespace BITFALL.Entities.Player.Movement.States
|
||||
characterController.CurrentCameraPosition.shouldBe = characterController.FpvLocalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class Dodge : PlayerCharacterState,IPlayerDodgeState
|
||||
{
|
||||
[SerializeField] private int costStamina = 10;
|
||||
[SerializeField] private AnimationCurve curve;
|
||||
[SerializeField] private float duration = 0.32f;
|
||||
private int direction;
|
||||
private float process;
|
||||
|
||||
[Inject] private IHealth _health;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_health.OnDamageFactory += OnDamageFactory;
|
||||
}
|
||||
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
direction = characterController.MovementInput.x > 0 ? 1 : -1;
|
||||
process = 0;
|
||||
characterController.Stamina-= costStamina;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||||
{
|
||||
currentVelocity = actor.transform.right * (direction * curve.Evaluate(process+=deltaTime / duration));
|
||||
}
|
||||
|
||||
public override void AfterUpdateMovement(float deltaTime)
|
||||
{
|
||||
if(process>=1)
|
||||
Exit();
|
||||
}
|
||||
|
||||
private int OnDamageFactory(DamageMessage msg, int currentDamage)
|
||||
{
|
||||
if (characterController.CurrentState is not IPlayerDodgeState || msg.Initiator is not Entity initiator)
|
||||
return currentDamage;
|
||||
var _direction = characterController.Position - initiator.transform.position;
|
||||
var verticalAngle = Vector3.Angle(initiator.transform.forward, _direction) - 90.0f;
|
||||
Debug.Log(verticalAngle);
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Fixed:PlayerCharacterState,IPlayerFixedState
|
||||
{
|
||||
|
Reference in New Issue
Block a user