示例#1
0
    private IEnumerator MoveCard(CardBehaviour card)
    {
        _lastSelectionIndex = _cards.FindIndex((x) => x == card);

        int prevIndex = _lastSelectionIndex;

        while (true)
        {
            var cursorPosition = InputHelper.GetCursorPosition();

            card.SetTarget(cursorPosition, Quaternion.identity);

            var index = GetCardIndexWithPosition(cursorPosition);
            if (index >= 0 && index != prevIndex)
            {
                _cards.Remove(card);
                _cards.Insert(index, card);
                ReorderCards();
                card.RectTransform.SetSiblingIndex(_cards.Count);
                prevIndex = index;
            }

            yield return(null);
        }
    }
示例#2
0
    private void Card_CursorEnter(CardBehaviour sender)
    {
        if (!_selected)
        {
            Vector3 normal;

            var pos = _deckBezier.GetPoint(GetCardPositionNormalized(_cards.FindIndex((x) => x == sender)), out normal);

            if (_highlighted)
            {
                Card_CursorExit(_highlighted);
            }

            sender.SetTarget(pos + normal * CardHighlightOffset, Quaternion.identity);
            sender.ToggleHighlight(true);
            sender.RectTransform.SetAsLastSibling();
            _highlighted = sender;
        }
    }
示例#3
0
    private void SetCardTarget(CardBehaviour card, Vector3 pos, Vector3 normal)
    {
        var angle = Vector3.SignedAngle(Vector3.up, normal, Vector3.forward);

        card.SetTarget(pos, Quaternion.AngleAxis(angle, Vector3.forward));
    }