Exemplo n.º 1
0
    public void SnapToIndex(int newCellIndex, bool isToNext = true)
    {
        int maxIndex = CalculateMaxIndex();

        if (wrapAround && maxIndex > 0)
        {
            actualIndex += newCellIndex - cellIndex;
            cellIndex    = newCellIndex;
            onLerpComplete.AddListener(WrapElementAround);
        }
        else
        {
            newCellIndex = Mathf.Clamp(newCellIndex, 0, maxIndex);
            actualIndex += newCellIndex - cellIndex;
            cellIndex    = newCellIndex;
        }

        onRelease.Invoke(cellIndex);
        StartLerping();

        if (controllerDelegate != null)
        {
            this.controllerDelegate.UpdatePieChart(cellIndex, true, isToNext);
        }
    }
Exemplo n.º 2
0
        private void _Apportion(ClientToServerOpCode code, byte[] args)
        {
            switch (code)
            {
            case ClientToServerOpCode.Ping:
                OnPingEvent?.Invoke();
                break;

            case ClientToServerOpCode.CallMethod:
            {
                var pkg = args.ToPackageData <PackageCallMethod>(_Serializer);

                OnCallMethodEvent?.Invoke(pkg.EntityId, pkg.MethodId, pkg.ReturnId, pkg.MethodParams);
            }

            break;

            case ClientToServerOpCode.Release:
            {
                var pkg = args.ToPackageData <PackageRelease>(_Serializer);

                OnReleaseEvent?.Invoke(pkg.EntityId);
            }

            break;

            default:
                throw new ArgumentOutOfRangeException(nameof(code), code, null);
            }
        }
Exemplo n.º 3
0
 public void OnPointerUp(PointerEventData eventData)
 {
     if (imageSwap != null)
     {
         image.sprite = imageOrig;
     }
     OnReleaseEvent?.Invoke();
     OnChangeEvent?.Invoke(false);
 }
Exemplo n.º 4
0
    public void SnapToIndex(int newCellIndex)
    {
        int maxIndex = CalculateMaxIndex();

        if (wrapAround && maxIndex > 0)
        {
            actualIndex += newCellIndex - cellIndex;
            cellIndex    = newCellIndex;
            onLerpComplete.AddListener(WrapElementAround);
        }
        else
        {
            newCellIndex = Mathf.Clamp(newCellIndex, 0, maxIndex);
            actualIndex += newCellIndex - cellIndex;
            cellIndex    = newCellIndex;
        }
        onRelease.Invoke(cellIndex);
        StartLerping();
    }
Exemplo n.º 5
0
        public void SnapToIndex(int newCellIndex)
        {
            int maxIndex = CalculateMaxIndex();

            if (wrapAround && maxIndex > 0)
            {
                actualIndex += newCellIndex - cellIndex;
                cellIndex    = newCellIndex;
                onLerpComplete.AddListener(WrapElementAround);
            }
            else
            {
                // when it's the same it means it tried to go out of bounds
                if (newCellIndex >= 0 && newCellIndex <= maxIndex)
                {
                    actualIndex += newCellIndex - cellIndex;
                    cellIndex    = newCellIndex;
                }
            }
            onRelease.Invoke(cellIndex);
            StartLerping();
        }
Exemplo n.º 6
0
    private void OnRelease(InputAction.CallbackContext callbackContext)
    {
        if (IsInputNotValidState())
        {
            return;
        }

        isPress = false;
        OnReleaseEvent?.Invoke();

#if DEBUGGING
        Debug.Log("Release");
#endif
    }
Exemplo n.º 7
0
        public void Update()
        {
            var touching = BaseInput.IsTouching();

            if (touching && !WasTouching)
            {
                StartCoroutine(StartTap());
            }

            if (!touching && Tapping)
            {
                Tapping = false;
                OnReleaseEvent.Invoke();
            }
            WasTouching = touching;
        }
Exemplo n.º 8
0
        public void Update()
        {
            var touching = BaseInput.IsTouching(true);

            if (touching)
            {
                var touch0Position = BaseInput.GetTouchPosition(0).y;
                var touch1Position = BaseInput.GetTouchPosition(1).y;
                var position       = (touch0Position + touch1Position) * 0.5f;

                if (!Panning)
                {
                    if (!WasTouching)
                    {
                        LastPosition = position;
                    }

                    var delta = Mathf.Abs(position - LastPosition);

                    if (!Rotating && delta >= Threshold)
                    {
                        LastPosition = position;
                        Panning      = true;
                    }
                }
                if (Panning)
                {
                    var delta = position - LastPosition;
                    OnDragEvent.Invoke(Vector3.up * (delta * Ratio));

                    LastPosition = position;
                }
            }

            if (!touching && Panning)
            {
                Panning = false;
                OnReleaseEvent.Invoke();
            }

            WasTouching = touching;
        }
Exemplo n.º 9
0
        public void Update()
        {
            var touching = BaseInput.IsTouching(true);

            if (touching)
            {
                var touch0Position = BaseInput.GetTouchPosition(0);
                var touch1Position = BaseInput.GetTouchPosition(1);
                var angle          = CalculateAngle(touch0Position, touch1Position);

                if (!Rotating)
                {
                    if (!WasTouching)
                    {
                        LastAngle = angle;
                    }

                    var delta = angle - LastAngle;
                    if (!Panning && Mathf.Abs(delta) >= Threshold)
                    {
                        LastAngle = angle;
                        Rotating  = true;
                    }
                }
                if (Rotating)
                {
                    var delta = angle - LastAngle;
                    OnRotationEvent.Invoke(delta);

                    LastAngle = angle;
                }
            }

            if (!touching && Rotating)
            {
                Rotating = false;
                OnReleaseEvent.Invoke();
            }

            WasTouching = touching;
        }
        /// <summary>
        /// release all selected object and put them back to their original structure
        /// </summary>
        public void Release()
        {
            Node[] selectedArray = SelectedNodes.ToArray();
            for (int i = 0; i < selectedArray.Length; i++)
            {
                /*if (selectedArray[i].OnReleaseEvent != null)
                 * {
                 *  SelectedNodes[i].OnReleaseEvent.Invoke();
                 * }*/
                if (OnReleaseEvent != null)
                {
                    OnReleaseEvent.Invoke(selectedArray[i]);
                }

                if (selectedArray [i].Childs.Count > 0)
                {
                    foreach (var child in selectedArray[i].Childs)
                    {
                        child.GameObject.transform.SetParent(selectedArray [i].GameObject.transform);
                    }
                }

                if (selectedArray [i].Parent == null)
                {
                    selectedArray [i].GameObject.transform.SetParent(this.transform);
                }
                else
                {
                    selectedArray [i].GameObject.transform.SetParent(selectedArray [i].Parent.GameObject.transform);
                }

                if (SnapParts)
                {
                    Snap(selectedArray [i]);
                }
            }
        }
Exemplo n.º 11
0
 public static void OnRelease(MouseClickEventArgs e)
 {
     OnReleaseEvent?.Invoke(e);
 }