예제 #1
0
    /// <summary>
    /// 刷新上阵卡牌信息
    /// </summary>
    /// <param name="item"></param>
    void UpdateCardFightGrid(UIGridItem item)
    {
        if (item == null || item.oData == null || item.mScripts == null)
        {
            return;
        }
        CardDataMsg info = item.oData as CardDataMsg;

        UILabel   nofight   = item.mScripts[0] as UILabel;
        UILabel   fight     = item.mScripts[1] as UILabel;
        UILabel   cardName  = item.mScripts[2] as UILabel;
        UITexture head      = item.mScripts[3] as UITexture;
        UILabel   skillType = item.mScripts[4] as UILabel;

        nofight.gameObject.SetActive(info.configId < 4);
        fight.gameObject.SetActive(info.configId > 4);
        item.name = "fight" + item.miCurIndex;
        if (fight.gameObject.activeSelf)
        {
            TD_Card card = CardConfig.GetItem(info.configId);
            cardName.text = card.name;
            LoadSprite.LoaderCard(head, card.res);
            skillType.text = UtilTools.GetSKillTypeName((int)card.type);
        }
    }
예제 #2
0
    /// <summary>
    /// 更换上阵卡牌
    /// </summary>
    /// <param name="card"></param>
    /// <param name="index"></param>
    public void ChangeFightCard(int index)
    {
        CardDataMsg info = panel.fightGrid.GetCustomDataItem(index) as CardDataMsg;
        CardMsg     msg  = null;

        // 此位置无上阵卡牌
        if (info.configId < 4)
        {
            msg = new CardMsg
            {
                teamUUid     = cardInfoList.teamId,
                teamHeroUUid = cardInfoList.heroId,
                oldCardId    = 0,
                newCardId    = changeCardId,
            };
        }
        // 此位置有上阵卡牌,进行替换
        else
        {
            msg = new CardMsg
            {
                teamUUid     = cardInfoList.teamId,
                teamHeroUUid = cardInfoList.heroId,
                oldCardId    = info.configId,
                newCardId    = changeCardId,
            };
            TD_Card card = null;
            for (int i = 0; i < listObj.Count; ++i)
            {
                card = listObj[i] as TD_Card;
                if (card.id == info.configId)
                {
                    card.isFight = 0;
                    panel.cardGrid.UpdateCustomData(card);
                }
            }
            HeroTeamMediator.heroTeamMediator.dropInfo.skillID.Remove(info.configId);
        }
        HeroTeamMediator.heroTeamMediator.dropInfo.skillID.Add(changeCardId);
        NSocket.GetInstance().SendData(Request.CardEnterTeamReq, msg);
        info.configId    = changeCardId;
        info.isFight     = 1; // 上阵的卡牌
        drapCard.isFight = 1;
        int fightCount = UtilTools.IntParse(panel.cardCount.text.Split('/')[0]) + 1;

        panel.cardCount.text = string.Format("{0}/{1}", fightCount, cardInfoList.cardList.Count);
        panel.fightGrid.UpdateCustomData(info);
        panel.cardGrid.UpdateCustomData(drapCard);
        HeroTeamMediator.heroTeamMediator.panel.cardGrid.UpdateCustomData(HeroTeamMediator.heroTeamMediator.dropInfo);
    }
예제 #3
0
    /// <summary>
    /// 刷新卡组信息
    /// </summary>
    /// <param name="hero"></param>
    void UpdateCardTeamInfo(TD_Hero hero)
    {
        for (int i = 0; i < cardInfoList.cardList.Count; ++i)
        {
            TD_Card card = CardConfig.GetItem(cardInfoList.cardList[i].configId);
            card.isFight = cardInfoList.cardList[i].isFight;
            card.isHave  = 1;
            cardList.Add(card);
        }

        CardDataMsg info = null;

        for (int i = 0; i < hero.card_list.Split(';').Length; ++i)
        {
            int id = hero.card_list.Split(';')[i].ToInt();
            info = CheckCardIsHave(id);

            if (info != null)
            {
                continue;
            }
            TD_Card card = CardConfig.GetItem(id);
            card.isFight = 0;
            card.isHave  = 0;
            cardList.Add(card);
        }

        listObj = new List <object>();
        for (int i = 0; i < cardList.Count; ++i)
        {
            listObj.Add(cardList[i]);
        }

        panel.cardGrid.AddCustomDataList(listObj);

        List <object> list = new List <object>();

        for (int i = 0; i < cardInfoList.cardList.Count; ++i)
        {
            if (cardInfoList.cardList[i].isFight == 1)
            {
                list.Add(cardInfoList.cardList[i]);
            }
        }
        if (list.Count < 4)
        {
            for (int i = 0; i < 4; ++i)
            {
                if (i >= list.Count)
                {
                    CardDataMsg data = new CardDataMsg
                    {
                        configId = i,
                    };
                    list.Add((object)data);
                }
            }
        }
        panel.fightGrid.AddCustomDataList(list);
        list.Clear();

        if (panel.cardGrid.mDataSource.Count % 6 == 0)
        {
            dragIndex = panel.cardGrid.mDataSource.Count / 6;
            dragIndex--;
        }
        else
        {
            dragIndex = Mathf.FloorToInt(panel.cardGrid.mDataSource.Count * 1.0f / 6);
        }
    }