Exemplo n.º 1
0
 /// <summary>
 /// Called from CardHoverInputzone
 /// </summary>
 public void BeginDrag()
 {
     if (!_mouseBusy && CanBeDragged)
     {
         IsDragged      = true;
         _mouseBusy     = true;
         AnimationState = CardAnimationState.Dragged;
         ShowAboveUi();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Called from CardHoverInputzone
 /// </summary>
 public void EndDrag()
 {
     if (CanBeDragged)
     {
         _mouseBusy     = false;
         IsDragged      = false;
         AnimationState = CardAnimationState.MovingToRoot;
         ShowInUi();
         InputManager.Instance.DraggedCardDrop(Input.mousePosition, _cardRoot);
     }
 }
Exemplo n.º 3
0
        private void Update()
        {
            // If any card got grabbed by mouse then every other card gets un-zoomed
            // (the _mouseBusy is static)
            if (_mouseBusy)
            {
                _zoom = false;
            }

            if (AnimationState == CardAnimationState.MovingToRoot)
            {
                targetPos   = _cardRoot.transform.position;
                targetRot   = _cardRoot.transform.rotation;
                targetScale = _cardRoot.transform.localScale;

                /*
                 * //Lerp LOCAL transform values to root
                 * transform.localPosition = Vector3.Lerp(transform.localPosition, targetPos, LerpSpeed * Time.deltaTime);
                 * transform.localRotation = Quaternion.Lerp(transform.localRotation, targetRot, LerpSpeed / 2f * Time.deltaTime);
                 * transform.localScale = Vector3.Lerp(transform.localScale, targetScale, LerpSpeed * Time.deltaTime);
                 */
                //Lerp world transform values to root
                transform.position   = Vector3.Lerp(transform.position, targetPos, LerpSpeed * Time.deltaTime);
                transform.rotation   = Quaternion.Lerp(transform.rotation, targetRot, LerpSpeed / 2f * Time.deltaTime);
                transform.localScale = Vector3.Lerp(transform.localScale, targetScale, LerpSpeed * Time.deltaTime);

                //If close in distance
                if (CanSnapToRoot())
                {
                    //Snap
                    transform.position   = targetPos;
                    transform.rotation   = targetRot;
                    transform.localScale = targetScale;


                    AnimationState = CardAnimationState.Idle;
                }
            }
            else if (AnimationState == CardAnimationState.Dragged)
            {
                targetPos   = (Input.mousePosition);
                targetRot   = Quaternion.identity;
                targetScale = Vector3.one;

                //Lerp WORLD transform values to mouse
                //transform.position = targetPos;
                transform.position   = Vector3.Lerp(transform.position, targetPos, LerpSpeed * Time.deltaTime);
                transform.rotation   = Quaternion.Lerp(transform.rotation, targetRot, Time.deltaTime);
                transform.localScale = Vector3.Lerp(transform.localScale, targetScale, LerpSpeed * Time.deltaTime);
            }
        }
Exemplo n.º 4
0
        public void AnimateToMyHand(Vector3 startPosition, Quaternion startRotation, Vector3 startScale)
        {
            //Set start
            transform.position   = startPosition;
            transform.rotation   = startRotation;
            transform.localScale = startScale;

            //Set target
            targetPos   = _cardRoot.transform.position;
            targetRot   = _cardRoot.transform.rotation;
            targetScale = _cardRoot.transform.localScale;

            AnimationState = CardAnimationState.MovingToRoot;
        }