Ejemplo n.º 1
0
        private void PlayCard(IPlayerCard card, List <ICard> targetCards)
        {
            if (!card.CanPlay(this.CurrentChaseState))
            {
                return;
            }

            this.PhaseManager.State = ChasePhase.PlayingAnimation;
            this.CurrentChaseState  = card.Play(this.CurrentChaseState, targetCards, this.UiManager);

            // Check if the player has won or lost as a result of playing this card.
            if (this.CheckForChaseEnd())
            {
                return;
            }

            this.UiManager.OnceAnimationQueueCompletes(() => {
                this.PhaseManager.State = ChasePhase.SelectingCard;
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the player has selected a card to play.
        /// </summary>
        public void SelectCard(IPlayerCard card)
        {
            if (!card.CanPlay(this.CurrentChaseState))
            {
                return;
            }

            IProvidesCardParameters parameterProvider = card
                                                        .GetParameterProvider(this.CurrentChaseState);

            if (parameterProvider == null)
            {
                // If the card doesn't require any parameters, jut play it immediately.
                this.PlayCard(card, new List <ICard>());
                this.PhaseManager.State = ChasePhase.PlayingAnimation;
            }
            else
            {
                // Otherwise, fire up the parameter provider and play the card once parameter values
                // have been provided.
                this.PhaseManager.State = ChasePhase.SelectingParameters;

                parameterProvider.PromptForParameters(
                    this.CurrentChaseState,
                    this.UiManager,
                    targetCards => {
                    // Paramters provided, play the card.
                    this.PlayCard(card, targetCards);
                },
                    () => {
                    // User cancelled out of parameter dialogue, go back to selecting card to
                    // play.
                    this.PhaseManager.State = ChasePhase.SelectingCard;
                });
            }
        }