Esempio n. 1
0
 /// <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);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 public void EvokeCardEffect(AbstractCard card, AbstractBattleUnit target, QueueingType queuingType = QueueingType.TO_BACK)
 {
     QueuedActions.DelayedActionWithCustomTrigger("Evoke card effect", () =>
     {
         RunCardEvocationSpecialEffects(card, target);
         card.EvokeCardEffect(target);
     }
                                                  );
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
    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);
        }
    }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
 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);
 }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
    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);
    }
Esempio n. 12
0
 public static void ImmediateAction(string name, Action action, QueueingType queueingType = QueueingType.TO_BACK)
 {
     PushActionOntoRelevantQueue(new ImmediateAction(action, ActionManager.Instance.ActionCurrentlyBeingPerformed, name: name),
                                 queueingType);
 }
Esempio n. 13
0
 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);
 }