This commit is contained in:
CortexCore
2023-10-24 23:37:59 +08:00
parent 325f63d6bc
commit 3e39e627bc
388 changed files with 29043 additions and 889 deletions

View File

@@ -35,6 +35,19 @@ namespace BITFALL.Entities.Player.Movement
[SerializeField] private Transform fpvPoint;
public Vector3 Position
{
get => actor.Position;
set=>actor.Position = value;
}
public Quaternion Rotation
{
get => actor.Rotation;
set => actor.Rotation = value;
}
public Vector3 Forward => actor.Forward;
public Vector3 ViewCenter { get; set; }
public Quaternion ViewRotation { get; set; }
public Vector3 LocomotionBasedVelocity { get;private set; }
@@ -230,6 +243,11 @@ namespace BITFALL.Entities.Player.Movement
return;
}
if (MovementInput.x is not 0 && MovementInput.z is 0)
{
TransitionState<Dodge>();
return;
}
if (climbClosePoint.TryGetClosePoint(out var closePoint))
{
ExpectClimb.shouldBe = closePoint;
@@ -345,15 +363,15 @@ namespace BITFALL.Entities.Player.Movement
case < -16:
entity.Invoke<DamageMessage>(new DamageMessage()
{
damage = value < -30 ? int.MaxValue : (int)math.abs(value) * 2 ,
damageType = new GravityDamage(),
location = new Location()
Damage = value < -30 ? int.MaxValue : (int)math.abs(value) * 2 ,
DamageType = new GravityDamage(),
Location = new Location()
{
position = actor.Position,
rotation = actor.Rotation
},
initiator = entity,
target = entity,
Initiator = entity,
Target = entity,
});
break;
}
@@ -393,7 +411,8 @@ namespace BITFALL.Entities.Player.Movement
ViewRotation = rotation;
ViewCenter = additiveTransform.position + additiveTransform.forward;
//ViewCenter = additiveTransform.position + additiveTransform.forward;
ViewCenter = additiveTransform.position + Quaternion.Euler(LookInput) * Vector3.forward;
}
private float _stamina = 100;
public float Stamina

View File

@@ -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
{