// 更新单个格子 为队伍编辑 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++; } }
// 设置编辑队伍 相关 public void UpdateOperateTeam(CSItem card, ENSortType sortType, Team.EDITTYPE type = Team.EDITTYPE.enALL, int index = 0) { if (card == null) { return; } Update(card, sortType, index); m_param.m_id = (int)Team.EDITTYPE.enNone; m_param.m_guid = card.Guid; int cardID = card.IDInTable; HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(cardID); if (heroInfo == null) { return; } string strShadow = ""; // 编辑全部队员类型 if (Team.Singleton.m_curEditType == Team.EDITTYPE.enALL) { string coverName = ""; CSItemGuid guid = Team.Singleton.m_bagMainSlotId; switch (type) { case Team.EDITTYPE.enMain: { coverName = "cardCover-team-1"; guid = Team.Singleton.m_bagMainSlotId; break; } case Team.EDITTYPE.enDeputy: { coverName = "cardCover-team-2"; guid = Team.Singleton.m_bagDeputySlotId; break; } case Team.EDITTYPE.enSupport: { coverName = "cardCover-team-3"; guid = Team.Singleton.m_bagSupportSlotId; break; } case Team.EDITTYPE.enNone: { coverName = ""; guid = card.Guid; break; } case Team.EDITTYPE.enALL: { // 队伍索引图标 if (Team.Singleton.m_bagMainSlotId.Equals(card.Guid)) { coverName = "cardCover-team-1"; type = Team.EDITTYPE.enMain; } else if (Team.Singleton.m_bagDeputySlotId.Equals(card.Guid)) { coverName = "cardCover-team-2"; type = Team.EDITTYPE.enDeputy; } else if (Team.Singleton.m_bagSupportSlotId.Equals(card.Guid)) { coverName = "cardCover-team-3"; type = Team.EDITTYPE.enSupport; } guid = card.Guid; break; } } // 如果已选 则显示相应的 已选的图片 if (guid.Equals(card.Guid)) { m_tips.GetComponent <UISprite>().spriteName = coverName; m_param.m_type = (int)Team.Singleton.m_curEditType; m_param.m_id = (int)type; } m_chosen.gameObject.SetActive(m_param.m_id != (int)Team.EDITTYPE.enNone); //获取世界参数表提取队伍最大人数 WorldParamInfo info = GameTable.WorldParamTableAsset.Lookup((int)ENWorldParamIndex.enTeamRoleMaxNum); int roleMax = 0; if (null != info) { roleMax = info.IntTypeValue; } else { roleMax = 3; } // 如果超过了 玩家的领导力 if (Team.Singleton.GetTheTeamCostExcept(card.Guid) + heroInfo.Cost > User.Singleton.GetLeadership()) { strShadow = "cost_Not_Enough"; } else if (OperateCardList.Singleton.m_hadItemList.Count >= roleMax) //队伍内人数是否大于等于队伍最大人数 { strShadow = "mask_card"; } } // 编辑单个队伍类型 else { // 突破 m_break.text = Localization.Get("LevelBreak") + card.BreakCounts; m_tips.GetComponent <UISprite>().spriteName = "cardCover-choose"; // 将要被替换角色的领导力 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()) { strShadow = "cost_Not_Enough"; } } m_tips.SetActive(true); m_mask.SetActive(true); m_defaultHead.gameObject.SetActive(false); m_tag.spriteName = ""; m_shadow.GetComponent <UISprite>().spriteName = strShadow; m_love.gameObject.SetActive(false); }
// 点击响应 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(); } }