示例#1
0
    public void OnDrag(PointerEventData eventData)
    {
        if (state == SwipeState.DISABLE)
        {
            return;
        }

        state = SwipeState.DRAG;

        rectTransform.anchoredPosition += new Vector2(eventData.delta.x, 0) / _parent.scaleFactor;
        rectTransform.rotation          = Quaternion.Euler(0, 0, (rectTransform.anchoredPosition.x - pivotPoint.x) * fRotation);

        if (rectTransform.anchoredPosition.x > pivotPoint.x)
        {
            if (direction != 1)
            {
                OnChangeDirection?.Invoke(SwipeDirection.RIGHT);
            }
            direction = 1;
        }
        else if (rectTransform.anchoredPosition.x < pivotPoint.x)
        {
            if (direction != -1)
            {
                OnChangeDirection?.Invoke(SwipeDirection.LEFT);
            }
            direction = -1;
        }

        if (cardController != null)
        {
            cardController.OnDrag(direction);

            if (!cardController.rightAvailable && rectTransform.anchoredPosition.x > pivotPoint.x)
            {
                float scale = 0.93f;
                rectTransform.anchoredPosition = pivotPoint;

                rectTransform.rotation   = Quaternion.Euler(0, 0, 0);
                rectTransform.localScale = Vector3.MoveTowards(rectTransform.localScale, new Vector3(scale, scale, scale), 0.02f);
            }
            else if (!cardController.leftAvailable && rectTransform.anchoredPosition.x < pivotPoint.x)
            {
                float scale = 0.93f;
                rectTransform.anchoredPosition = pivotPoint;
                rectTransform.rotation         = Quaternion.Euler(0, 0, 0);
                rectTransform.localScale       = Vector3.MoveTowards(rectTransform.localScale, new Vector3(scale, scale, scale), 0.02f);
            }
            else
            {
            }
        }

        MovingDispatcher();
    }
示例#2
0
 private void DirectionChange_Horizontal(float horizontalAxis)
 {
     if (horizontalAxis > 0)
     {
         if (faceDirection != Vector2.right)
         {
             OnChangeDirection?.Invoke(Vector2.right);
         }
     }
     else if (horizontalAxis < 0)
     {
         if (faceDirection != Vector2.left)
         {
             OnChangeDirection?.Invoke(Vector2.left);
         }
     }
 }
    protected override Vector3 GetMovingDirection()
    {
        if (Frozen)
        {
            return(Vector3.zero);
        }

        var dir = input.GetMovingDirection();

        dir.y = 0;


        if (dir.x != 0)
        {
            OnChangeDirection.Invoke(dir.x > 0);
            sprite.transform.rotation = Quaternion.Euler(0, dir.x > 0? 0: 180, 0);
        }


        return(dir);
    }
示例#4
0
 private void SetDirection()
 {
     direction = (objective.position - transform.position).normalized;
     OnChangeDirection?.Invoke(direction);
 }
示例#5
0
 private void SetDefaultFaceDirection()
 {
     OnChangeDirection?.Invoke(Vector2.right);
 }
 private void ChangeNavigationDirection(CommandTypes directionType)
 {
     OnChangeDirection?.Invoke(PropulsionModule, directionType);
 }
 private void MoveForwardCommandExecute(CommandTypes directionType)
 {
     OnChangeDirection?.Invoke(PropulsionModule, directionType);
 }
示例#8
0
 private async void DirectionHasChanged(bool state)
 {
     await OnChangeDirection.InvokeAsync(state);
 }