コード例 #1
0
ファイル: RotationAnimator.cs プロジェクト: mANDROID99/IaS
 public RotationAnimator(SplitSide splitSide, Quaternion from, Quaternion to, RotateableBranch rotateable)
 {
     SplitSide = splitSide;
     Rotateable = rotateable;
     From = from;
     To = to;
     Delta = 0;
 }
コード例 #2
0
        IEnumerator Rotate90Degrees(SplitSide splitRotation, IList<RotationAnimator> animators)
        {
            float startTime = Time.time;
            float deltaTime;
            do
            {
                deltaTime = Mathf.Clamp(Time.time - startTime, 0, 1);
                foreach (RotationAnimator animator in animators)
                {
                    Quaternion lerpRotation = Quaternion.Lerp(animator.From, animator.To, Mathf.SmoothStep(0, 1, deltaTime));
                    Transformation transformation = new RotateAroundPivotTransform(splitRotation.Pivot, lerpRotation);
                    Vector3 localPosition = transformation.Transform(new Vector3());

                    animator.UpdateTransform(lerpRotation, localPosition);
                }

                yield return null;
            } while (deltaTime < 1);

            _eventRegistry.Notify(new GameEvent(GameEvent.Type.RESUMED));
            _readyToRot = true;
        }
コード例 #3
0
ファイル: TreeRotater.cs プロジェクト: mANDROID99/IaS
        public IList<RotationAnimator> Rotate(SplitSide splitSide, Direction direction)
        {
            float directionMult = direction == Direction.Clockwise ? 1 : -1;
            Quaternion rotationDelta = Quaternion.Euler(splitSide.Axis * 90 * directionMult);

            GroupBranch group = splitSide.Group;

            List<RotationAnimator> animators = new List<RotationAnimator>();
            foreach (SplitBoundsBranch splitBoundsBranch in group.SplitBoundsBranches)
            {
                float distance;
                Split.ConstraintResult constraintResult = splitSide.Constrains(splitBoundsBranch.RotatedBounds, out distance);
                switch (constraintResult)
                {
                    case Split.ConstraintResult.Blocked:
                        return new RotationAnimator[0];
                    case Split.ConstraintResult.Included:
                        Transformation transformation;
                        RotationAnimator animator = CreateRotationAnimation(splitSide, splitBoundsBranch, rotationDelta, out transformation);
                        _eventRegistry.Notify(new BlockRotationEvent(group.Group, transformation, splitBoundsBranch.SplittedRegion));
                        animators.Add(animator);
                        break;
                }
            }

            foreach(GroupBranch attachedGroup in splitSide.AttachedRotateables)
            {
                Transformation transformation;
                RotationAnimator animator = CreateRotationAnimation(splitSide, attachedGroup, rotationDelta, out transformation);
                _eventRegistry.Notify(new GroupRotationEvent(group.Group, transformation));
                animators.Add(animator);
            }

            return animators;
        }
コード例 #4
0
ファイル: TreeRotater.cs プロジェクト: mANDROID99/IaS
        private RotationAnimator CreateRotationAnimation(SplitSide splitSide, RotateableBranch rotateable, Quaternion rotationDelta, out Transformation transformation)
        {
            BlockBounds rotatedBounds = rotateable.RotatedBounds;
            Quaternion startRot = rotatedBounds.Rotation;
            Quaternion endRot = startRot * rotationDelta;

            rotatedBounds.SetToRotationFrom(endRot, splitSide.Pivot, rotateable.OriginalBounds);
            transformation = new RotateAroundPivotTransform(splitSide.Pivot, endRot);
            return new RotationAnimator(splitSide, startRot, endRot, rotateable);
        }