Exemplo n.º 1
0
    private IEnumerator DiscardTween(Card card, float duration)
    {
        GameObject tweenGO   = Instantiate(_tweenCardGO, _tweenCardGO.transform);
        CardView   tweenView = tweenGO.GetComponent <CardView>();

        tweenGO.transform.position = _currentCardView.transform.position;
        tweenView.Display(card);
        LeanTween.move(tweenGO, _discardDeckView.transform, duration);
        yield return(new WaitForSeconds(duration));

        _discardDeckView.Display(card);
        Debug.Log("Player: Card added to discard: " + card.Name);
        Debug.Log("Player Hand Count: " + _playerHand.Count);
        if (_playerHand.Count > 0)
        {
            _currentCardView.Display(_playerHand.TopItem);
            _currentCardIndex = _playerHand.Count - 1;
        }
        else
        {
            _currentCardView.DisplayNull();
            _currentCardIndex = 0;
        }
        Destroy(tweenGO);
    }
Exemplo n.º 2
0
    private IEnumerator ReshuffleTween(Card card, float duration)
    {
        GameObject tweenGO   = Instantiate(_tweenCardGO, _tweenCardGO.transform);
        CardView   tweenView = tweenGO.GetComponent <CardView>();

        tweenGO.transform.position = _discardDeckView.transform.position;
        tweenView.Display(card);
        LeanTween.move(tweenGO, _drawDeckView.transform, duration);
        yield return(new WaitForSeconds(duration));

        _drawDeckView.Display(_drawDeck);
        _discardDeckView.DisplayNull();
        Destroy(tweenGO);
    }
Exemplo n.º 3
0
    private IEnumerator DrawCardTween(Card card, float duration)
    {
        GameObject tweenGO   = Instantiate(_tweenCardGO, _tweenCardGO.transform);
        CardView   tweenView = tweenGO.GetComponent <CardView>();

        tweenGO.transform.position = _drawDeckView.transform.position;
        tweenView.Display(card);
        LeanTween.move(tweenGO, _currentCardView.transform, duration);
        yield return(new WaitForSeconds(duration));

        _currentCardView.Display(_playerHand.Cards[_currentCardIndex]);
        _drawDeckView.Display(_drawDeck);
        Destroy(tweenGO);
    }
Exemplo n.º 4
0
 public void PlayCurrentCard()
 {
     if (_playerHand.Count > 0)
     {
         Card targetCard = _playerHand.Cards[_currentCardIndex];
         _cardToPlace     = targetCard;
         _cardToPlaceGO   = Instantiate(_tweenCardGO, _tweenCardGO.transform);
         _cardToPlaceView = _cardToPlaceGO.GetComponent <CardView>();
         _cardToPlaceGO.transform.position = _currentCardView.transform.position;
         _cardToPlaceView.Display(targetCard);
         AudioHelper.PlayClip2D(_playAudio, 1f);
     }
     else
     {
         Debug.LogWarning("Player Hand: Nothing to play - hand is empty!");
     }
     UpdateHandSize();
 }
Exemplo n.º 5
0
 public void SelectNextCard()
 {
     if (_playerHand.Count > 0)
     {
         if (_currentCardIndex + 1 <= _playerHand.Count - 1)
         {
             //If there's a next card to go to
             _currentCardIndex += 1;
             _currentCardView.Display(_playerHand.Cards[_currentCardIndex]);
         }
         else
         {
             //else return to the beginning
             _currentCardIndex = 0;
             _currentCardView.Display(_playerHand.BottomItem);
         }
         AudioHelper.PlayClip2D(_selectAudio, 1f);
     }
     else
     {
         Debug.LogWarning("Player: No cards to select between");
     }
     UpdateHandSize();
 }