private void AddUndoAction(CardDisplay card, UndoAction undoAction)
        {
            undoActions.Push(undoAction);

            moveCount++;

            OnCheckMovesCurrentState_Event(moveCount);
        }
        public void OnDoubleClick()
        {
            var undoAction = new UndoAction(() =>
            {
                CurrentPile.GetCard(this);

                PreviousPile.PlaceCard(this);

                CurrentPile.HandlePreviousCard(false);
            });

            OnDoubleClick_Event(this, undoAction);
        }
Ejemplo n.º 3
0
        private void QuickPlacement(CardDisplay card, UndoAction someType)
        {
            if (card.CurrentPile.IsCardLastIndex(card) == false)
            {
                return;
            }

            var cardToDrop = new CardDisplay[] { card };

            if (IsValidDrop(cardToDrop))
            {
                var topCard = card.CurrentPile.GetCard(card);

                PlaceCard(topCard);

                topCard.PreviousPile.HandleTopCard(true);

                OnQuickPlacement(card, someType);
            }
        }
Ejemplo n.º 4
0
        private IEnumerator IResetCards()
        {
            var cards = waste.GetAllCards();

            if (IsAnimating)
            {
                var isAnimatingScale    = false;
                var isAnimatingMovement = false;

                yield return(new WaitUntil(() => isAnimatingScale == false && isAnimatingMovement == false));
            }

            CardDisplay card         = null;
            var         pileToReturn = cards[0].CurrentPile;

            for (int i = 0; i < cards.Length; i++)
            {
                card = cards[i];
                card.Flip(false, false);
                PlaceCard(card);
            }

            var undoAction = new UndoAction(() =>
            {
                for (int i = cards.Length - 1; i >= 0; i--)
                {
                    //for(int i = 0; i < cards.Length; i++)
                    card = cards[i].CurrentPile.GetCard(cards[i]);
                    pileToReturn.PlaceCard(card);

                    card.Flip(true, true);

                    card.CurrentPile.HandlePreviousCard(false);
                }
            });

            OnCardDrawed_Event(card, undoAction);

            iResetCards_Coroutine = null;
        }
Ejemplo n.º 5
0
        private IEnumerator IDrawCard()
        {
            var card = GetTopCard();

            if (IsAnimating)
            {
                yield return(card.IMoveToPile(waste, waste.transform.position, CardMovementDuration));
            }

            waste.PlaceCard(card);

            if (IsAnimating)
            {
                yield return(card.IFlip(true, CardFlipDuration));
            }
            else
            {
                card.Flip(true, true);
            }

            var pileToReturn = card.PreviousPile;

            var undoAction = new UndoAction(() =>
            {
                // Debug.Log("MOVE AND FLIP");

                card.CurrentPile.GetCard(card);
                pileToReturn.PlaceCard(card);

                card.Flip(false, card.IsTurned == false);

                card.CurrentPile.HandlePreviousCard(false);
            });

            OnCardDrawed_Event(card, undoAction);

            iDrawCard_Coroutine = null;
        }
        private void ValidateDrop(CardDisplay[] cards)
        {
            var canDrop = IsValidDrop(cards);

            if (canDrop)
            {
                var topCard = cards[0];

                topCard.PreviousPile.HandleTopCard(true);

                CardDisplay card;
                Pile        pileToReturn;

                pileToReturn = topCard.PreviousPile;

                var undoAction = new UndoAction(() =>
                {
                    for (int i = cards.Length - 1; i >= 0; i--)
                    {
                        card = cards[i];

                        card.CurrentPile.GetCard(card);
                        pileToReturn.PlaceCard(card);
                        card.CurrentPile.HandlePreviousCard(false);
                    }
                });

                OnCardsValidPlacement_Event(cards, undoAction);

                PlaceCards(cards);

                return;
            }

            OnCardsInvalidPlacement_Event(cards);
        }
 private void AddUndoAction(CardDisplay[] cards, UndoAction undoAction)
 {
     AddUndoAction(cards[0], undoAction);
 }
Ejemplo n.º 8
0
 private void PlayQuickPlacement(CardDisplay someCard, UndoAction someUndoAction)
 {
     PlaySoundEffect(Place_Card_Sound);
 }
Ejemplo n.º 9
0
 private void PlayCardFlip(CardDisplay someCard, UndoAction someUndoAction)
 {
     PlaySoundEffect(Turn_Card_Sound);
 }
Ejemplo n.º 10
0
 private void PlayValidPlacement(CardDisplay[] someCards, UndoAction someUndoAction)
 {
     PlaySoundEffect(Place_Card_Sound);
 }