static void Postfix(ref CardFrameUI __instance, CardState cardState, List <AbstractSpriteSelector> ___spriteSelectors) { try { if (cardState.GetLinkedClassID() == null) { return; } List <Sprite> cardFrame; if (CustomClassManager.CustomClassFrame.TryGetValue(cardState.GetLinkedClassID(), out cardFrame)) { foreach (AbstractSpriteSelector spriteSelector in ___spriteSelectors) { switch (spriteSelector) { case ClassSpriteSelector classSpriteSelector: foreach (var image in classSpriteSelector.gameObject.GetComponents <Image>()) { image.sprite = cardState.GetCardType() == CardType.Monster ? cardFrame[0] : cardFrame[1]; } continue; } } } } catch (Exception) { Trainworks.Log(BepInEx.Logging.LogLevel.Error, "TryGetValue is a dumb function."); } }
public static void OnPlayedCard( CardState cardState, int roomIndex, SpawnPoint dropLocation, CombatManager.ApplyPreEffectsVfxAction onPreEffectsFiredVfx, CombatManager.ApplyEffectsAction onEffectsFired) { if (cardState.GetCardType() != CardType.Spell) { return; } // Gotta check and make sure it's not a consume or purge card. Avoid crashes RelicManager relicManager; ProviderManager.TryGetProvider <RelicManager>(out relicManager); if (cardState.GetDiscardEffectWhenPlayed(relicManager, null) != HandUI.DiscardEffect.Default) { return; } // Make sure we're on the same floor as the Owner MonsterManager monsterManager; ProviderManager.TryGetProvider <MonsterManager>(out monsterManager); List <CharacterState> units = new List <CharacterState>(); monsterManager.AddCharactersInRoomToList(units, roomIndex); bool ret = true; foreach (var unit in units) { foreach (var mod in unit.GetRoomStateModifiers()) { if (mod is RoomStateModifierRewind) { ret = false; } } } if (ret) { return; } // Get the provider and do the effect CardManager cardManager; ProviderManager.TryGetProvider <CardManager>(out cardManager); if (cardManager.GetCardStatistics().GetNumCardsPlayedThisTurnOfType(CardType.Spell) < numOfCards) { var corountine = RedrawCard(cardState, cardManager.GetHand().Count); cardManager.StartCoroutine(corountine); } }
public IEnumerator ApplyConsume(CardState card) { yield return(new WaitForSeconds(0.01f)); // Check and see if we're a starter card foreach (var clan in ProviderManager.SaveManager.GetAllGameData().GetAllClassDatas()) { for (int i = 0; i < 2; i++) { if (card.GetCardDataID() == clan.GetChampionData(i).starterCardData.GetID() && card.GetCardType() == CardType.Spell) { cardManager.AddTemporaryTraitToCard(card, new CardTraitData { traitStateName = "CardTraitExhaustState" }); cardManager.RefreshCardInHand(card); card.RefreshCardBodyTextLocalization(); cardsWeHaveModified.Add(card); } } } yield break; }
public static bool IsCardStarterSpell(CardState card) { foreach (var clan in ProviderManager.SaveManager.GetAllGameData().GetAllClassDatas()) { for (int i = 0; i < 2; i++) { // If we find any match, return true if (card.GetCardDataID() == clan.GetChampionData(i).starterCardData.GetID() && card.GetCardType() == CardType.Spell) { return(true); } } } return(false); }