--[[ 天下会武参赛者禁选将 ]] local UITeamFairChampionshipBanSelect = UIViewClass() local STATE_BAN = 0 --禁阶段 local STATE_PICK = 1 --选阶段 local STATE_ADJUST = 2 --调整顺序阶段 local STATE_READY_BATTLE = 3 --进战斗倒计时阶段 --武将几个选中状态 local HERO_STATE_LEFT_BAN = 1 local HERO_STATE_LEFT_PICK = 2 local HERO_STATE_RIGHT_BAN = 3 local HERO_STATE_RIGHT_PICK = 4 local HERO_STATE_ALL_PICK = 5 --双方都选中 local HERO_STATE_ALL_BAN = 6 --双方都禁止 --选将置灰状态 local LOCK_STATE_SHOW_1 = 0 --第1行亮 local LOCK_STATE_SHOW_2 = 1 --第1、2行亮 local LOCK_STATE_SHOW_3 = 2 --第2、3行亮 local LOCK_STATE_SHOW_4 = 3 --第3行亮 local LOCK_STATE_SHOW_ALL = 4 --全部亮 local LOCK_STATE_HIDE_ALL = 5 --全部置灰 local BanHeroCount = DataSheetManager.ConstData:GetDataByID("TeamFairTournamentBanNum").IntValue local SuperHeroCount = DataSheetManager.ConstData:GetDataByID("TeamFairTournamenPick22HeroNum").IntValue function UITeamFairChampionshipBanSelect:OnCreated() --左边已经选择的武将列表 self.leftSelectedHeroIdList = {0,0,0,0,0,0} self.clientBanHeroIdList = {} self.leftBPInfo = nil self.leftTeamInfo = nil --右边已经选择的武将列表 self.rightSelectedHeroIdList = {0,0,0,0,0,0} self.rightBPInfo = nil self.rightTeamInfo = nil self.dragParentTrans = self.obj_DragParent.transform --初始化可选的武将列表,这里用FairSoloTournament模块的 self.displayHeroList = CTL.FairSoloTournament.GetAllSortedHeroList() --当前可操作的队伍 self.curCanOperTeamInfo = nil --当前可操作的BP信息 self.curCanOperBPHeroInfo = nil --当前可以操作的武将起始位置 self.canOperHeroStartIndex = 1 --当前可以造作的武将终止位置 self.canOperHeroEndIndex = 6 --我的队伍位置 self.myTeamPos = -1 self.leftSuperGolderHeroCfgIdArr = {} self.rightSuperGolderHeroCfgIdArr = {} UIUtils.SetLabel(self.txt_BanSelectTip, string.FormatByIdsKey("IDS_FairTournament_CaiJinHero", SuperHeroCount)) end --更新比赛队伍信息 function UITeamFairChampionshipBanSelect:UpdateMatchTeamInfo() self:SetBasicInfo(self.group_Left, self.leftTeamInfo) self:SetBasicInfo(self.group_Right, self.rightTeamInfo) end function UITeamFairChampionshipBanSelect:SetBasicInfo(comp, showInfo) if showInfo.teamId == MDL.TeamFairChampionship.GetMyTeamId() then comp.txt_TeamName.text = showInfo.teamName else comp.txt_TeamName.text = showInfo.teamName end for i, v in ipairs(comp.group_SelectHero) do v.txt_Nun.text = i local playerInfo = MDL.TeamFairChampionship.GetPlayerInfoByACID(showInfo.memberAcids[i]) if playerInfo then CTL.Character.SetPortraitAndFrame(v.group_Head.UIHeroHead150, playerInfo.PortraitId, playerInfo.FrameId) UIUtils.SetLabel(v.group_Head.lab_RoleName, playerInfo.name) end end end function UITeamFairChampionshipBanSelect:OnOpened(context) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_NoticeBPHeroInfo, self.OnBPHeroInfoNotice) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_RefreshBPState, self.OnRefreshBPStateInfo) if MDL.TeamFairChampionship.IsTeamMatchWatcher() then self:RegistSystemEvent(EventID.UI_TeamFairChampionship_RefreshInfo, self.OnRefreshStageInfo) end self.matchGroupInfo = MDL.TeamFairChampionship.GetCurBattleMatchGroup() if context.leftShowTeamId == self.matchGroupInfo.teamInfos[1].teamId then self.leftTeamInfo = self.matchGroupInfo.teamInfos[1] self.rightTeamInfo = self.matchGroupInfo.teamInfos[2] else self.leftTeamInfo = self.matchGroupInfo.teamInfos[2] self.rightTeamInfo = self.matchGroupInfo.teamInfos[1] end for index, memberAcid in ipairs(self.leftTeamInfo.memberAcids) do if memberAcid == BattleDataGetter.GetAcID() then self.myTeamPos = index end end for i=1, BanHeroCount do self.clientBanHeroIdList[i] = 0 end self:UpdateMatchTeamInfo() self:InitOperationPermissions() end function UITeamFairChampionshipBanSelect:OnRefreshStageInfo() local stageInfo = MDL.TeamFairChampionship.GetMatchStageInfo(MDL.TeamFairChampionship.GetCurStageID()) if stageInfo.state == MDL.TeamFairChampionship.Enum_State.Battle then MDL.TeamFairChampionship.TeamFairGetWatchBattleInfoReq(self.context.leftShowTeamId, true) self:StartRepeatFunc(self.CheckCanWatchBattleReq, 2) end end --大阶段进入战斗,可能小组还没进房间,需要轮询看什么时候可以进战斗 function UITeamFairChampionshipBanSelect:CheckCanWatchBattleReq(deltaTime, timeSinceUpdate) MDL.TeamFairChampionship.TeamFairGetWatchBattleInfoReq(self.context.leftShowTeamId, true) end function UITeamFairChampionshipBanSelect:InitOperationPermissions() if MDL.TeamFairChampionship.IsTeamMatchWatcher() then UIUtils.SetActive(self.btn_Close, true) else UIUtils.SetActive(self.btn_Close, false) if MDL.SpecialTeam.IsSelfLeader() then for __, groupHeroComp in ipairs(self.group_Left.group_SelectHero) do for i=1, 2 do self:RegistTriggerEvent(groupHeroComp["group_hero0" .. i].btn_FormationHero, UIEventTriggerType.BeginDrag) self:RegistTriggerEvent(groupHeroComp["group_hero0" .. i].btn_FormationHero, UIEventTriggerType.Drag) self:RegistTriggerEvent(groupHeroComp["group_hero0" .. i].btn_FormationHero, UIEventTriggerType.EndDrag) self:RegistTriggerEvent(groupHeroComp["group_hero0" .. i].btn_FormationHero, UIEventTriggerType.Drop) self:RegistTriggerEvent(groupHeroComp["group_hero0" .. i].img_Empty, UIEventTriggerType.Drop) end end end if not GameAppInfo.IsJapanesePackage() then CTL.VoiceRoom.OpenCommonVoiceChat(self.voiceChatPanel, MDL.VoiceRoom.VoiceRoomType.TeamFairChampionship, true) end end end function UITeamFairChampionshipBanSelect:OnBPHeroInfoNotice(bpHeroInfos, serverBanPickState) self:UpdateBPHeroData(bpHeroInfos, serverBanPickState) if self.group_BanSelect.loop_bpHero.Count == 0 then self.group_BanSelect.loop_bpHero:ReloadAll(self.displayHeroList) else self.group_BanSelect.loop_bpHero:RefreshCells(false) end end function UITeamFairChampionshipBanSelect:UpdateBPHeroData(bpHeroInfos, serverBanPickState) for __, bpInfo in ipairs(bpHeroInfos) do if bpInfo.TeamId == self.leftTeamInfo.teamId then self.leftBPInfo = bpInfo else self.rightBPInfo = bpInfo end end self.leftSuperGolderHeroCfgIdArr = {} for index, heroId in ipairs(self.leftBPInfo.PickHero) do self.leftSelectedHeroIdList[index] = heroId self:RefreshSingleHeroCell(index) if heroId>0 and CTL.HeroSelect.IsSuperGoldHero(heroId) then table.insert(self.leftSuperGolderHeroCfgIdArr, heroId) end end self:RefreshRightSelectedHero(serverBanPickState~=MDL.TeamFairChampionship.BanPickState.Change) if self.banStateInfo and not self.curCanOperTeamInfo then self:UpdateBPState() end end function UITeamFairChampionshipBanSelect:RefreshRightSelectedHero(isForce) self.rightSuperGolderHeroCfgIdArr = {} for index, heroId in ipairs(self.rightBPInfo.PickHero) do self.rightSelectedHeroIdList[index] = heroId self:RefreshEnemyHeroCell(index, isForce) if heroId>0 and CTL.HeroSelect.IsSuperGoldHero(heroId) then table.insert(self.rightSuperGolderHeroCfgIdArr, heroId) end end end function UITeamFairChampionshipBanSelect:OnRefreshBPStateInfo(bpStateinfo) self.banStateInfo = bpStateinfo if self.leftBPInfo then self:UpdateBPState() end end --防止在时间到达的时候服务器消息没推送过来,客户端做一个处理 function UITeamFairChampionshipBanSelect:CheckBanSelectStateTimer(deltaTime, timeSinceUpdate) MDL.TeamFairChampionship.C2GTeamFairRequireBPState() end function UITeamFairChampionshipBanSelect:UpdateBPState() self:StopRepeatFunc(self.CheckBanSelectStateTimer) local matchTimeCfg = DataSheetManager.TeamFairMatchTime:GetDataByID(MDL.TeamFairChampionship.GetCurBigStageID()) local leftTime = self.banStateInfo.fightTimeList.startFightTime - UTL.Time.GetServerTimestamp() if leftTime <= 0 then self.curBPState = MDL.TeamFairChampionship.BanPickState.None return end if self.leftTeamInfo.teamId == self.banStateInfo.opTeamId then self.curCanOperTeamInfo = self.leftTeamInfo self.curCanOperBPHeroInfo = self.leftBPInfo else self.curCanOperTeamInfo = self.rightTeamInfo self.curCanOperBPHeroInfo = self.rightBPInfo end if self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Ban1 then self.curBPState = STATE_BAN self.canOperHeroStartIndex = 1 self.canOperHeroEndIndex = 6 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.banEndTime[1] - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Ban2 then self.curBPState = STATE_BAN self.canOperHeroStartIndex = 1 self.canOperHeroEndIndex = 6 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.banEndTime[2] - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick1_2 then self.curBPState = STATE_PICK self.canOperHeroStartIndex = self.myTeamPos*2-1 self.canOperHeroEndIndex = self.myTeamPos*2 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.pickTime[1] - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick2_4 then self.curBPState = STATE_PICK self.canOperHeroStartIndex = self.myTeamPos*2-1 self.canOperHeroEndIndex = self.myTeamPos*2 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.pickTime[2] - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick1_4 then self.curBPState = STATE_PICK self.canOperHeroStartIndex = self.myTeamPos*2-1 self.canOperHeroEndIndex = self.myTeamPos*2 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.pickTime[3] - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick2_2 then self.curBPState = STATE_PICK self.canOperHeroStartIndex = self.myTeamPos*2-1 self.canOperHeroEndIndex = self.myTeamPos*2 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.pickTime[4] - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Change then self.curBPState = STATE_ADJUST self.canOperHeroStartIndex = 1 self.canOperHeroEndIndex = 6 self.curBPStateLeftTime = self.banStateInfo.fightTimeList.fixTime - UTL.Time.GetServerTimestamp() elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Finish then self.curBPState = STATE_READY_BATTLE self.curBPStateLeftTime = self.banStateInfo.fightTimeList.startFightTime - UTL.Time.GetServerTimestamp() end self:OnBPStateChanged() if self.curBPStateLeftTime>0 then self:StartRepeatFunc(self.CheckBanSelectStateTimer, self.curBPStateLeftTime+2, 1) end end function UITeamFairChampionshipBanSelect:OnBPStateChanged() if self.curBPState == STATE_BAN then self.state_Middle:SetState(0) UIUtils.SetActive(self.group_Tip, true) UIUtils.SetActive(self.banSelectTip, false) UIUtils.SetActive(self.group_BanSelect.group_TitleBan, true) UIUtils.SetActive(self.group_BanSelect.group_TitleSelect, false) self.group_BanSelect.cdTimer_BP:ResetAndBeginCustomTimer(false, self.curBPStateLeftTime, 0, "{0}s", 1) UIUtils.SetLabelText(self.group_BanSelect.lab_Title, Const_IDS.IDS_TeamFairTournamen_BanHero) local teamLeadInfo = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[1]) UIUtils.SetLabel(self.txt_Info, string.FormatByIdsKey("IDS_TeamFairTournamen_LeaderBan", teamLeadInfo.name, BanHeroCount)) elseif self.curBPState == STATE_PICK then self.group_BanSelect.loop_bpHero:RefreshCells(false) self.state_Middle:SetState(0) UIUtils.SetActive(self.group_Tip, true) UIUtils.SetActive(self.banSelectTip, true) UIUtils.SetActive(self.group_BanSelect.group_TitleBan, false) UIUtils.SetActive(self.group_BanSelect.group_TitleSelect, true) self.group_BanSelect.cdTimer_BP:ResetAndBeginCustomTimer(false, self.curBPStateLeftTime, 0, "{0}s", 1) if MDL.TeamFairChampionship.IsTeamMatchWatcher() then UIUtils.SetLabelText(self.txt_Info, Const_IDS["IDS_FairTournament_QuickHero2"]) elseif CTL.TeamFairChampionship.IsFilterMatchStage() then UIUtils.SetLabelText(self.txt_Info, Const_IDS["IDS_FairTournament_QuickHero"]) else if self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick1_2 then local teamPlayerInfo = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[1]) UIUtils.SetLabel(self.txt_Info, string.FormatByIdsKey("IDS_TeamFairTournamen_PlayerBan", teamPlayerInfo.name)) elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick2_4 then local teamPlayerInfo1 = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[1]) local teamPlayerInfo2 = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[2]) UIUtils.SetLabel(self.txt_Info, string.FormatByIdsKey("IDS_TeamFairTournamen_TwoPlayerBan", teamPlayerInfo1.name, teamPlayerInfo2.name)) elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick1_4 then local teamPlayerInfo1 = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[2]) local teamPlayerInfo2 = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[3]) UIUtils.SetLabel(self.txt_Info, string.FormatByIdsKey("IDS_TeamFairTournamen_TwoPlayerBan", teamPlayerInfo1.name, teamPlayerInfo2.name)) elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick2_2 then local teamPlayerInfo = MDL.TeamFairChampionship.GetPlayerInfoByACID(self.curCanOperTeamInfo.memberAcids[3]) UIUtils.SetLabel(self.txt_Info, string.FormatByIdsKey("IDS_TeamFairTournamen_PlayerBan", teamPlayerInfo.name)) end end elseif self.curBPState == STATE_ADJUST then self:RefreshRightSelectedHero(true) UIUtils.SetActive(self.group_Tip, false) UIUtils.SetActive(self.banSelectTip, false) self.state_Middle:SetState(2) self.group_Adjustment.cdTimer_Adjustment:ResetAndBeginCustomTimer(false, self.curBPStateLeftTime, 0, "{0}s", 1) elseif self.curBPState == STATE_READY_BATTLE then self:RefreshRightSelectedHero(false) UIUtils.SetActive(self.group_Tip, false) UIUtils.SetActive(self.banSelectTip, false) self.state_Middle:SetState(1) self.group_Prepare.cdTimer_Prepare:ResetAndBeginCustomTimer(false, self.curBPStateLeftTime, 0, "{0}s", 1) end self:UpdateBPDetail() end function UITeamFairChampionshipBanSelect:UpdateBPDetail() if self.curBPState == STATE_BAN then self:SetOperatorState(LOCK_STATE_HIDE_ALL, LOCK_STATE_HIDE_ALL, false, false) UIUtils.SetActive(self.group_Left.group_SelectHero[1].group_Head.img_OperationTip, self.banStateInfo.opTeamId == self.leftTeamInfo.teamId) UIUtils.SetActive(self.group_Right.group_SelectHero[1].group_Head.img_OperationTip, self.banStateInfo.opTeamId == self.rightTeamInfo.teamId) elseif self.curBPState == STATE_PICK then UIUtils.SetActive(self.group_Left.group_SelectHero[1].group_Head.img_OperationTip, false) UIUtils.SetActive(self.group_Right.group_SelectHero[1].group_Head.img_OperationTip, false) if CTL.TeamFairChampionship.IsFilterMatchStage() then self:SetOperatorState(LOCK_STATE_SHOW_ALL, LOCK_STATE_HIDE_ALL, false, not MDL.TeamFairChampionship.IsTeamMatchWatcher()) elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick1_2 then --第一轮pick,pick那一方亮第一行,另一方全部置灰 if self.banStateInfo.opTeamId == self.leftTeamInfo.teamId then self:SetOperatorState(LOCK_STATE_SHOW_1, LOCK_STATE_HIDE_ALL, false, false) else self:SetOperatorState(LOCK_STATE_HIDE_ALL, LOCK_STATE_SHOW_1, false, false) end elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick2_4 then if self.banStateInfo.opTeamId == self.leftTeamInfo.teamId then self:SetOperatorState(LOCK_STATE_SHOW_2, LOCK_STATE_HIDE_ALL, false, false) else self:SetOperatorState(LOCK_STATE_HIDE_ALL, LOCK_STATE_SHOW_2, false, false) end elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick1_4 then if self.banStateInfo.opTeamId == self.leftTeamInfo.teamId then self:SetOperatorState(LOCK_STATE_SHOW_3, LOCK_STATE_HIDE_ALL, false, false) else self:SetOperatorState(LOCK_STATE_HIDE_ALL, LOCK_STATE_SHOW_3, false, false) end elseif self.banStateInfo.state == MDL.TeamFairChampionship.BanPickState.Pick2_2 then if self.banStateInfo.opTeamId == self.leftTeamInfo.teamId then self:SetOperatorState(LOCK_STATE_SHOW_4, LOCK_STATE_HIDE_ALL, false, false) else self:SetOperatorState(LOCK_STATE_HIDE_ALL, LOCK_STATE_SHOW_4, false, false) end end elseif self.curBPState == STATE_ADJUST then self:SetOperatorState(LOCK_STATE_SHOW_ALL, LOCK_STATE_HIDE_ALL, false, false) elseif self.curBPState == STATE_READY_BATTLE then self:SetOperatorState(LOCK_STATE_SHOW_ALL, LOCK_STATE_SHOW_ALL, false, false) end end function UITeamFairChampionshipBanSelect:SetOperatorState(leftState, rightState, showLeftTip, showRightTip) self.group_Left.state_Lock:SetState(leftState) UIUtils.SetActive(self.group_Left.group_SelectTip, showLeftTip) self.group_Right.state_Lock:SetState(rightState) UIUtils.SetActive(self.group_Right.group_SelectTip, showRightTip) end --获取武将bp情况 function UITeamFairChampionshipBanSelect:GetHeroState(heroId) local leftPick = self:GetIndexByHeroId(self.leftBPInfo.PickHero, heroId) local leftBan = self:GetIndexByHeroId(self.leftBPInfo.BanHero, heroId) local rightPick = self:GetIndexByHeroId(self.rightBPInfo.PickHero, heroId) local rightBan = self:GetIndexByHeroId(self.rightBPInfo.BanHero, heroId) if self.curBPState == STATE_PICK and CTL.TeamFairChampionship.IsFilterMatchStage() then if not MDL.TeamFairChampionship.IsTeamMatchWatcher() then rightPick = false end end if leftPick and rightPick then return HERO_STATE_ALL_PICK elseif leftPick and not rightPick then return HERO_STATE_LEFT_PICK elseif not leftPick and rightPick then return HERO_STATE_RIGHT_PICK end if leftBan and rightBan then return HERO_STATE_ALL_BAN elseif leftBan and not rightBan then return HERO_STATE_LEFT_BAN elseif not leftBan and rightBan then return HERO_STATE_RIGHT_BAN end return nil end function UITeamFairChampionshipBanSelect:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetHeroIconByHeroId(cellTable.img_HeroHead, CTL.HeroAwaken.DecodeHeroId(data)) local state = self:GetHeroState(data) if state == nil then UIUtils.SetActive(cellTable.img_Mask_Ban, false) UIUtils.SetActive(cellTable.img_Mask_Select, false) UIUtils.SetGray(cellTable.img_HeroHead, false) else UIUtils.SetGray(cellTable.img_HeroHead, true) if state == HERO_STATE_ALL_BAN then UIUtils.SetActive(cellTable.img_BanSelect, false) UIUtils.SetActive(cellTable.img_Mask_Ban, true) UIUtils.SetActive(cellTable.img_Mask_Select, false) UIUtils.SetActive(cellTable.img_BanBlue, true) UIUtils.SetActive(cellTable.img_BanRed, true) elseif state == HERO_STATE_ALL_PICK then UIUtils.SetActive(cellTable.img_BanSelect, false) UIUtils.SetActive(cellTable.img_Mask_Ban, false) UIUtils.SetActive(cellTable.img_Mask_Select, true) UIUtils.SetActive(cellTable.img_SelectBlue, true) UIUtils.SetActive(cellTable.img_SelectRed, true) elseif state == HERO_STATE_LEFT_BAN then UIUtils.SetActive(cellTable.img_BanSelect, false) UIUtils.SetActive(cellTable.img_Mask_Select, false) UIUtils.SetActive(cellTable.img_Mask_Ban, true) UIUtils.SetActive(cellTable.img_BanBlue, true) UIUtils.SetActive(cellTable.img_BanRed, false) elseif state == HERO_STATE_RIGHT_BAN then UIUtils.SetActive(cellTable.img_BanSelect, false) UIUtils.SetActive(cellTable.img_Mask_Select, false) UIUtils.SetActive(cellTable.img_Mask_Ban, true) UIUtils.SetActive(cellTable.img_BanBlue, false) UIUtils.SetActive(cellTable.img_BanRed, true) elseif state == HERO_STATE_LEFT_PICK then UIUtils.SetActive(cellTable.img_BanSelect, false) UIUtils.SetActive(cellTable.img_Mask_Select, true) UIUtils.SetActive(cellTable.img_Mask_Ban, false) UIUtils.SetActive(cellTable.img_SelectBlue, true) UIUtils.SetActive(cellTable.img_SelectRed, false) elseif state == HERO_STATE_RIGHT_PICK then UIUtils.SetActive(cellTable.img_BanSelect, false) UIUtils.SetActive(cellTable.img_Mask_Select, true) UIUtils.SetActive(cellTable.img_Mask_Ban, false) UIUtils.SetActive(cellTable.img_SelectBlue, false) UIUtils.SetActive(cellTable.img_SelectRed, true) end end if self.curBPState == STATE_PICK then local tempArr = nil if self.banStateInfo.opTeamId == self.leftTeamInfo.teamId then tempArr = self.leftSuperGolderHeroCfgIdArr else tempArr = self.rightSuperGolderHeroCfgIdArr end if #tempArr>=SuperHeroCount and not table.containValue(tempArr, data) and CTL.HeroSelect.IsSuperGoldHero(data) then UIUtils.SetGray(cellTable.img_HeroHead, true) end end --觉醒前后只能选一个 if self:GetIndexByHeroId(self.leftBPInfo.PickHero, CTL.HeroAwaken.TranslateHeroId(data)) or (MDL.TeamFairChampionship.GetCurBigStageID() ~= MDL.TeamFairChampionship.Enum_BigStage.Screening and self:GetIndexByHeroId(self.rightBPInfo.PickHero, CTL.HeroAwaken.TranslateHeroId(data))) then UIUtils.SetGray(cellTable.img_HeroHead, true) end end function UITeamFairChampionshipBanSelect:OnCellClicked(scrollRect, index, cellTable, target, data) if self.curBPState==STATE_READY_BATTLE or self.curBPState==STATE_ADJUST then return end if not table.containValue(self.banStateInfo.opAcid, BattleDataGetter.GetAcID()) then return end if self.curBPState == STATE_BAN then if self.selectBPCell then UIUtils.SetActive(self.selectBPCell.img_BanSelect, false) end UIUtils.SetActive(cellTable.img_BanSelect, true) self.selectBPCell = cellTable if self:GetIndexByHeroId(self.rightBPInfo.BanHero, data) then return end local findIndex = 0 local emptyIndex = 0 for index, heroId in ipairs(self.clientBanHeroIdList) do if heroId == data then findIndex = index end if emptyIndex<=0 and heroId==0 then emptyIndex = index end end if findIndex>0 then self.clientBanHeroIdList[findIndex] = 0 elseif emptyIndex>0 then self.clientBanHeroIdList[emptyIndex] = data else return end MDL.TeamFairChampionship.C2GTeamFairBP(false, self.clientBanHeroIdList) elseif self.curBPState == STATE_PICK then local state = self:GetHeroState(data) if state == HERO_STATE_LEFT_BAN or state == HERO_STATE_RIGHT_BAN or state == HERO_STATE_ALL_BAN then CTL.Tips.AddTipsMsg(Const_IDS["IDS_FairTournament_Baned"]) return end --非小组赛不能选被pick的武将 if state == HERO_STATE_RIGHT_PICK and MDL.TeamFairChampionship.GetCurBigStageID() ~= MDL.TeamFairChampionship.Enum_BigStage.Screening then return end local tempIndex = 0 if self.leftSelectedHeroIdList[self.canOperHeroStartIndex]==data then tempIndex = self.canOperHeroStartIndex elseif self.leftSelectedHeroIdList[self.canOperHeroEndIndex]==data then tempIndex = self.canOperHeroEndIndex end if tempIndex>0 then if self.selectBPCell then UIUtils.SetActive(self.selectBPCell.img_BanSelect, false) end UIUtils.SetActive(cellTable.img_BanSelect, false) self.selectBPCell = nil self:NotifyPickHero(tempIndex, 0) else if #self.leftSuperGolderHeroCfgIdArr>=SuperHeroCount and CTL.HeroSelect.IsSuperGoldHero(data) then return end if self:GetIndexByHeroId(self.leftBPInfo.PickHero, CTL.HeroAwaken.TranslateHeroId(data)) then return end if MDL.TeamFairChampionship.GetCurBigStageID() ~= MDL.TeamFairChampionship.Enum_BigStage.Screening and self:GetIndexByHeroId(self.rightBPInfo.PickHero, CTL.HeroAwaken.TranslateHeroId(data)) then return end if self.leftSelectedHeroIdList[self.canOperHeroStartIndex]<=0 then tempIndex = self.canOperHeroStartIndex elseif self.leftSelectedHeroIdList[self.canOperHeroEndIndex]<=0 then tempIndex = self.canOperHeroEndIndex end if tempIndex <= 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_BossChallenge_ChooseHero_FullHero"]) else if self.selectBPCell then UIUtils.SetActive(self.selectBPCell.img_BanSelect, false) end UIUtils.SetActive(cellTable.img_BanSelect, true) self.selectBPCell = cellTable self:NotifyPickHero(tempIndex, data) end end end end --选中即通知 function UITeamFairChampionshipBanSelect:NotifyPickHero(pos, heroId) self.leftSelectedHeroIdList[pos] = heroId MDL.TeamFairChampionship.C2GTeamFairBP(false, nil, self.leftSelectedHeroIdList) self.leftSelectedHeroIdList[pos] = 0 end function UITeamFairChampionshipBanSelect:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() MDL.TeamFairChampionship.ClearWatchParam() MDL.TeamFairChampionship.TeamFairBPWatchReq(false, self.context.leftShowTeamId) return end if not table.containValue(self.banStateInfo.opAcid, BattleDataGetter.GetAcID()) then return end if self.curBPState==STATE_READY_BATTLE or self.curBPState==STATE_ADJUST then return end local index = self:GetIndexByInteractiveItem(comp) if index then if indexself.canOperHeroEndIndex then return end if self.selectBPCell then UIUtils.SetActive(self.selectBPCell.img_BanSelect, false) self.selectBPCell = nil end self:NotifyPickHero(index, 0) end end function UITeamFairChampionshipBanSelect:RefreshSingleHeroCell(index) local heroId = self.leftSelectedHeroIdList[index] local cell = self.group_Left.group_SelectHero[math.ceil(index/2)] if index % 2 == 0 then self:RefreshHeroCell(cell.group_hero02, heroId, false) else self:RefreshHeroCell(cell.group_hero01, heroId, false) end end function UITeamFairChampionshipBanSelect:RefreshEnemyHeroCell(index, isForce) --调整武将的时候不实时显示 if isForce or self.curBPState ~= STATE_ADJUST then local heroId = self.rightSelectedHeroIdList[index] local cell = self.group_Right.group_SelectHero[math.ceil(index/2)] if index % 2 == 0 then self:RefreshHeroCell(cell.group_hero02, heroId, self.curBPState == STATE_PICK and CTL.TeamFairChampionship.IsFilterMatchStage()) else self:RefreshHeroCell(cell.group_hero01, heroId, self.curBPState == STATE_PICK and CTL.TeamFairChampionship.IsFilterMatchStage()) end end end function UITeamFairChampionshipBanSelect:RefreshHeroCell(cell, heroId, isHideSelectHero) if not isHideSelectHero and heroId and heroId > 0 then UTL.Item.SetHeroIconByHeroId(cell.img_HeroHead, CTL.HeroAwaken.DecodeHeroId(heroId)) UIUtils.SetActive(cell.group_FormationHero, true) UIUtils.SetActive(cell.img_Empty, false) UIUtils.SetActive(cell.img_Select, false) else UIUtils.SetActive(cell.group_FormationHero, false) UIUtils.SetActive(cell.img_Empty, true) UIUtils.SetActive(cell.img_Select, isHideSelectHero and heroId and heroId>0) end end function UITeamFairChampionshipBanSelect:OnBeginDrag(comp, eventData) if self.curBPState ~= STATE_ADJUST then return end self.dragIndex = self:GetIndexByInteractiveItem(comp) self.dragItem = GameObject.Instantiate(comp.transform.parent.parent.gameObject) self.dragItem.transform:SetParent(self.dragParentTrans, false) self.dragItem.transform:GetChild(0):GetComponentInChildren(typeof(Image)).raycastTarget = false end function UITeamFairChampionshipBanSelect:OnDrag(comp, eventData) if self.dragItem then UIUtils.ScreenPointToWorldPointInRectangle(self.dragItem, eventData) end end function UITeamFairChampionshipBanSelect:OnEndDrag(comp, eventData) self:ClearDragData() end function UITeamFairChampionshipBanSelect:OnDrop(comp, eventData) if eventData.pointerEnter and self.dragIndex then local dropIndex = self:GetIndexByInteractiveItem(comp) if dropIndex and dropIndex ~= self.dragIndex then local dragItemId = self.leftSelectedHeroIdList[self.dragIndex] self.leftSelectedHeroIdList[self.dragIndex] = self.leftSelectedHeroIdList[dropIndex] self.leftSelectedHeroIdList[dropIndex] = dragItemId MDL.TeamFairChampionship.C2GTeamFairBP(false, nil, self.leftSelectedHeroIdList) return end end self:ClearDragData() end function UITeamFairChampionshipBanSelect:ClearDragData() self.dragIndex = nil if self.dragItem then GameObject.Destroy(self.dragItem) self.dragItem = nil end end function UITeamFairChampionshipBanSelect:GetIndexByHeroId(list, id) for i, v in ipairs(list) do if v == id then return i end end return nil end function UITeamFairChampionshipBanSelect:GetIndexByInteractiveItem(comp) local returnIndex = 0 for groupHeroIndex, groupHeroComp in ipairs(self.group_Left.group_SelectHero) do for i=1, 2 do returnIndex = returnIndex+1 if comp == groupHeroComp["group_hero0" .. i].btn_FormationHero or comp == groupHeroComp["group_hero0" .. i].img_Empty then return returnIndex end end end return nil end function UITeamFairChampionshipBanSelect:OnClosed() CTL.VoiceRoom.ExitVoiceRoom(MDL.VoiceRoom.VoiceRoomType.TeamFairChampionship) end return UITeamFairChampionshipBanSelect