Exemplo n.º 1
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);
    }
Exemplo n.º 2
0
    /*
     * This doesn't really make sense anymore, since we're not doing this in combat.
     * public void PromptPossibleUpgradeOfCard(AbstractCard beforeCard, int? cost = null)
     * {
     *  QueuedActions.ImmediateAction(() =>
     *  {
     *      var afterCard = beforeCard.CopyCard();
     *      afterCard.Upgrade();
     *      CardModificationDisplayScreen.Instance.Show(
     *          afterCard: afterCard,
     *          beforeCard: beforeCard,
     *          message: "Upgrade card?",
     *          goldCost: cost
     *      );
     *  });
     * }
     */

    public void RemoveStatusEffect <T>(AbstractBattleUnit unit) where T : AbstractStatusEffect
    {
        QueuedActions.ImmediateAction("RemoveStatusEffect", () =>
        {
            unit.StatusEffects.RemoveAll(item => item.GetType() == typeof(T));
        });
    }
Exemplo n.º 3
0
 public void EndBattleTurn()
 {
     QueuedActions.ImmediateAction("EndBattleTurn", () =>
     {
         turnEndActions.EndTurn();
     });
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
0
 public void AddStickerToCard(AbstractCard card, AbstractCardSticker stickerToAdd)
 {
     QueuedActions.ImmediateAction("AddStickerToCard", () =>
     {
         card.AddSticker(stickerToAdd);
     });
 }
Exemplo n.º 6
0
 public void Advance(AbstractBattleUnit unit)
 {
     QueuedActions.ImmediateAction("Advance", () =>
     {
         unit.StatusEffects.Add(new AdvancedStatusEffect());
     });
 }
Exemplo n.º 7
0
 public void CheckIsBattleOver()
 {
     QueuedActions.ImmediateAction("CheckIsBattleOver", () =>
     {
         BattleRules.CheckIsBattleOverAndIfSoSwitchScenes();
     });
 }
Exemplo n.º 8
0
 public void UpgradeCard(AbstractCard card)
 {
     QueuedActions.ImmediateAction("UpgradeCard", () =>
     {
         card.Upgrade();
     });
 }
Exemplo n.º 9
0
 public void TickDownStatusEffect <T>(AbstractBattleUnit unit) where T : AbstractStatusEffect
 {
     QueuedActions.ImmediateAction("TickDownStatusEffect", () =>
     {
         unit.TickDownStatusEffect <T>();
     });
 }
Exemplo n.º 10
0
        /// <summary>
        ///     Initializes the loader using the default values.
        /// </summary>
        public Loader()
        {
            _containerLoader = this.CreateDefaultContainerLoader();

            // Load everything else into the container
            var hostAssembly = typeof(Loader).Assembly;

            QueuedActions.Add(container => container.LoadFrom(hostAssembly));

            // Make sure that the plugins are only added once
            if (!Plugins.HasElementWith(p => p is AutoPropertyInjector))
            {
                Plugins.Add(new AutoPropertyInjector());
            }

            if (!Plugins.HasElementWith(p => p is AutoMethodInjector))
            {
                Plugins.Add(new AutoMethodInjector());
            }

            if (!Plugins.HasElementWith(p => p is AutoFieldInjector))
            {
                Plugins.Add(new AutoFieldInjector());
            }

            // Add the initializer to the end of
            // the instantiation pipeline
            if (!Plugins.HasElementWith(p => p is InitializerPlugin))
            {
                Plugins.Add(new InitializerPlugin());
            }

            FileLoaders.Add(_containerLoader);
        }
Exemplo n.º 11
0
        public void Reload(int step, byte[] bytes)
        {
            vec2  HoldCamPos  = CameraPos;
            float HoldCamZoom = CameraZoom;

            Load(MapFilePath);

            RepeatTry(() =>
            {
                LoadStateFromBuffer(bytes);

                if (MyPlayerNumber > 0)
                {
                    GameClass.Data.DoUnitSummary(MyPlayerValue, true);
                }
            });

            CameraPos  = HoldCamPos;
            CameraZoom = HoldCamZoom;

            QueuedActions.Clear();

            SimStep = ServerSimStep = AckSimStep = MinClientSimStep = step;

            SentBookend        = false;
            PostUpdateFinished = false;
            PostUpdateStep     = 0;

            SecondsSinceLastUpdate = 0;
        }
Exemplo n.º 12
0
 public void KillUnit(AbstractBattleUnit unit)
 {
     QueuedActions.ImmediateAction("KillUnit", () =>
     {
         unit.CurrentHp = 0;
         BattleRules.CheckAndRegisterDeath(unit, null, null);
     });
 }
Exemplo n.º 13
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);
 }
Exemplo n.º 14
0
 public void ChangeUnit(AbstractBattleUnit unit, Action <AbstractBattleUnit> action)
 {
     Require.NotNull(unit);
     QueuedActions.ImmediateAction("ChangeUnit", () =>
     {
         action(unit);
     });
 }
Exemplo n.º 15
0
 public void EvokeCardEffect(AbstractCard card, AbstractBattleUnit target, QueueingType queuingType = QueueingType.TO_BACK)
 {
     QueuedActions.DelayedActionWithCustomTrigger("Evoke card effect", () =>
     {
         RunCardEvocationSpecialEffects(card, target);
         card.EvokeCardEffect(target);
     }
                                                  );
 }
Exemplo n.º 16
0
 public void FallBack(AbstractBattleUnit unit)
 {
     QueuedActions.ImmediateAction("FallBack", () =>
     {
         if (unit.HasStatusEffect <AdvancedStatusEffect>())
         {
             unit.RemoveStatusEffect <AdvancedStatusEffect>();
         }
     });
 }
Exemplo n.º 17
0
 public void DiscardHand()
 {
     QueuedActions.ImmediateAction("DiscardHand", () =>
     {
         var hand = ServiceLocator.GameState().Deck.Hand.ToList();
         foreach (var card in hand)
         {
             DiscardCard(card);
         }
     });
 }
Exemplo n.º 18
0
 public void ApplyDefense(AbstractBattleUnit target, AbstractBattleUnit source, int baseQuantity)
 {
     QueuedActions.ImmediateAction("ApplyDefense", () =>
     {
         target.CurrentBlock += BattleRules.GetDefenseApplied(source, target, baseQuantity);
         if (target.CurrentBlock < 0)
         {
             target.CurrentBlock = 0;
         }
     });
 }
Exemplo n.º 19
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);
 }
Exemplo n.º 20
0
    // I should probably stop using the action manager for campaign actions
    public void PromptCardReward(AbstractBattleUnit soldier)
    {
        var soldierClass = soldier.SoldierClass;

        soldier.NumberCardRewardsEligibleFor--;

        var cardsThatCanBeSelected = soldierClass.GetCardRewardChoices();

        QueuedActions.DelayedActionWithCustomTrigger("Choose New Card For Deck", () => {
            CardRewardScreen.Instance.Show(cardsThatCanBeSelected, soldier);
        });
    }
Exemplo n.º 21
0
 /// <summary>
 ///  Rules for taunting:
 ///  It sets all attacks getting made to the taunter.
 /// </summary>
 public void TauntEnemy(AbstractBattleUnit target, AbstractBattleUnit source)
 {
     QueuedActions.ImmediateAction("TauntEnemy", () =>
     {
         var eligibleAttackIntents = target.CurrentIntents.Where(item => item is SingleUnitAttackIntent);
         foreach (var intent in eligibleAttackIntents)
         {
             // remove one unit from list (which should be all of them, since these are single-unit-attack-intents), add source
             intent.UnitsTargeted.RemoveAt(0);
             intent.UnitsTargeted.Add(source);
         }
     });
 }
Exemplo n.º 22
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);
 }
Exemplo n.º 23
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);
 }
Exemplo n.º 24
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);
 }
Exemplo n.º 25
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);
    }
Exemplo n.º 26
0
 public void AttackUnitForDamage(AbstractBattleUnit targetUnit, AbstractBattleUnit sourceUnit, int baseDamageDealt, AbstractCard cardPlayed)
 {
     Require.NotNull(targetUnit);
     QueuedActions.DelayedActionWithCustomTrigger("AttackUnitForDamage_ShakeUnit", () => {
         if (targetUnit.IsDead || sourceUnit.IsDead)
         {
             // do nothing if it's already dead
             IsCurrentActionFinished = true;
             return;
         }
         targetUnit.CorrespondingPrefab.gameObject.AddComponent <ShakePrefab>();
         var shakePrefab = targetUnit.CorrespondingPrefab.gameObject.GetComponent <ShakePrefab>();
         shakePrefab.Begin(() => { IsCurrentActionFinished = true; });
         targetUnit.CorrespondingPrefab.FlickerFeedbacks.PlayFeedbacks();
         BattleRules.ProcessDamageWithCalculatedModifiers(sourceUnit, targetUnit, cardPlayed, baseDamageDealt);
     });
 }
Exemplo n.º 27
0
 public void PerformAdvanceActionIfPossible(AbstractBattleUnit unit)
 {
     QueuedActions.ImmediateAction("PerformAdvanceActionIfPossible", () =>
     {
         if (gameState.energy > 0)
         {
             gameState.energy--;
         }
         else
         {
             EnergyIcon.Instance.Flash();
             Shout(unit, "Not enough energy!");
             return;
         }
         unit.StatusEffects.Add(new AdvancedStatusEffect());
     });
 }
Exemplo n.º 28
0
    public CardSelectionFuture PromptDiscardOfSingleCard()
    {
        var future = new CardSelectionFuture();

        QueuedActions.DelayedActionWithFinishTrigger("Discard Prompt",
                                                     // starting action
                                                     () =>
        {
            if (GameState.Instance.Deck.Hand.Count == 0)
            {
                return;
            }
            SelectCardInHandOverlay.ShowPromptForCardSelection(new DiscardCardsBehavior(), future);
        },
                                                     // finish trigger
                                                     () =>
        {
            return(future.IsReady);
        });
        return(future);
    }
Exemplo n.º 29
0
    public void Shout(AbstractBattleUnit unit, string stuffToSay)
    {
        QueuedActions.ImmediateAction("Shout", () =>
        {
            var speechBubbleText = unit.CorrespondingPrefab.SpeechBubbleText;
            var bubbleImg        = unit.CorrespondingPrefab.SpeechBubble;
            bubbleImg.gameObject.AddComponent <AppearDisappearImageAnimationPrefab>();
            var appearDisappearPrefab = bubbleImg.gameObject.GetComponent <AppearDisappearImageAnimationPrefab>();
            appearDisappearPrefab.Begin(thingToDoAfterFadingIn: () => {
                speechBubbleText.gameObject.SetActive(true);
                speechBubbleText.SetText(stuffToSay);
            }, thingToDoBeforeFadingOut: () =>
            {
                speechBubbleText.gameObject.SetActive(false);
            });

            ParticleSystemSpawner.Instance.PlaceParticleSystem(
                ProtoParticleSystem.GreenSlash,
                unit.CorrespondingPrefab.transform as RectTransform
                );
        });
    }
Exemplo n.º 30
0
    public void ApplyStatusEffect(AbstractBattleUnit unit, AbstractStatusEffect attribute, int stacks = 1)
    {
        if (unit == null)
        {
            throw new Exception("No unit specified");
        }

        if (attribute == null)
        {
            throw new Exception("No attribute specified");
        }

        if (stacks == 0)
        {
            return;
        }

        QueuedActions.ImmediateAction("ApplyStatusEffect", () =>
        {
            unit.ApplyStatusEffect(attribute, stacks);
        });
    }