Exemple #1
0
 private void AddToDeckFromPool(Card card, Transform target, bool isMain)
 {
     if (waitToUseList.Count == 0)
     {
         GameObject obj      = ComMethod.InitGameObject(cardPrefeb, target);
         Card_Edit  editCard = obj.GetComponent <Card_Edit>();
         editCard.Init();
         editCard.SetTexture(card.cardID, true);
         if (isMain)
         {
             mainDeckList.Add(obj);
         }
         else
         {
             extraDeckList.Add(obj);
         }
     }
     else
     {
         GameObject obj = waitToUseList[0];
         waitToUseList.RemoveAt(0);
         Card_Edit editCard = obj.GetComponent <Card_Edit>();
         obj.GetComponent <RectTransform>().anchoredPosition3D = Vector3.zero;
         editCard.SetTexture(card.cardID, true);
         obj.transform.SetParent(target);
         if (isMain)
         {
             mainDeckList.Add(obj);
         }
         else
         {
             extraDeckList.Add(obj);
         }
     }
 }
Exemple #2
0
    /// <summary>
    /// 显示卡组
    /// <para>这会隐藏已存在的卡片</para>
    /// </summary>
    /// <param name="deck"></param>
    public void ShowDeck(Deck deck)
    {
        curDeck = deck;
        Group mainGroup  = curDeck.mainDeck;
        Group extraGroup = curDeck.extraDeck;

        for (int i = 0; i < mainGroup.cardList.Count; i++)
        {
            Card theCard = mainGroup.cardList[i];

            if (i < mainDeckList.Count)
            {
                Card_Edit theCard_edit = mainDeckList[i].GetComponent <Card_Edit>();
                theCard_edit.SetTexture(theCard.cardID, true);
                theCard_edit.SetActive(true);
            }
            else
            {
                GameObject obj  = ComMethod.InitGameObject(cardPrefeb, mainDeckGroup.transform);
                Card_Edit  card = obj.GetComponent <Card_Edit>();
                card.Init();

                card.SetTexture(theCard.cardID, true);
                mainDeckList.Add(obj);
            }
        }
        for (int i = 0; i < extraGroup.cardList.Count; i++)
        {
            Card theCard = extraGroup.cardList[i];

            if (i < extraDeckList.Count)
            {
                Card_Edit theCard_edit = extraDeckList[i].GetComponent <Card_Edit>();
                theCard_edit.SetTexture(theCard.cardID, true);
                theCard_edit.SetActive(true);
            }
            else
            {
                GameObject obj  = ComMethod.InitGameObject(cardPrefeb, extraDeckGroup.transform);
                Card_Edit  card = obj.GetComponent <Card_Edit>();
                card.Init();

                card.SetTexture(theCard.cardID, true);
                extraDeckList.Add(obj);
            }
        }

        if (mainDeckList.Count > mainGroup.cardList.Count)
        {
            for (int i = mainGroup.cardList.Count; i < mainDeckList.Count; i++)
            {
                RemoveAtMainDeck(i);
                i--;
            }
        }
        if (extraDeckList.Count > extraGroup.cardList.Count)
        {
            for (int i = extraGroup.cardList.Count; i < extraDeckList.Count; i++)
            {
                RemoveAtExtraDeck(i);
                i--;
            }
        }
        UpdateText();
    }