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(); }
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); }
private void SetDirection() { direction = (objective.position - transform.position).normalized; OnChangeDirection?.Invoke(direction); }
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); }
private async void DirectionHasChanged(bool state) { await OnChangeDirection.InvokeAsync(state); }