/// <summary>
        /// Return the card to original deck
        /// </summary>
        private void ReleaseDraggedCard(bool _giveBackToOriginalDeck)
        {
            if (draggedCard == null)
            {
                return;
            }

            if (_giveBackToOriginalDeck)
            {
                draggedCardOriginalDeck.AddTopCard(draggedCard);                        //Return the card to original Deck
            }
            else if (draggedCardOriginalDeck.deckType == DeckController.DeckType.Column)
            {
                if (draggedCardOriginalDeck.IsTopCardFrontSide)                         //Add the card to the new deck and flip the top
                {
                    draggedCardOriginalDeck.DrawCard(true, false);                      //card of the original deck if it wasn't already flipped (front side)
                }
                else
                {
                    AssignPoints(5);                                                    //Special case: assign 5 points if a card in column is reveald
                    draggedCardOriginalDeck.DrawCard(true, true);
                }
            }
            else if (draggedCardOriginalDeck.deckType == DeckController.DeckType.DrawnCards)
            {
                draggedCardOriginalDeck.DrawCard(true, false);                          //Never flip the drawn cards (they are already fron side)
                draggedCardOriginalDeck.OrderCards();                                   //Always update their displacement
            }

            draggedCard = null;
            isDragging  = false;
        }
Beispiel #2
0
        public void UndoLastMove()
        {
            if (IsPaused || moves.Count <= 0)
            {
                return;
            }

            Move lastMove = moves.Last();

            //Subtract eventual points given
            GameManager.I.InterfaceCtrl.AddPoints(-lastMove.PointsGiven);

            CardBehaviour card = lastMove.EndingDeck.RemoveTopCard();

            if (lastMove.InitialDeck.deckType == DeckController.DeckType.Column)
            {
                List <CardBehaviour> initiaDeckCardsFF = lastMove.InitialDeck.GetFrontSizedCards();
                if (initiaDeckCardsFF.Count == 1)
                {
                    lastMove.InitialDeck.GetTopCard().Flip();
                    GameManager.I.InterfaceCtrl.AddPoints(-5);
                }
            }

            lastMove.InitialDeck.AddTopCard(card);

            moves.RemoveAt(moves.Count - 1);
        }
Beispiel #3
0
 public Move(int _points, CardBehaviour _card, DeckController _initialDeck, DeckController _endingDeck)
 {
     PointsGiven = _points;
     Card        = _card;
     CardVal     = _card.GetValue();
     InitialDeck = _initialDeck;
     EndingDeck  = _endingDeck;
 }
Beispiel #4
0
        /// <summary>
        /// Add a card to the deck
        /// </summary>
        /// <param name="_newCard"></param>
        public void AddTopCard(CardBehaviour _newCard)
        {
            deck.Add(_newCard.GetValue());
            _newCard.transform.parent = transform;

            DisplayCard(_newCard, false);

            OrderCards();
        }
Beispiel #5
0
        /// <summary>
        /// Transfer the card from this deck to another
        /// </summary>
        /// <param name="_newDeck"></param>
        public void TransferTopCard(DeckController _newDeck)
        {
            CardBehaviour card = RemoveTopCard();

            if (card != null)
            {
                _newDeck.AddTopCard(card);
            }
        }
        /// <summary>
        /// Reaction to pointer-like input down recived (by deck controllers)
        /// </summary>
        /// <param name="_deck"></param>
        public void OnInputDownRecived(DeckController _deck)
        {
            if (IsPaused)
            {
                return;
            }

            if (_deck.deckType == DeckController.DeckType.DrawnCards || _deck.deckType == DeckController.DeckType.Column)
            {
                draggedCard             = _deck.RemoveTopCard();
                draggedCardOriginalDeck = _deck;
                isDragging = true;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Remove the card on the top of the deck
        /// Return null if there are none
        /// </summary>
        /// <returns></returns>
        public CardBehaviour RemoveTopCard()
        {
            if (deck.Count > 0)
            {
                deck.RemoveAt(deck.Count - 1);
            }

            if (deckGraphic.Count > 0)
            {
                CardBehaviour card = deckGraphic.Last();
                deckGraphic.RemoveAt(deckGraphic.Count - 1);
                return(card);
            }

            return(null);
        }
Beispiel #8
0
        /// <summary>
        /// Display a card on the top of the deck
        /// If _overrideLast == true, _card will be destroyed
        /// </summary>
        /// <param name="_card"></param>
        /// <param name="_overrideLast"></param>
        public void DisplayCard(CardBehaviour _card, bool _overrideLast)
        {
            if (_overrideLast && deckGraphic.Count > 0)
            {
                //Prevent override of nothing
                if (deckGraphic.Count == 0)
                {
                    DisplayCard(_card, false);
                    return;
                }

                deckGraphic.Last().SetValue(_card.GetValue());
                Destroy(_card.gameObject);
            }
            else
            {
                deckGraphic.Add(_card);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Display a card on the top of the deck
        /// </summary>
        public void DisplayCard(CardValue _cardValue, bool _overrideLast)
        {
            if (_overrideLast && deckGraphic.Count > 0)
            {
                //Prevent override of nothing
                if (deckGraphic.Count == 0)
                {
                    DisplayCard(_cardValue, false);
                    return;
                }

                deckGraphic.Last().SetValue(_cardValue);
            }
            else
            {
                CardBehaviour cardFacedDown = Instantiate(GameManager.I.CardPrefab, transform).GetComponent <CardBehaviour>();
                cardFacedDown.Init(_cardValue);

                deckGraphic.Add(cardFacedDown);
            }
        }
Beispiel #10
0
 public void RecordMove(int _points, CardBehaviour _card, DeckController _startingDeck, DeckController _endingDeck)
 {
     RecordMove(new Move(_points, _card, _startingDeck, _endingDeck));
 }