Ejemplo n.º 1
0
        private void VisibleState(AnimState lastState, ref TweenHolder returnTween)
        {
            Vector3 finalPosition = _parentModViewtroller.ParentCardHolder.GetFinalPositionOfCard(_parentModViewtroller);

            switch (lastState)
            {
            case AnimState.SELECTED:
                returnTween.AddIncrementalScaleTween(Vector3.one);
                goto case AnimState.ABLE_TO_BE_SELECTED;

            case AnimState.ABLE_TO_BE_SELECTED:
                returnTween.RemoveTweenOfType <PositionPingPongTween>().AddIncrementalPositionTween(finalPosition);
                break;

            default:                     // case AnimState.OBSCURED:
                if (returnTween.GetTweenOfType <PositionPingPongTween>() != null)
                {
                    goto case AnimState.ABLE_TO_BE_SELECTED;
                }
                returnTween.AddPositionPingPongTween(finalPosition
                                                     + Vector3.up * _parentModViewtroller._cardAnimationData.CardFloatingHeight, finalPosition)
                .AddLocalRotationTween(Vector3.zero);
                break;
            }
            returnTween.SetDuration(_parentModViewtroller._cardAnimationData.CardStateChangeDuration);
        }
    public override void OnUpdate()
    {
        float percentDone = PingPong ? TweenHolder.EaseInOutPingPongAnimationCurveFastOutro(TweenHolder.PercentDone)
                                                                         : TweenHolder.EaseInOutAnimationCurve(TweenHolder.PercentDone);

        _CachedTransform.localEulerAngles = Vector3.Lerp(EulerFrom, EulerTo, percentDone);
    }
Ejemplo n.º 3
0
    public void MoveCard(int cardIndex, CardHolder other, out TweenHolder outTween, bool?visibleDuringTween, int indexToInsertAt = -1)
    {
        CardController cardBeingMoved = _Cards[cardIndex];

        _Cards.RemoveAt(cardIndex);
        if (!other._Cards.InsertionIndexIsValid(indexToInsertAt))
        {
            indexToInsertAt = other._Cards.Count;
        }
        other.AddCard(cardBeingMoved, indexToInsertAt);

        cardBeingMoved.ViewFSM.SetAnimState(other._cardsAnimState, performTweens: false);
        cardBeingMoved.ViewFSM.SetTextVisibility(visibleDuringTween ?? other._cardsTextVisibility);

        outTween = cardBeingMoved.AddOffsetHeightTween(_cardAnimationData.GeneralCardMoveHeight,
                                                       other.GetFinalPositionOfCardAtIndex(indexToInsertAt), true)
                   .AddLocalRotationTween(Vector3.one * 360.0f + cardBeingMoved.ViewFSM.GetAnimRotationOffset())
                   .AddIncrementalScaleTween(cardBeingMoved.ViewFSM.GetAnimScale())
                   .SetDuration(_cardAnimationData.GeneralCardMoveDuration)
                   .SetShouldChangeLayer(true)
                   .AddToOnFinishedOnce(() => other.OnCardRecieveTweenFinished(cardBeingMoved));

        OnCardSent(cardBeingMoved);
        other.OnCardRecieveTweenBegan(cardBeingMoved);

        if (CardFlipAudio != null)
        {
            CardFlipAudio.Play();
        }
    }
Ejemplo n.º 4
0
        public TweenHolder SetAnimState(AnimState newState, bool performTweens = true)
        {
            TweenHolder returnTween = _parentModViewtroller.Holder;

            if (State != newState)
            {
                AnimState lastState = State;
                State = newState;
                if (performTweens)
                {
                    switch (State)
                    {
                    case AnimState.OBSCURED:
                        ObscuredState(lastState, ref returnTween);
                        break;

                    case AnimState.VISIBLE:
                        VisibleState(lastState, ref returnTween);
                        break;

                    case AnimState.ABLE_TO_BE_SELECTED:
                        AbleToBeSelectedState(lastState, ref returnTween);
                        break;

                    case AnimState.SELECTED:
                        SelectedState(lastState, ref returnTween);
                        break;
                    }
                    return(returnTween);
                }
            }
            return(null);
        }
    public override void OnUpdate()
    {
        float percentDone = TweenHolder.EaseInOutPingPongAnimationCurveFastOutro(TweenHolder.PercentDone);

        if (percentDone < 0.5f)
        {
            _CachedTransform.position = Vector3.Lerp(PositionFrom, PositionTo, PingPongFunction(percentDone));
        }
        else
        {
            _CachedTransform.position = Vector3.Lerp(PositionBackTo, PositionTo, PingPongFunction(percentDone));
        }
    }
Ejemplo n.º 6
0
    protected override void RepositionCards()
    {
        Vector3        leftmostPosition = transform.position - transform.right * _handMaxSizeInUnits / 2.0f;
        float          distBetweenCards = _handMaxSizeInUnits / (Mathf.Max(1.0f, CardCount) + 1.0f);
        CardController bestCardToMimic  = _CardsInTransition.Best((a, b) => a.Holder.TimeRemaining < b.Holder.TimeRemaining);

        for (int i = 0, iMax = ReadOnlyCards.Count; i < iMax; ++i)
        {
            if (ReadOnlyCards[i].ViewFSM.State != CardController.CardViewFSM.AnimState.SELECTED)
            {
                TweenHolder cardShiftTween = ReadOnlyCards[i].Holder;
                Vector3     targetPosition = leftmostPosition + transform.right * distBetweenCards * (i + 1);

                IncrementalPositionTween posTweenToShift;
                if ((posTweenToShift = cardShiftTween.GetTweenOfType <IncrementalPositionTween>()) == null)                // Careful (=)
                {
                    ReadOnlyCards[i].AddIncrementalPositionTween(targetPosition)
                    .SetShouldChangeLayer(false);
                }
                else
                {
                    posTweenToShift.PositionTo = targetPosition;
                }

                if (!_CardsInTransition.Contains(ReadOnlyCards[i]))
                {
                    if (bestCardToMimic != null)
                    {
                        if (Mathf.Approximately(ReadOnlyCards[i].Holder.Duration, ReadOnlyCards[i].Holder.TimeRemaining))
                        {
                            ReadOnlyCards[i].Holder.SetDuration(bestCardToMimic.Holder.TimeRemaining);
                        }
                        else
                        {
                            ReadOnlyCards[i].Holder.SetDuration(bestCardToMimic.Holder.Duration);
                        }
                    }
                    else
                    {
                        ReadOnlyCards[i].Holder.SetDuration(_CardAnimationData.GeneralCardMoveDuration);
                    }
                }
            }
        }
    }
Ejemplo n.º 7
0
        private void SelectedState(AnimState lastState, ref TweenHolder returnTween)
        {
            switch (lastState)
            {
            case AnimState.OBSCURED:
                returnTween.AddLocalRotationTween(Vector3.zero);
                goto case AnimState.VISIBLE;

            case AnimState.VISIBLE:
                returnTween.AddIncrementalPositionTween(_parentModViewtroller.ParentCardHolder.GetFinalPositionOfCard(_parentModViewtroller));
                goto default;

            default:                     // case AnimState.ABLE_TO_BE_SELECTED:
                returnTween.AddIncrementalScaleTween(SELECTED_SCALE)
                .SetDuration(_parentModViewtroller._cardAnimationData.CardStateChangeDuration);
                break;
            }
        }
Ejemplo n.º 8
0
 private void OnDrawGizmosSelected()
 {
     Gizmos.color = Color.yellow;
     _tweenTransformPairs.ForEach(t =>
     {
         if (t.From != null && t.To != null)
         {
             Gizmos.color = Color.yellow;
             Gizmos.DrawLine(t.From.position, t.To.position);
             for (int i = 0, iMax = 15; i <= iMax; ++i)
             {
                 float percentLerped  = TweenHolder.EaseInOutAnimationCurve((float)i / iMax);
                 Vector3 positionLerp = Vector3.Lerp(t.From.position, t.To.position, percentLerped);
                 Gizmos.color         = Color.red;
                 Gizmos.DrawLine(positionLerp, positionLerp + Vector3.Slerp(t.From.forward, t.To.forward, percentLerped));
             }
         }
     });
 }
Ejemplo n.º 9
0
    protected override void RepositionCards()
    {
        int            cardCount        = ReadOnlyCards.Count;
        float          distBetweenCards = cardCount == 1 ? 0.0f : Mathf.Min(_maxDistBetweenCardsInUnits, _pileMaxHeightInUnits / (cardCount - 1));
        CardController bestCardToMimic  = _CardsInTransition.Best((a, b) => a.Holder.TimeRemaining < b.Holder.TimeRemaining);

        for (int i = 0; i < cardCount; ++i)
        {
            TweenHolder cardShiftTween = ReadOnlyCards[i].Holder;
            Vector3     targetPosition = transform.position + Vector3.up * distBetweenCards * i;

            IncrementalPositionTween posTweenToShift;
            if ((posTweenToShift = cardShiftTween.GetTweenOfType <IncrementalPositionTween>()) == null)            // Careful (=)
            {
                ReadOnlyCards[i].AddIncrementalPositionTween(targetPosition)
                .SetShouldChangeLayer(false);
            }
            else
            {
                posTweenToShift.PositionTo = targetPosition;
            }

            if (!ReadOnlyCards[i].Holder.enabled)
            {
                if (bestCardToMimic != null)
                {
                    if (Mathf.Approximately(ReadOnlyCards[i].Holder.Duration, ReadOnlyCards[i].Holder.TimeRemaining))
                    {
                        ReadOnlyCards[i].Holder.SetDuration(bestCardToMimic.Holder.TimeRemaining);
                    }
                    else
                    {
                        ReadOnlyCards[i].Holder.SetDuration(bestCardToMimic.Holder.Duration);
                    }
                }
                else
                {
                    ReadOnlyCards[i].Holder.SetDuration(_CardAnimationData.GeneralCardMoveDuration);
                }
            }
        }
    }
Ejemplo n.º 10
0
    public void IntroduceCard(CardController cardToIntroduce, out TweenHolder outTween,
                              bool fancyEntrance = false, float angleOffsetForFancyEntrance = 0.0f)
    {
        outTween = null;
        AddCard(cardToIntroduce);
        cardToIntroduce.ViewFSM.SetAnimState(_cardsAnimState, performTweens: false);

        if (fancyEntrance)
        {
            float cardCreationRadius = _cardAnimationData.DeckFillFancyIntroCardSpawnDistance;
            float rightDistance      = cardCreationRadius * Mathf.Cos(angleOffsetForFancyEntrance);
            float forwardDistance    = cardCreationRadius * Mathf.Sin(angleOffsetForFancyEntrance);

            cardToIntroduce.transform.position = transform.position
                                                 + Vector3.right * rightDistance
                                                 + Vector3.forward * forwardDistance;

            outTween = cardToIntroduce.AddOffsetHeightTween(_cardAnimationData.DeckFillFancyIntroTweenHeight,
                                                            GetCardPositionAtIndex(_Cards.LastIndex()), true)
                       .AddLocalRotationTween(360.0f * Vector3.one + cardToIntroduce.ViewFSM.GetAnimRotationOffset())
                       .SetDuration(_cardAnimationData.DeckFillDurationPerCard)
                       .SetShouldChangeLayer(true)
                       .AddToOnFinishedOnce(() => OnCardRecieveTweenFinished(cardToIntroduce));

            OnCardRecieveTweenBegan(cardToIntroduce);
        }
        else
        {
            cardToIntroduce.transform.ResetLocal();
        }

        if (CardFlipAudio != null)
        {
            CardFlipAudio.Play();
        }
    }
Ejemplo n.º 11
0
 private static TweenHolder AddPositionTweenInternal(TweenHolder tweenHolder, Vector3 from, Vector3 to)
 {
     return(tweenHolder.AddTween(new PositionTween(from, to)).Play());
 }
Ejemplo n.º 12
0
    public override void OnUpdate()
    {
        float percentDone = TweenHolder.EaseInOutAnimationCurve(TweenHolder.PercentDone);

        _CachedTransform.position = Vector3.Lerp(PositionFrom, PositionTo, percentDone);
    }
 private static TweenHolder AddLocalRotationTweenInternal(TweenHolder tweenHolder, Vector3 from, Vector3 to, bool pingPong)
 {
     return(tweenHolder.AddTween(new LocalRotationTween(from, to, pingPong)).Play());
 }
Ejemplo n.º 14
0
 public void DealTo(CardHolder holder, out TweenHolder outTween, bool?visibleDuringTween)
 {
     MoveCard(ReadOnlyCards.LastIndex(), holder, out outTween, visibleDuringTween);
 }
Ejemplo n.º 15
0
 private static TweenHolder AddLocalQuaternionRotationTweenInternal(TweenHolder tweenHolder, Quaternion from, Quaternion to)
 {
     return(tweenHolder.AddTween(new LocalQuaternionRotationTween(from, to)).Play());
 }
Ejemplo n.º 16
0
    public override void OnUpdate()
    {
        float percentDone = TweenHolder.EaseInOutAnimationCurve(TweenHolder.PercentDone);

        _CachedTransform.localRotation = Quaternion.Slerp(From, To, percentDone);
    }