private void OnRouteCardClicked(object sender, EventArgs e) { IRouteCard clickedCard = (sender as GameObject) ?.GetComponent <UICardView>() ?.GetCard() as IRouteCard; this.RouteCardClicked?.Invoke(clickedCard); }
public ChaseMutator ExhaustFromRoute(IRouteCard card) { this.chase.CurrentRoute.Remove(card); this.changesApplied.Add($"Exhausted {card.Name} from route."); this.uiManager.AnimateExhaust(card, this.chase); return(this); }
/// <summary> /// Discard the specified card from the current route. /// </summary> public ChaseMutator DiscardFromRoute(IRouteCard card) { this.chase.CurrentRoute.Remove(card); this.chase.RouteDiscard.Prepend(card); this.changesApplied.Add($"Discarded {card.Name} from route."); this.uiManager.AnimateRouteDiscard(card, this.chase); return(this); }
/// <summary> /// Queue an animation to show a card being removed from the current route. /// </summary> public void AnimateRouteDiscard(IRouteCard card, Chase newState) { // Remove the first matching card from the current route. UICardView uiCard = FindCard(this.Route.transform, card); if (uiCard != null) { //queue card destroy AddAnimationToQueue(new QueuedAnimation(null, null, () => { if (uiCard != null && uiCard.gameObject != null) { Destroy(uiCard.gameObject); } }, null)); } }
public void Setup(IRouteCard card) { m_cardControlCostLayer.SetActive(false); m_flavourTextLayer.SetActive(string.IsNullOrEmpty(card.FlavourText) == false); UIPalette.CardTypeColourScheme scheme = UIPalette.Instance.GetCardTypeColorScheme(card.CardType); SetColourScheme(scheme); m_card = card; if (card.CardType != RouteCardType.None) { m_cardTypeLayer.SetActive(true); m_cardTypeText.text = card.CardType.ToString(); } else { m_cardTypeLayer.SetActive(false); } m_cardName.text = card.Name; m_cardName.color = Color.white; m_cardEffects.text = card.Description; m_cardImage.sprite = card.CardImage; SetFlavourText(card.FlavourText); }
public ChaseMutator AddCardToRouteDeck(IRouteCard card) { this.chase.RouteDeck.Prepend(card); this.changesApplied.Add($"Added {card.Name} to top of route deck."); return(this); }
/// <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(); }); }
/// <summary> /// Queue an animation to show the addition of a card to the current route. /// </summary> public void AnimateRouteCardDraw(IRouteCard card, Chase newState) { this.SpawnCard(card, CardSpawnLocation.Route); this.RouteDeckCountLabel.text = newState.RouteDeck.Count.ToString("N0"); }