HoloCop still in progress
This commit is contained in:
1 parent
430b250075
commit
d3b2e4c8d8
54 files changed
+173233
-112995
No files matched your search
@@ -113,7 +113,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
public void CompleteOrInterruptAction()
|
||||
{
|
||||
animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
|
||||
animator.Update(0f);
|
||||
_entityHitBoxes.DisableAllHitboxes();
|
||||
|
||||
// TODO С нормальными анимациями не нужен будет рут моушен
|
||||
animator.transform.localPosition = Vector3.zero;
|
||||
animator.transform.localRotation = Quaternion.identity;
|
||||
|
||||
Finished = true;
|
||||
}
|
||||
|
||||
@@ -128,7 +134,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
|
||||
_currentFrame++;
|
||||
|
||||
return _currentFrame >= _attackData.TotalFrames;
|
||||
if(_currentFrame >= _attackData.TotalFrames)
|
||||
{
|
||||
_currentFrame = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,39 +11,59 @@ namespace Code.OfficeGame.BattleMode.Actions.HoloCopy
|
||||
{
|
||||
public class HoloCop : MonoBehaviour
|
||||
{
|
||||
private static readonly int VelocityForward = Animator.StringToHash("VelocityForward");
|
||||
|
||||
private Func<HoloCop, float, bool> _action;
|
||||
|
||||
[SerializeField] private MovementController movementController;
|
||||
[SerializeField] private KinematicCharacterMotor motor;
|
||||
[SerializeField] private KinematicCharacterMotor originMotor;
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private Animator originAnimator;
|
||||
|
||||
public MovementController Controller => movementController;
|
||||
public Animator Animator => animator;
|
||||
|
||||
private Vector3 _initialPosition;
|
||||
private Quaternion _initialRotation;
|
||||
private Vector3 _initialMotorPosition;
|
||||
private Quaternion _initialMotorRotation;
|
||||
|
||||
private int _initialAnimationState;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
movementController = GetComponent<MovementController>();
|
||||
motor = GetComponent<KinematicCharacterMotor>();
|
||||
}
|
||||
|
||||
private float _initialNormalizedTime;
|
||||
|
||||
private void Snapshot()
|
||||
{
|
||||
_initialPosition = motor.transform.position;
|
||||
_initialRotation = motor.transform.rotation;
|
||||
_initialMotorPosition = originMotor.TransientPosition;
|
||||
_initialMotorRotation = originMotor.TransientRotation;
|
||||
|
||||
_initialAnimationState = animator.GetCurrentAnimatorStateInfo(0).shortNameHash;
|
||||
AnimatorStateInfo stateInfo = originAnimator.GetCurrentAnimatorStateInfo(0);
|
||||
_initialAnimationState = stateInfo.shortNameHash;
|
||||
_initialNormalizedTime = stateInfo.normalizedTime;
|
||||
|
||||
animator.applyRootMotion = false;
|
||||
animator.SetFloat(VelocityForward, originAnimator.GetFloat(VelocityForward));
|
||||
|
||||
animator.Play(_initialAnimationState, 0, _initialNormalizedTime);
|
||||
animator.Update(0f);
|
||||
|
||||
animator.applyRootMotion = true;
|
||||
}
|
||||
|
||||
private void ReturnToSnapshot()
|
||||
{
|
||||
motor.SetPositionAndRotation(_initialPosition, _initialRotation);
|
||||
bool prevRootMotion = animator.applyRootMotion;
|
||||
animator.applyRootMotion = false;
|
||||
|
||||
animator.Play(_initialAnimationState, 0);
|
||||
animator.Play(_initialAnimationState, 0, _initialNormalizedTime);
|
||||
animator.Update(0f);
|
||||
|
||||
animator.transform.localPosition = Vector3.zero;
|
||||
animator.transform.localRotation = Quaternion.identity;
|
||||
|
||||
originMotor.SetPositionAndRotation(_initialMotorPosition, _initialMotorRotation);
|
||||
|
||||
animator.applyRootMotion = prevRootMotion;
|
||||
|
||||
Physics.SyncTransforms();
|
||||
}
|
||||
|
||||
public async UniTask Simulate(Func<HoloCop, float, bool> action, CancellationToken ctx)
|
||||
@@ -70,7 +90,7 @@ namespace Code.OfficeGame.BattleMode.Actions.HoloCopy
|
||||
if (_action == null) return;
|
||||
|
||||
bool result = _action(this, BattleTimeline.TickDelta);
|
||||
|
||||
|
||||
animator.Update(BattleTimeline.TickDelta);
|
||||
|
||||
Physics.Simulate(BattleTimeline.TickDelta);
|
||||
|
||||
@@ -10,12 +10,15 @@ namespace Code.OfficeGame.Player
|
||||
|
||||
|
||||
private KinematicCharacterMotor _motor;
|
||||
[SerializeField] private Animator animator;
|
||||
public Animator Animator { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_motor = GetComponent<KinematicCharacterMotor>();
|
||||
Animator = GetComponentInChildren<Animator>();
|
||||
// :?:?:?:?:?:?:?:?:?:?:?:?:?:?
|
||||
if (!animator) Animator = GetComponentInChildren<Animator>();
|
||||
else Animator = animator;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
Reference in new issue
Block a user