//设置公式一升段素材
    void SetFormulaOneMaterial(GradeUpRequireInfo info, CSItem card)
    {
        SetCostMoney(info.Formula1_Cost);//设置公式一升段所需金钱
        //设置素材卡牌头像 与 段位升级卡头像相同
        UICardHead tempCardHead = UICardHead.Create();

        m_materialList.Add(tempCardHead);//加入到素材列表
        tempCardHead.SetParent(m_materialSpritList[0].transform);
        tempCardHead.SetLocalPosition(Vector3.zero);
        //获得公式一卡牌
        CSItem materialCard = User.Singleton.ItemBag.GetCardBuyIdCardDivisionFormula(card);

        CardDivisionUpdateProp.Singleton.AddMaterialCard(materialCard);
        if (null == materialCard)           //如果背包里只有一张升段卡牌或者没有所需卡牌时
        {
            tempCardHead.SetCardMask(true); //素材显示黑色遮罩
            //升段确定按钮不可点击
            m_buttonOk.isEnabled = false;
            //如果背包里面没有这张卡则创建一张只带有ID的卡牌从表里读取信息
            CSItem tempCard = new CSItem();
            tempCard.m_id = card.m_id;
            tempCardHead.SetCardInfo(tempCard);
        }
        else
        {
            m_materialSpritList[0].GetComponent <Parma>().m_type = 1;
            //如果表里有这张卡 则显示素材卡信息
            tempCardHead.SetCardInfo(materialCard);
        }
        tempCardHead.RegisterCallBack(null, PressCardHead);
        tempCardHead.ShowCard();
        tempCardHead.SetCardInfoShow(false);
        tempCardHead.SetCardLoveShow(false);
    }
Example #2
0
    //设置卡牌晋级的素材卡牌
    void SetMaterial(CSItem card)
    {
        HeroInfo info = GameTable.HeroInfoTableAsset.Lookup(card.IDInTable);

        if (null == info)
        {
            Debug.Log("UICardEvolution HeroInfo == null card.m_id:" + card.IDInTable);
            return;
        }

        Dictionary <int, int> evolveCardList = new Dictionary <int, int>();

        foreach (var cardID in info.EvolveCardList)
        {
            if (evolveCardList.ContainsKey(cardID))
            {
                ++evolveCardList[cardID];
            }
            else
            {
                evolveCardList.Add(cardID, 1);
            }
        }
        int spritIndex = 0;

        foreach (KeyValuePair <int, int> item in evolveCardList)
        {
            //设置添加素材卡牌头像
            UICardHead tempHead = UICardHead.Create();
            m_materialList.Add(tempHead);//加入到素材列表
            tempHead.SetParent(m_materialSpritList[spritIndex].transform);
            tempHead.SetLocalPosition(Vector3.zero);
            tempHead.RegisterCallBack(null, PressCardHead);
            CSItem tempCard = new CSItem();
            tempCard.m_id = (short)item.Key;
            tempHead.SetCardInfo(tempCard);
            tempHead.ShowCard();
            tempHead.SetCardLoveShow(false);
            //根据需要素材个数显示文字颜色
            int cardCount = User.Singleton.ItemBag.GetCardNumById(item.Key);
            tempHead.m_cardInfo.text = string.Format(Localization.Get("WithTheMaterial"), cardCount);
            if (cardCount >= item.Value)
            {
                tempHead.m_cardInfo.color = Color.green;//显示 绿色文字
            }
            else
            {
                tempHead.m_cardInfo.color = Color.red;//显示红色文字 显示 透明遮罩
                tempHead.SetCardMask(true);
            }
            spritIndex++;
        }
    }
    //添加指定卡牌素材
    void AddAppointCard(UISprite sprite, FormulaParam param, int index)
    {
        UICardHead tempHead = UICardHead.Create();

        m_materialList.Add(tempHead);//加入到素材列表
        tempHead.SetParent(sprite.transform);
        tempHead.SetLocalPosition(Vector3.zero);
        tempHead.RegisterCallBack(null, PressCardHead);
        CSItem tempCard = new CSItem();

        tempCard.m_id = (short)param.paramId;
        tempHead.SetCardInfo(tempCard);

        tempHead.ShowCard();
        tempHead.SetCardLoveShow(false);

        //获得这张ID的卡牌在背包中有多少张
        int cardCount = User.Singleton.ItemBag.GetCardNumById(param.paramId);

        tempHead.m_cardInfo.text = string.Format(Localization.Get("WithTheMaterial"), cardCount);
        int tempCardCount = cardCount;

        foreach (UICardHead item in m_materialList)
        {
            if (item != tempHead && tempHead.m_showCard.m_id == param.paramId)
            {
                tempCardCount--;
            }
            if (item == tempHead)
            {
                if (tempCardCount > 0)
                {
                    tempHead.m_cardInfo.color = Color.green;
                }
                else
                {
                    tempHead.m_cardInfo.color = Color.red;
                    tempHead.SetCardMask(true);
                }
            }
        }
    }