コード例 #1
0
        protected void Shift(IScrollController <TData> controller, Vector2 delta)
        {
            ////! temporal - item height limit speed
            //delta = delta.magnitude > ScrollerExtensions.SCROLL_SPEED_LIMIT_F ? delta.normalized * ScrollerExtensions.SCROLL_SPEED_LIMIT_F : delta;

            var direction = new Straight {
                Direction = controller.GrowDirection
            };
            VectorGeneric2 intersection;

            if (!controller.RectTransform.GetIntersectionInLocalSpace(direction, out intersection))
            {
                return;
            }

            if (Vector2.Dot(delta, controller.GrowDirection) > 0)
            {
                var first = controller.FirstOrDefault();
                if (first != null && !first.RectTransform.IsInsideParentSpace(intersection.Origin) && controller.RectTransform.IsOverlapsChild(controller.First().RectTransform))
                {
                    controller.ShiftWindowUp();
                }
            }

            if (Vector2.Dot(delta, controller.GrowDirection) < 0)
            {
                var last = controller.LastOrDefault();
                if (last != null && !last.RectTransform.IsInsideParentSpace(intersection.Target) && controller.RectTransform.IsOverlapsChild(controller.Last().RectTransform))
                {
                    controller.ShiftWindowDown();
                }
            }
        }
コード例 #2
0
        public FreeCarrier(IScrollController <TData> controller)
        {
            var delta = controller.PointerEventData.delta.ProjectTo(controller.GrowDirection);

            //! temporal - item height limit speed
            _delta = delta.magnitude > ScrollerExtensions.SCROLL_SPEED_LIMIT_F ? delta.normalized * ScrollerExtensions.SCROLL_SPEED_LIMIT_F : delta;
            var cutting = new Straight {
                Direction = _delta.normalized,
            };

            _isAtTarget = !controller.RectTransform.GetIntersectionInLocalSpace(cutting, out _target);
            var item = controller.FirstOrDefault(_ => _.RectTransform.IsInsideParentSpace(_target.Origin)) ?? (Vector2.Dot(_delta, controller.GrowDirection) > 0 ? controller.First() : controller.Last());

            VectorGeneric2 @internal;

            item.RectTransform.GetIntersectionInParentSpace(cutting, out @internal);

            _necessaryDist = (_target.Origin - @internal.Origin).magnitude;
            _acceleration  = -_delta.normalized * (_necessaryDist / (STOP_TIME_F * STOP_TIME_F) + _delta.magnitude / STOP_TIME_F);

            //ScrollerExtensions.MultiLine(controller.RectTransform.GetSidesInLocalSpace(), Color.yellow * .5f, true, 1f);
            //ScrollerExtensions.Cross(_target.Origin, Color.yellow, 30f, 1f);
            //ScrollerExtensions.Cross(@internal.Origin, Color.yellow, 30f, 1f);

            //Debug.Log(string.Format("speed: {0}, acceleration: {1}, distance is: {2}", _delta, _acceleration, _necessuaryDist));
        }
        public OneItemHopCoDirectionCarrier(IScrollController <TData> controller)
        {
            var first = controller.FirstOrDefault();

            if (first == null)
            {
                return;
            }
            first.RectTransform.GetIntersectionInParentSpace(new Straight {
                Direction = -controller.GrowDirection
            }, out _path);
        }