コード例 #1
0
        public bool UseCard(ICard card, Vector3 targetPosition)
        {
            int index = CardDeck.IndexOf(card);

            if (index > 4)
            {
                throw new Exception("Card is outside of the useable range");
            }

            if (card.WBCCost > m_whiteBloodCells)
            {
                Debug.Log("White blood cell count is too low to instantiate " + card.Name);
                return(false);
            }

            m_whiteBloodCells -= card.WBCCost;

            Instantiate(card.gameObject, targetPosition, Quaternion.identity);

            if (!card.OneTimeUse)               //reinsert the used card at the bottom of the deck
            {
                CardDeck.Insert(Random.Range(7, CardDeck.Count), card);
            }

            //move the next card (index 5) to the index
            CardDeck[index] = CardDeck[5];
            CardDeck.RemoveAt(5);

            OnCardDeckChanged?.Invoke(CardDeck);

            return(true);
        }
コード例 #2
0
 public void SetCardDeck(List <ICard> cards)
 {
     CardDeck = cards;
     OnCardDeckChanged?.Invoke(CardDeck);
 }