/// <summary> /// REQUIRED that the IsCurrentActionFinished flag be set by the end of the action. /// </summary> public static void DelayedActionWithCustomTrigger(string name, Action action, QueueingType queueingType = QueueingType.TO_BACK) { PushActionOntoRelevantQueue(new BasicDelayedAction(action, ActionManager.Instance.ActionCurrentlyBeingPerformed, name), queueingType); }
internal void CreateCardToBattleDeckDiscardPile(AbstractCard abstractCard, AbstractBattleUnit owner = null, CardCreationLocation location = CardCreationLocation.SHUFFLE, QueueingType queueingType = QueueingType.TO_BACK) { Require.NotNull(abstractCard); abstractCard.Owner = owner; QueuedActions.ImmediateAction("CreateCardToBattleDeckDiscardPile", () => { BattleRules.MarkCreatedCard(abstractCard, owner); if (location == CardCreationLocation.BOTTOM) { ServiceLocator.GameState().Deck.DiscardPile.Add(abstractCard); } else if (location == CardCreationLocation.TOP) { ServiceLocator.GameState().Deck.DiscardPile.AddToFront(abstractCard); } else if (location == CardCreationLocation.SHUFFLE) { ServiceLocator.GameState().Deck.DiscardPile.InsertIntoRandomLocation(abstractCard); } else { throw new Exception("gotta select a location"); } }, queueingType); }
public void DiscardCard(AbstractCard protoCard, QueueingType queueingType = QueueingType.TO_BACK) { QueuedActions.ImmediateAction("DiscardCard", () => { gameState.Deck.MoveCardToPile(protoCard, CardPosition.DISCARD); ServiceLocator.GetCardAnimationManager().MoveCardToDiscardPile(protoCard, assumedToExistInHand: false); }, queueingType); }
public void EvokeCardEffect(AbstractCard card, AbstractBattleUnit target, QueueingType queuingType = QueueingType.TO_BACK) { QueuedActions.DelayedActionWithCustomTrigger("Evoke card effect", () => { RunCardEvocationSpecialEffects(card, target); card.EvokeCardEffect(target); } ); }
public void DrawCards(int n = 1, QueueingType queueingType = QueueingType.TO_BACK, Action <List <AbstractCard> > performOnCards = null) { QueuedActions.ImmediateAction("DrawCards", () => { var cardsToPutInHand = deck.DrawNextNCards(n); ServiceLocator.GetCardAnimationManager().AddHypercardsToHand(cardsToPutInHand.Select(item => item.CreateHyperCard()).ToList()); if (performOnCards != null) { performOnCards(cardsToPutInHand); } }, queueingType); }
public void ExhaustCard(AbstractCard protoCard, QueueingType queueingType = QueueingType.TO_BACK) { QueuedActions.DelayedActionWithCustomTrigger("ExhaustCard", () => { gameState.Deck.MoveCardToPile(protoCard, CardPosition.EXPENDED); ServiceLocator.GetCardAnimationManager().DisappearCard(protoCard, assumedToExistInHand: false, callbackWhenFinished: () => { IsCurrentActionFinished = true; }); BattleRules.TriggerProc(new ExhaustedCardProc { TriggeringCardIfAny = protoCard }); }, queueingType); }
private static void PushActionOntoRelevantQueue(BasicDelayedAction action, QueueingType queueingType) { var parentAction = ActionManager.Instance.ActionCurrentlyBeingPerformed; if (queueingType == QueueingType.TO_BACK) { parentAction.ChildActionsQueue.Add(action); } else { parentAction.ChildActionsQueue.AddToFront(action); } }
internal void CreateCardToHand(AbstractCard abstractCard, AbstractBattleUnit owner = null, QueueingType queueingType = QueueingType.TO_BACK) { Require.NotNull(abstractCard); abstractCard.Owner = owner; QueuedActions.ImmediateAction("CreateCardToHand", () => { BattleRules.MarkCreatedCard(abstractCard, owner); ServiceLocator.GameState().Deck.Hand.Add(abstractCard); ServiceLocator.GetCardAnimationManager().AddHypercardsToHand(new List <Card> { abstractCard.CreateHyperCard() }); }, queueingType); }
internal void PurgeCardFromDeck(AbstractCard card, QueueingType queueingType = QueueingType.TO_BACK) { Require.NotNull(card); QueuedActions.ImmediateAction("PurgeCardFromDeck", () => { var position = deck.PurgeCardFromDeck(card.Id); if (position == CardPosition.HAND) { // Animate dissolving var movement = ServiceLocator.GetCardAnimationManager().GetCardMovementBehavior(card); movement.DissolveAndDestroyCard(() => { }); ServiceLocator.GetCardAnimationManager().RemoveHypercardFromHand(card); } }, queueingType); }
public void AttemptPlayCardFromHand(AbstractCard logicalCard, AbstractBattleUnit target, QueueingType queueingType = QueueingType.TO_BACK ) { QueuedActions.DelayedActionWithCustomTrigger("Attempt play card from hand: " + logicalCard.Name, () => { IsCurrentActionFinished = true; if (logicalCard != null) { if (!logicalCard.CanPlay(target).Playable) { Shout(logicalCard.Owner, logicalCard.CanPlay(target).ReasonUnplayable); } else { RunCardEvocationSpecialEffects(logicalCard, target); logicalCard.PlayCardFromHandIfAble_Action(target); } } else { throw new System.Exception("Could not deploy card! None selected."); } CheckIsBattleOver(); }, queueingType); }
public void AddCardToPersistentDeck(AbstractCard protoCard, AbstractBattleUnit unit, QueueingType queueingType = QueueingType.TO_BACK) { QueuedActions.ImmediateAction("AddCardToPersistentDeck", () => { var persistentDeckList = unit.CardsInPersistentDeck; if (persistentDeckList.Where(item => item.Id == protoCard.Id).Any()) { throw new Exception("Attempted to add card to deck that already had the same ID as a card in the deck already: " + protoCard.Name); } unit.AddCardToPersistentDeck(protoCard); Debug.Log("Added card to deck: " + protoCard.Name); // ServiceLocator.GetCardAnimationManager().RunCreateNewCardAndAddToDiscardPileAnimation(protoCard); //todo // Animate: Card created in center of screen, wait for a second, and shrinks while going down to the deck. }, queueingType); }
public static void ImmediateAction(string name, Action action, QueueingType queueingType = QueueingType.TO_BACK) { PushActionOntoRelevantQueue(new ImmediateAction(action, ActionManager.Instance.ActionCurrentlyBeingPerformed, name: name), queueingType); }
public static void DelayedActionWithFinishTrigger(string name, Action action, Func <bool> finishTrigger, QueueingType queueingType = QueueingType.TO_BACK) { PushActionOntoRelevantQueue(new DelayedActionWithFinishTrigger(name, action, ActionManager.Instance.ActionCurrentlyBeingPerformed, finishTrigger), queueingType); }