Example #1
0
 public ChaseMutator(Chase chaseState, UIManager uiManager, string reason)
 {
     this.chase     = chaseState;
     this.rng       = new System.Random();
     this.uiManager = uiManager;
     this.reason    = reason;
 }
Example #2
0
        /// <summary>
        /// Called at the start of the player's turn.
        /// </summary>
        public void BeginTurn()
        {
            this.CurrentChaseState = new ChaseMutator(this.CurrentChaseState, this.UiManager, "starting new turn")
                                     .DrawCards(DrawCardsPerTurn)
                                     .ReplacePursuitAction()
                                     .DrawRouteCards(this.CurrentChaseState.PlayerSpeed)
                                     .AddControl(ControlGainPerTurn)
                                     .Done();

            this.PhaseManager.State = ChasePhase.SelectingCard;
        }
Example #3
0
 void Awake()
 {
     // Bootstrap the chase state.
     this.CurrentChaseState = new Chase(
         StartInfo.StartingLead,
         StartInfo.StartingPlayerSpeed,
         StartInfo.StartingPursuitSpeed,
         StartInfo.StartingControl,
         StartInfo.StartingMaxLead,
         StartInfo.StartingMaxPlayerSpeed,
         StartInfo.StartingMaxPursuitSpeed,
         StartInfo.StartingMaxControl,
         StartInfo.StartingPlayerDeck,
         StartInfo.StartingRouteDeck,
         StartInfo.StartingPursuitDeck,
         StartInfo.AllDamageCards
         );
 }
Example #4
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;
            });
        }
Example #5
0
        public void PromptForParameters(
            Chase currentChaseState,
            UIManager uiManager,
            Action <List <ICard> > OnComplete,
            Action OnCancel
            )
        {
            this.uiManager = uiManager;

            // If there are no available cards to choose from, just return an empty list
            // immediately.
            if (this.candidateCards.Count == 0)
            {
                OnComplete(new List <ICard>());
                return;
            }

            uiManager.DisplayCardPicker(candidateCards);
            uiManager.CardClicked         += this.CardSelected;
            uiManager.CardPickerCancelled += () => { Cancel(OnCancel); };

            this.OnComplete = OnComplete;
        }
Example #6
0
 public virtual IProvidesCardParameters GetParameterProvider(Chase chaseState)
 {
     // By default, cards do not require parameters.
     return(null);
 }
Example #7
0
 public bool CanPlay(Chase currentState)
 {
     return(currentState.Control >= this.ControlCost);
 }
Example #8
0
 public abstract Chase Play(
     Chase currentState,
     List <ICard> targetCards,
     UIManager uiManager
     );
Example #9
0
        /// <summary>
        /// Called at the end of a player's turn.
        /// </summary>
        public void EndTurn()
        {
            if (!UiManager.HasFinishedAnimations())
            {
                return;
            }

            this.PhaseManager.State = ChasePhase.ResolvingPursuitAndRoute;

            // The player discards all remaining cards and loses any unspent control.
            ChaseMutator endPlayerTurnMutator = new ChaseMutator(
                this.CurrentChaseState,
                this.UiManager,
                "ending player turn"
                );

            endPlayerTurnMutator.AddControl(-this.CurrentChaseState.Control);
            this.CurrentChaseState.Hand.ToList()
            .ForEach(card => endPlayerTurnMutator.DiscardFromHand(card));
            this.CurrentChaseState = endPlayerTurnMutator.Done();

            // Apply the current pursuit card.
            if (this.CurrentChaseState.PursuitAction != null)
            {
                this.CurrentChaseState = this.CurrentChaseState.PursuitAction
                                         .Play(this.CurrentChaseState, this.UiManager);

                if (this.CheckForChaseEnd())
                {
                    return;
                }
            }


            // Then apply any route cards.
            while (this.CurrentChaseState.CurrentRoute.Count > 0)
            {
                // Play the next route card. We charitably assume that route cards discard
                // themselves after being played.
                IRouteCard routeCard = this.CurrentChaseState.CurrentRoute[0];
                this.CurrentChaseState = routeCard.Play(this.CurrentChaseState, this.UiManager);

                if (this.CheckForChaseEnd())
                {
                    return;
                }
            }

            // Apply any damage cards in the player's hand
            IPlayerCard[] damageCards = this.CurrentChaseState.Hand
                                        .Where(card => card.CardType == PlayerCardType.Damage)
                                        .ToArray();

            foreach (IPlayerCard damageCard in damageCards)
            {
                this.CurrentChaseState = damageCard
                                         .Play(this.CurrentChaseState, new List <ICard>(), this.UiManager);

                if (this.CheckForChaseEnd())
                {
                    return;
                }
            }

            // Discard any remaining cards in the player's hand.
            ChaseMutator endRoundMutator = new ChaseMutator(this.CurrentChaseState, this.UiManager, "ending round");

            // Finally, apply the effects of pursit speed and the player's speed
            this.CurrentChaseState = endRoundMutator
                                     .AddLead(this.CurrentChaseState.PlayerSpeed - this.CurrentChaseState.PursuitSpeed)
                                     .Done();

            if (this.CheckForChaseEnd())
            {
                return;
            }

            // Add a callback to start the next turn once the animation for the end of the turn is
            // done.
            this.UiManager.OnceAnimationQueueCompletes(() => { BeginTurn(); });
        }
Example #10
0
 public abstract Chase Play(Chase currentState, UIManager uiManager);