示例#1
0
    IEnumerator playCardAnimation(CardStateAnimation cardStateAnimation, System.Action callBack)
    {
        float   currentTime   = 0;
        Vector3 startPosition = cardStateAnimation.card.transform.position;
        Vector3 endPosition   = cardStateAnimation.Position;

        cardStateAnimation.card.SetLayer(1, SortingLayer.NameToID("Animation"));

        while (currentTime < _animationDuration)
        {
            float factor = currentTime / _animationDuration;
            factor = _animationCurve.Evaluate(factor);

            cardStateAnimation.card.transform.position = Vector3.Lerp(startPosition, endPosition, factor);

            currentTime += Time.deltaTime;
            yield return(null);
        }

        cardStateAnimation.card.transform.position = endPosition;
        cardStateAnimation.card.SetLayer(cardStateAnimation.Layer, SortingLayer.NameToID("Deck"));
        cardStateAnimation.card.setVisible(cardStateAnimation.isVisible);
        cardStateAnimation.card.setFaceUp(cardStateAnimation.isFaceUp);

        callBack();
    }
示例#2
0
 private void playNextAnimation()
 {
     if (_cardAnimations.Count > 0)
     {
         CardStateAnimation cardStateAnimation = _cardAnimations[0];
         _cardAnimations.RemoveAt(0);
         StartCoroutine(playCardAnimation(cardStateAnimation, playNextAnimation));
     }
 }