Пример #1
0
    //
    IEnumerator CoroutinePrizeCard()
    {
        yield return(new WaitForSeconds(0));

//         BattleArena.Singleton.DropCardsIdList.Add(2);
//         BattleArena.Singleton.DropCardsIdList.Add(4);
//         BattleArena.Singleton.DropCardsIdList.Add(5);
//         BattleArena.Singleton.DropCardsIdList.Add(5);
//
//         BattleSummary.Singleton.SummaryGetNewCard(2);
//         BattleSummary.Singleton.SummaryGetNewCard(4);
//         BattleSummary.Singleton.SummaryGetNewCard(5);
//         BattleSummary.Singleton.SummaryGetNewCard(5);

        foreach (int cardId in BattleArena.Singleton.DropCardsIdList)
        {
            GameObject item = GameObject.Instantiate(m_prizeCard) as GameObject;

            item.transform.parent = m_cardGrid.transform;

            item.transform.localPosition = Vector3.zero;
            item.transform.localScale    = Vector3.one;

            int id = cardId;

            // 容错卡牌ID
            if (GameTable.HeroInfoTableAsset.Lookup(id) == null)
            {
                id = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enDefaultCardId).IntTypeValue;
            }

            bool bNew = BattleSummary.Singleton.IsNewCard(id);

            // 如果是新的
            item.transform.Find("New").gameObject.SetActive(bNew);

            Debug.Log(bNew);

            UICardHead tempHead = UICardHead.Create();

            tempHead.SetParent(item.transform);
            tempHead.SetLocalPosition(Vector3.zero);
            tempHead.RegisterCallBack(PressCardHead, null);
            CSItem tempCard = new CSItem();
            tempCard.m_id  = (short)id;
            tempCard.Level = 1;
            tempHead.SetCardInfo(tempCard);
            tempHead.SetCardLoveShow(false);
            tempHead.SetCardInfoShow(false);
            tempHead.SetCardNew(bNew);
            tempHead.HideWindow();


            item.SetActive(false);

            m_prizeCardList.Add(item, tempHead);
            m_prizeCardDataList.Add(item, tempHead);
        }

        m_cardGrid.GetComponent <UIGrid>().Reposition();


        // 先显示
        foreach (KeyValuePair <GameObject, UICardHead> item in m_prizeCardList)
        {
            item.Key.SetActive(true);

            // 如果快速
            if (BattleSummary.Singleton.m_fastPrizeCard)
            {
                yield return(new WaitForSeconds(0f));
            }
            else
            {
                yield return(new WaitForSeconds(0.5f));
            }
        }

        // 再一个一个播动画
        MainGame.Singleton.StartCoroutine(CoroutinePlayAnmiationPrizeCard());
    }