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); }
/* * 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)); }); }
public void EndBattleTurn() { QueuedActions.ImmediateAction("EndBattleTurn", () => { turnEndActions.EndTurn(); }); }
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 AddStickerToCard(AbstractCard card, AbstractCardSticker stickerToAdd) { QueuedActions.ImmediateAction("AddStickerToCard", () => { card.AddSticker(stickerToAdd); }); }
public void Advance(AbstractBattleUnit unit) { QueuedActions.ImmediateAction("Advance", () => { unit.StatusEffects.Add(new AdvancedStatusEffect()); }); }
public void CheckIsBattleOver() { QueuedActions.ImmediateAction("CheckIsBattleOver", () => { BattleRules.CheckIsBattleOverAndIfSoSwitchScenes(); }); }
public void UpgradeCard(AbstractCard card) { QueuedActions.ImmediateAction("UpgradeCard", () => { card.Upgrade(); }); }
public void TickDownStatusEffect <T>(AbstractBattleUnit unit) where T : AbstractStatusEffect { QueuedActions.ImmediateAction("TickDownStatusEffect", () => { unit.TickDownStatusEffect <T>(); }); }
/// <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); }
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; }
public void KillUnit(AbstractBattleUnit unit) { QueuedActions.ImmediateAction("KillUnit", () => { unit.CurrentHp = 0; BattleRules.CheckAndRegisterDeath(unit, null, null); }); }
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 ChangeUnit(AbstractBattleUnit unit, Action <AbstractBattleUnit> action) { Require.NotNull(unit); QueuedActions.ImmediateAction("ChangeUnit", () => { action(unit); }); }
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 FallBack(AbstractBattleUnit unit) { QueuedActions.ImmediateAction("FallBack", () => { if (unit.HasStatusEffect <AdvancedStatusEffect>()) { unit.RemoveStatusEffect <AdvancedStatusEffect>(); } }); }
public void DiscardHand() { QueuedActions.ImmediateAction("DiscardHand", () => { var hand = ServiceLocator.GameState().Deck.Hand.ToList(); foreach (var card in hand) { DiscardCard(card); } }); }
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; } }); }
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); }
// 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); }); }
/// <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); } }); }
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); }
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); }
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); }
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 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); }); }
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()); }); }
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); }
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 ); }); }
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); }); }