Пример #1
0
        private void DoRockAnimation(Entity entity)
        {
            var moveDirection = entity.knocked.FromDirection.ToV3();
            var transform     = entity.view.Value.transform;

            const float time              = 0.5f;
            var         camera            = _pool.GetCamera();
            var         rotationDirection = Vector3.Cross(moveDirection.normalized, Vector3.up);
            // TODO: This looks like shit
            var sequence = DOTween.Sequence()
                           .AppendInterval(entity.knocked.Wait)
                           .Append(transform.DORotate(-rotationDirection / 8 * 90, time / 4, RotateMode.WorldAxisAdd))
                           .Join(transform.DOMove(moveDirection / 8, time / 4).SetRelative())
                           .Join(camera.transform.DOShakeRotation(0.2f, 0.7f, 20, 3))
                           .Append(transform.DORotate(rotationDirection / 8 * 90, time / 4, RotateMode.WorldAxisAdd))
                           .Join(transform.DOMove(-moveDirection / 8, time / 4).SetRelative())
                           .Append(transform.DORotate(rotationDirection / 16 * 90, time / 4, RotateMode.WorldAxisAdd))
                           .Join(transform.DOMove(-moveDirection / 16, time / 4).SetRelative())
                           .Append(transform.DORotate(-rotationDirection / 16 * 90, time / 4, RotateMode.WorldAxisAdd))
                           .Join(transform.DOMove(moveDirection / 16, time / 4).SetRelative())
                           .OnUpdate(() => UpdateVerticalMove(transform));

            if (!entity.knocked.Immediate)
            {
                entity.AddActingSequence(MoveAnimationSystem.MoveTime);
                entity.AddActingSequence(time, sequence);
            }
        }
Пример #2
0
        private void PositionChanged(Entity entity)
        {
            var transform   = entity.view.Value.transform;
            var newPosition = entity.position.Value.ToV3() + entity.viewOffset.Value;

            var animationAction = "IsMoving";
            var time            = MoveTime;

            if (entity.isPushing)
            {
                animationAction = "IsPushing";
                time            = 0.7f;
            }
            else if (entity.isPulling)
            {
                animationAction = "IsPulling";
                time            = 0.9f;
            }

            var animator = entity.animator.Value;
            var sequence = DOTween.Sequence()
                           .Pause()
                           .OnStart(() => animator.SetBool(animationAction, true))
                           .AppendInterval(time)
                           .OnComplete(() =>
            {
                transform.position = newPosition;
                animator.SetBool(animationAction, false);
            });

            entity.AddActingSequence(time, sequence);
        }
Пример #3
0
        private void DoRollAnimation(Entity entity, PositionComponent oldPosition, PositionComponent newPosition)
        {
            var moveDirection = (newPosition.Value - oldPosition.Value).ToV3();
            var transform     = entity.view.Value.transform;

            const float time              = 0.5f;
            var         camera            = _pool.GetCamera();
            var         rotationDirection = Vector3.Cross(moveDirection.normalized, Vector3.up);
            var         sequence          = DOTween.Sequence()
                                            .AppendInterval(entity.knocked.Wait)
                                            .Append(transform.DORotate(-rotationDirection * 90, time, RotateMode.WorldAxisAdd))
                                            .Join(transform.DOMove(moveDirection, time)
                                                  .SetRelative(true))
                                            .Join(camera.transform.DOShakeRotation(0.3f, 1, 20, 3))
                                            .OnUpdate(() => UpdateVerticalMove(transform));

            if (!entity.knocked.Immediate)
            {
                entity.AddActingSequence(MoveAnimationSystem.MoveTime);
                entity.AddActingSequence(time, sequence);
            }
        }