public bool AddCard(EntityDef cardEntityDef, CardFlair cardFlair, DeckTrayDeckTileVisual deckTileToRemove, bool playSound, Actor animateFromActor = null) { if (!base.IsModeActive()) { return(false); } if (cardEntityDef == null) { UnityEngine.Debug.LogError("Trying to add card EntityDef that is null."); return(false); } string cardId = cardEntityDef.GetCardId(); CollectionDeck taggedDeck = CollectionManager.Get().GetTaggedDeck(this.m_deckType); if (taggedDeck == null) { return(false); } if (playSound) { SoundManager.Get().LoadAndPlay("collection_manager_place_card_in_deck", base.gameObject); } if (taggedDeck.GetTotalCardCount() == 30) { if (deckTileToRemove == null) { UnityEngine.Debug.LogWarning(string.Format("CollectionDeckTray.AddCard(): Cannot add card {0} (flair {1}) without removing one first.", cardEntityDef.GetCardId(), cardFlair)); return(false); } string cardID = deckTileToRemove.GetCardID(); CardFlair flair = deckTileToRemove.GetCardFlair(); if (!taggedDeck.RemoveCard(cardID, flair.Premium, deckTileToRemove.IsOwnedSlot())) { object[] args = new object[] { cardId, cardFlair, cardID, flair }; UnityEngine.Debug.LogWarning(string.Format("CollectionDeckTray.AddCard({0},{1}): Tried to remove card {2} with flair {3}, but it failed!", args)); return(false); } } if (!taggedDeck.AddCard(cardEntityDef, cardFlair.Premium)) { UnityEngine.Debug.LogWarning(string.Format("CollectionDeckTray.AddCard({0},{1}): deck.AddCard failed!", cardId, cardFlair)); return(false); } if (taggedDeck.GetTotalOwnedCardCount() == 30) { DeckHelper.Get().Hide(); } this.UpdateCardList(cardEntityDef, true, animateFromActor); CollectionManagerDisplay.Get().UpdateCurrentPageCardLocks(true); if ((!Options.Get().GetBool(Option.HAS_ADDED_CARDS_TO_DECK, false) && (taggedDeck.GetTotalCardCount() >= 2)) && (!DeckHelper.Get().IsActive() && (taggedDeck.GetTotalCardCount() < 15))) { NotificationManager.Get().CreateInnkeeperQuote(GameStrings.Get("VO_INNKEEPER_CM_PAGEFLIP_28"), "VO_INNKEEPER_CM_PAGEFLIP_28", 0f, null); Options.Get().SetBool(Option.HAS_ADDED_CARDS_TO_DECK, true); } return(true); }
public bool GrabCard(DeckTrayDeckTileVisual deckTileVisual) { Actor actor = deckTileVisual.GetActor(); if (!this.CanGrabItem(actor)) { return(false); } if (!this.m_heldCardVisual.ChangeActor(actor, CollectionManagerDisplay.ViewMode.CARDS)) { return(false); } this.m_scrollBar.Pause(true); PegCursor.Get().SetMode(PegCursor.Mode.DRAG); this.m_heldCardVisual.SetSlot(deckTileVisual.GetSlot()); this.m_heldCardVisual.transform.position = actor.transform.position; this.m_heldCardVisual.Show(this.m_mouseIsOverDeck); SoundManager.Get().LoadAndPlay("collection_manager_pick_up_card", this.m_heldCardVisual.gameObject); CollectionDeckTray.Get().RemoveCard(this.m_heldCardVisual.GetCardID(), this.m_heldCardVisual.GetCardFlair(), deckTileVisual.IsOwnedSlot()); return(true); }