Пример #1
0
    // 更新单个格子 为队伍编辑
    void UpdateTeamItem(CSItem card, Team.EDITTYPE type)
    {
        if (null != card && !SortByOccRace(card.IDInTable))
        {
            // 格子不够增加格子
            if (false == m_gridList.ContainsKey(m_tempIndex))
            {
                ExpandOneGrid();
            }

            UICardItem item = m_gridList[m_tempIndex];

            HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(card.IDInTable);
            if (null == heroInfo)
            {
                Debug.LogWarning("UpdateTeamItem null == heroInfo item.IDInTable:" + card.IDInTable);
            }
            else
            {
                OperateCardList.Singleton.m_leadShipCost = OperateCardList.Singleton.m_leadShipCost + heroInfo.Cost;
                item.UpdateOperateTeam(card, m_cardSortUI.GetLastSortType(), type, m_tempIndex);
                OperateCardList.Singleton.m_hadItemList.Add(card.Guid);
            }
            m_tempIndex++;
        }
    }
Пример #2
0
    //  点击响应
    public void OnClickTeamItem(UICardItem item, ENSortType sortType)
    {
        int    leadship = 0;
        CSItem card     = null;

        // 编辑全队
        if (Team.Singleton.m_curEditType == Team.EDITTYPE.enALL)
        {
            // 要判断领导力
            // 不在编队中
            if (item.m_param.m_id == (int)Team.EDITTYPE.enNone)
            {
                // 点选角色
                card = CardBag.Singleton.GetCardByGuid(item.m_param.m_guid);

                if (null != card)
                {
                    leadship = Team.Singleton.GetAllCost() + GameTable.HeroInfoTableAsset.Lookup(card.IDInTable).Cost;
                }
                // 如果领导力不够 则返回
                if (leadship > User.Singleton.GetLeadership())
                {
                    return;
                }

                Team.EDITTYPE type = Team.EDITTYPE.enNone;

                if (Team.Singleton.m_bagMainSlotId.Equals(CSItemGuid.Zero))
                {
                    Team.Singleton.m_bagMainSlotId = item.m_param.m_guid;
                    type = Team.EDITTYPE.enMain;
                }

                else if (Team.Singleton.m_bagDeputySlotId == CSItemGuid.Zero)
                {
                    Team.Singleton.m_bagDeputySlotId = item.m_param.m_guid;
                    type = Team.EDITTYPE.enDeputy;
                }

                else if (Team.Singleton.m_bagSupportSlotId == CSItemGuid.Zero)
                {
                    Team.Singleton.m_bagSupportSlotId = item.m_param.m_guid;
                    type = Team.EDITTYPE.enSupport;
                }

                item.m_param.m_id = (int)type;

                item.UpdateOperateTeam(card, sortType, type, item.m_index);
            }
            // 在编队中
            else
            {
                if (item.m_param.m_id == (int)Team.EDITTYPE.enMain)
                {
                    Team.Singleton.m_bagMainSlotId = CSItemGuid.Zero;
                    item.m_param.m_id = (int)Team.EDITTYPE.enNone;
                }
                else if (item.m_param.m_id == (int)Team.EDITTYPE.enDeputy)
                {
                    Team.Singleton.m_bagDeputySlotId = CSItemGuid.Zero;
                    item.m_param.m_id = (int)Team.EDITTYPE.enNone;
                }
                else if (item.m_param.m_id == (int)Team.EDITTYPE.enSupport)
                {
                    Team.Singleton.m_bagSupportSlotId = CSItemGuid.Zero;
                    item.m_param.m_id = (int)Team.EDITTYPE.enNone;
                }

                item.UpdateOperateTeam(card, sortType, Team.EDITTYPE.enNone, item.m_index);
            }
        }
        // 编辑单个队伍
        else
        {
            // 如果是移除标志位 则移除当前 队伍成员
            if (item.m_param.m_id == -1)
            {
                Team.Singleton.RemoveTeamMember(Team.Singleton.m_curTeamIndex, Team.Singleton.m_curEditType);
                Team.Singleton.UpdateTeamBagAllSlotId();
                return;
            }

            // 如果是当前队伍中的队伍成员 则返回
            if (Team.Singleton.IsCardInTheTeam(Team.Singleton.m_curTeamIndex, item.m_param.m_guid))
            {
                return;
            }

            card = CardBag.Singleton.GetCardByGuid(item.m_param.m_guid);
            HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(card.IDInTable);

            if (null == heroInfo)
            {
                Debug.LogWarning("null == heroInfo card.IDInTable:" + card.IDInTable);
                return;
            }


            // 将要被替换角色的领导力
            CSItem replaceCard = Team.Singleton.GetCard(Team.Singleton.m_curTeamIndex, Team.Singleton.m_curEditType);
            int    replaceCost = 0;
            if (null != replaceCard)
            {
                replaceCost = GameTable.HeroInfoTableAsset.Lookup(replaceCard.IDInTable).Cost;
            }
            // 要判断领导力

            // 如果领导力不够 则返回
            if (OperateCardList.Singleton.m_leadShipCost - replaceCost + heroInfo.Cost > User.Singleton.GetLeadership())
            {
                return;
            }

            // 添加
            if (item.m_param.m_id != -1)
            {
                Team.Singleton.AddTeamMember(Team.Singleton.m_curTeamIndex, Team.Singleton.m_curEditType, item.m_param.m_guid);
            }

            Team.Singleton.UpdateTeamBagAllSlotId();
        }
    }