public bool AddAtIndex(Card card, int index)
 {
     if (Cards[index] != null)
     {
         return(false);
     }
     else
     {
         Cards[index] = card;
         if (OnCardChangedCallback != null)
         {
             OnCardChangedCallback.Invoke();
         }
         return(true);
     }
 }
Beispiel #2
0
 public bool AddCard(int cardRecordID, int positionIndex)
 {
     if (fieldCardDictionary.ContainsKey(cardRecordID))
     {
         return(false);
     }
     if (DisplayCheck(positionIndex))
     {
         FieldCardRecord record = new FieldCardRecord {
             CardRecordID = cardRecordID, PositionIndex = positionIndex
         };
         foreach (var targetCard in FieldCards)
         {
             if (targetCard.PositionIndex >= positionIndex)
             {
                 targetCard.PositionIndex++;
                 OnCardChanged?.Invoke(targetCard, DataChangeCode.Update);
             }
         }
         fieldCardDictionary.Add(cardRecordID, record);
         OnCardChanged?.Invoke(record, DataChangeCode.Add);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #3
0
 public bool AddCard(Card card)
 {
     if (card == null || TotalCardCount >= MaxCardCount)
     {
         return(false);
     }
     else if (card.Rarity == RarityCode.Legendary)
     {
         if (CardCount(card.CardID) >= 1)
         {
             return(false);
         }
         else
         {
             cards.Add(card);
             OnCardChanged?.Invoke(this, card, DataChangeCode.Add);
             return(true);
         }
     }
     else
     {
         if (CardCount(card.CardID) >= 2)
         {
             return(false);
         }
         else
         {
             cards.Add(card);
             OnCardChanged?.Invoke(this, card, DataChangeCode.Add);
             return(true);
         }
     }
 }
Beispiel #4
0
 public void LoadCard(CardRecord card)
 {
     if (cardDictionary.ContainsKey(card.CardRecordID))
     {
         cardDictionary[card.CardRecordID] = card;
         OnCardChanged?.Invoke(card, DataChangeCode.Update);
     }
     else
     {
         cardDictionary.Add(card.CardRecordID, card);
         OnCardChanged?.Invoke(card, DataChangeCode.Add);
     }
 }
Beispiel #5
0
    void Start()
    {
        /* Set up the default cards ONLY */
        for (int i = 0; i < defaultCards.Length; i++)
        {
            cards.Add(defaultCards[i]);
        }

        PlayerData.Instance.LoadPlayerCard();

        for (int i = 0; i < cards.Count; i++)
        {
            cards[i].SetupSlimeProperties();
        }

        if (onCardChangedCallback != null)
        {
            onCardChangedCallback.Invoke();
        }

        //Load player saved card deck
        PlayerData.Instance.LoadPlayerCardDeck();
    }
Beispiel #6
0
 public bool UpdateCard(int cardRecordID, int positionIndex)
 {
     if (fieldCardDictionary.ContainsKey(cardRecordID))
     {
         FieldCardRecord record = fieldCardDictionary[cardRecordID];
         record.PositionIndex = positionIndex;
         OnCardChanged?.Invoke(record, DataChangeCode.Update);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #7
0
 public bool RemoveCard(int cardID)
 {
     if (CardCount(cardID) > 0)
     {
         int  index = cards.FindIndex(x => x.CardID == cardID);
         Card card  = cards[index];
         cards.RemoveAt(index);
         OnCardChanged?.Invoke(this, card, DataChangeCode.Remove);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #8
0
 public bool RemoveCard(int cardRecordID)
 {
     if (fieldCardDictionary.ContainsKey(cardRecordID))
     {
         FieldCardRecord record = fieldCardDictionary[cardRecordID];
         fieldCardDictionary.Remove(record.CardRecordID);
         OnCardChanged?.Invoke(record, DataChangeCode.Remove);
         foreach (var targetCard in FieldCards)
         {
             if (targetCard.PositionIndex >= record.PositionIndex)
             {
                 targetCard.PositionIndex--;
                 OnCardChanged?.Invoke(targetCard, DataChangeCode.Update);
             }
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #9
0
        private void setDeckCard(int Idx, TriadCard card, bool previewOnly)
        {
            if (deck != null)
            {
                deck.SetCard(Idx, card);
            }

            CardCtrl updatedCtrl = cardCtrls[Idx];

            if (updatedCtrl.GetCard() != card)
            {
                updatedCtrl.SetCard(new TriadCardInstance(card, deckOwner));
            }

            if (OnCardChanged != null)
            {
                OnCardChanged.Invoke(cardCtrls[Idx].GetCardInst(), Idx, previewOnly);
            }

            updatedCtrl.UpdateBackColor();
            updatedCtrl.Invalidate();
        }
Beispiel #10
0
 public void ChangeCounters(int delta)
 {
     Counters += delta;
     Debug.Log("counters changed, new total = " + Counters);
     OnCardChanged?.Invoke();
 }
 private void Next()
 {
     OnCardChanged?.Invoke(this, new EventArgs());
 }
Beispiel #12
0
 public void Neutralize()
 {
     _isNeutralised = true;
     OnCardChanged?.Invoke();
 }