local UIGuildWarArray = UIViewClass() local EventSystem = require('Event/EventSystem') local State = { Member = 1, LeaderReadyEdit = 2, LeaderEdit = 3, } local GROUPMAXCOUNT = 21 --每个战场最大人数 local IndexToExcelId = {2 , 1, 3, 3, 3} --选中的下标对应战场表的id function UIGuildWarArray:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GuildWar_Phase2) self:RegistSystemEvent(EventID.UI_GuildWarGroupInfosUpdate, self.Refresh) self:RegistSystemEvent(EventID.UI_Guild_SelfInfoRefresh, self.OnJobChange) UIUtils.SetLabelText(self.lab_LimitText,Const_IDS.IDS_GuildWar_PowerLimit) local isEditor = MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildWarPrepareEdit) self.group_Edit.gameObject:SetActive(isEditor) if isEditor then self:InitEditor() else UIUtils.SetActive(self.btn_CEEdit, false) UIUtils.SetActive(self.group_Leader, false) self.editState = State.Member end self:InitGroupTitle() self.group_Toggle:SelectIndex(context[1]-1) for i,v in ipairs(self.groups) do v.txt_TeamName.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_Team,i) end EventSystem.Dispatch(EventID.UI_GuildWarArrayOpen,false) self.group_Edit.gameObject:SetActive(false) self:SetEditState() self.clickGroups = {} self.keyBoardView = nil for i,v in ipairs(self.groups) do for _,player in ipairs(v.players) do self:RegistTriggerEvent(player.img_PlayerHead, UIEventTriggerType.PointerClick) self.clickGroups[player.img_PlayerHead.gameObject] = {index = _, group = i} end end end function UIGuildWarArray:InitEditor() self.editState = State.LeaderReadyEdit UIUtils.SetActive(self.group_Edit, false) UIUtils.SetActive(self.event_Edit, true) UIUtils.SetActive(self.btn_CEEdit, true) UIUtils.SetActive(self.txt_Info2, true) UIUtils.SetActive(self.btn_Close, false) UIUtils.SetActive(self.group_CELimit, true) --group_Info UIUtils.SetActive(self.group_Info, true) self.hasChange = false self.cdTimer:EndTimer() self.group_ArrayScroll:ClearCells() MDL.Guild.GetGuildInfoReq() end function UIGuildWarArray:BeginEditor() UIUtils.SetActive(self.group_CELimit, false) --group_Info UIUtils.SetActive(self.group_Info, false) UIUtils.SetActive(self.group_Edit, true) UIUtils.SetActive(self.event_Edit, false) UIUtils.SetActive(self.cdTimer, true) UIUtils.SetActive(self.txt_Info2, false) UIUtils.SetActive(self.btn_Close, true) local editTime = CTL.GuildWar.GetEditTime() self.cdTimer:ResetAndBeginCustomTimer(false,editTime,0,UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_EditorModeAutoCloseTime)) self:StartRepeatFunc(self.OnUpdateFun, editTime) self.editState = State.LeaderEdit self:ShowArrayByIndex(self.curIndex) if self.dropSlots == nil then self.dropSlots = {} self.dropGroups ={} for i,v in ipairs(self.groups) do for _,player in ipairs(v.players) do table.insert(self.dropSlots, player.bg_Head.gameObject) table.insert(self.dropSlots, player.img_PlayerHead.gameObject) self.dropGroups[player.img_PlayerHead.gameObject] = {index = _, group = i, hasPlayer = true} self.dropGroups[player.bg_Head.gameObject] = {index = _, group = i, hasPlayer = false} player.gameObject.name = (i - 1)*3 + _ end end table.insert(self.dropSlots, self.loop_drop.gameObject) for i,v in ipairs(self.groups) do for _,player in ipairs(v.players) do self:RegistTriggerEvent(player.img_PlayerHead, UIEventTriggerType.BeginDrag) self:RegistTriggerEvent(player.img_PlayerHead, UIEventTriggerType.Drag) self:RegistTriggerEvent(player.img_PlayerHead, UIEventTriggerType.EndDrag) self:RegistTriggerEvent(player.img_PlayerHead, UIEventTriggerType.PointerClick) --UIUtils.AddDropList(player.img_PlayerHead,self.dropSlots) --这样写会报错 很神奇 不知道为啥 先再起一个循环解决吧 --self:RegistDropEvent(player.img_PlayerHead,self.dropSlots) end end end for i,v in ipairs(self.groups) do for _,player in ipairs(v.players) do self:RegistDropEvent(player.img_PlayerHead,self.dropSlots) end end self:ShowMember() self.event_Save:SetGray(true,true) MDL.GuildWar.BeginEdit() UnityEngine.Input.multiTouchEnabled = false end function UIGuildWarArray:SetEditState() local groupInfos = MDL.GuildWar.GetGroupInfos() local lockAcid = nil for i,v in ipairs(groupInfos) do if v.isLock then lockAcid = v.lockAcid end end if lockAcid and lockAcid ~= BattleDataGetter.GetAcID() then self:ShowGroupTeamMask(true) UIUtils.SetActive(self.group_Editing, true) UIUtils.SetActive(self.group_MemberTitle, false) if self.editState == State.LeaderReadyEdit then self.btn_CEEdit.gameObject:SetActive(false) self.event_Edit.gameObject:SetActive(false) end UIUtils.SetActive(self.group_Edit, false) UIUtils.SetActive(self.group_Member, true) UIUtils.SetActive(self.txt_Info2, false) else self:ShowGroupTeamMask(false) UIUtils.SetActive(self.group_Editing, false) UIUtils.SetActive(self.group_MemberTitle, true) UIUtils.SetActive(self.group_Member, false) if self.editState == State.LeaderReadyEdit then self.btn_CEEdit.gameObject:SetActive(true) self.event_Edit.gameObject:SetActive(true) end UIUtils.SetActive(self.txt_Info2, lockAcid ~= BattleDataGetter.GetAcID()) end end function UIGuildWarArray:Refresh() self:InitGroupTitle() self:ShowArrayByIndex(self.curIndex) self:SetEditState() end function UIGuildWarArray:SetLimitGs(value) if value <= 0 then self.obj_CEInputField.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_TeamUI_ApplyLimit_None) else local myGs = MDL.Player.GetLineUpGs() if value > myGs then self.obj_CEInputField.text = UTL.Color.FormatRedColor(value) else self.obj_CEInputField.text = value end end end function UIGuildWarArray:InitGroupTitle() local groupInfos = MDL.GuildWar.GetGroupInfos() if groupInfos then --这里猜测是网不好 不等协议过来 显示了界面 for i,v in ipairs(groupInfos) do local isSelfInGroup = false local gs = 0 local count = 0 for _,player in ipairs(v.players) do if player.isHasPlayer then gs = gs + player.headInfo.gsSum count = count + 1 if player.headInfo.acid == BattleDataGetter.GetAcID() then isSelfInGroup = true end end end local countStr = nil if count == GROUPMAXCOUNT then countStr = UTL.Color.FormatRedColor(count) .."/"..GROUPMAXCOUNT else countStr = count .."/"..GROUPMAXCOUNT end self.group_txt[i].txt_MemberNum.text = "("..countStr..")" self.group_txt[i].txt_CEPresent.text = gs self.group_txt[i].img_Self.gameObject:SetActive(isSelfInGroup) end end end function UIGuildWarArray:OnValueChanged(comp, value) if comp == self.group_Toggle then if value == 0 then self:ShowArrayByIndex(1) elseif value == 1 then self:ShowArrayByIndex(2) elseif value == 2 then self:ShowArrayByIndex(3) elseif value == 3 then self:ShowArrayByIndex(4) elseif value == 4 then self:ShowArrayByIndex(5) end end end function UIGuildWarArray:ShowArrayByIndex(index) local groupInfos = MDL.GuildWar.GetGroupInfos() self.curIndex = index local players = groupInfos[index].players for i,v in ipairs(players) do self:ShowPlayerByIndex(i,v) end self:SetLimitGs(groupInfos[index].fightScoreLimit) self:HidePreAndNextBtn() local data = DataSheetManager.GuildWarBattleIntroSummary:GetDataByID(IndexToExcelId[self.curIndex]) UIUtils.SetLabelText(self.txt_Info2, Const_IDS[data.Summary]) end function UIGuildWarArray:ShowPlayerByIndex(index,playerInfo) local obj = self:GetObjByIndex(index) if playerInfo.isHasPlayer then CTL.Character.SetImgPortrait(obj.playerHead, playerInfo.headInfo.PortraitId) obj.MainWar_Name.text = playerInfo.headInfo.name obj.txt_CEPresent.text = playerInfo.headInfo.gsSum obj.img_PlayerHead.gameObject:SetActive(true) obj.group_Add.gameObject:SetActive(false) obj.group_Quit.gameObject:SetActive(playerInfo.headInfo.acid == BattleDataGetter.GetAcID() and self.editState ~= State.LeaderEdit) obj.group_TeamLead.gameObject:SetActive(index == 1) obj.group_Combat.gameObject:SetActive(true) --obj.bg_Head2.gameObject:SetActive(true) obj.UIState:SetState(playerInfo.headInfo.acid == BattleDataGetter.GetAcID() and 1 or 0) else -- obj.bg_Head2.gameObject:SetActive(false) obj.MainWar_Name.text = nil obj.txt_CEPresent.text = nil obj.img_PlayerHead.gameObject:SetActive(false) obj.group_Add.gameObject:SetActive(self.editState ~= State.LeaderEdit) obj.group_Quit.gameObject:SetActive(false) obj.group_TeamLead.gameObject:SetActive(false) obj.group_Combat.gameObject:SetActive(false) obj.UIState:SetState(0) end end function UIGuildWarArray:GetObjByIndex(index) local arrayIndex = math.ceil(index / 3) local teamIndex = index % 3 if teamIndex == 0 then teamIndex = 3 end return self.groups[arrayIndex].players[teamIndex] end function UIGuildWarArray:OnClickSlot(comp) local groupInfos = MDL.GuildWar.GetGroupInfos() for i,v in ipairs(self.groups) do for index,slot in ipairs(v.players) do if comp == slot.group_Add then self:AddTeam((i-1) * 3 + index, v.txt_TeamName.text) elseif comp == slot.group_Quit then self:LeaveTeam((i-1) * 3 + index, v.txt_TeamName.text) end end end end function UIGuildWarArray:ShowGroupTeamMask(show) for i, v in ipairs(self.groups) do UIUtils.SetActive(v.edit_Mask1, show) UIUtils.SetActive(v.edit_Mask2, show) end end function UIGuildWarArray:GetShowRoomByType(roomType) if roomType ==1 then --主战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName1) elseif roomType ==2 then -- 码头战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName3) elseif roomType == 3 then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName6) elseif roomType == 4 then --支援战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName7) elseif roomType == 5 then --支援战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName8) else --无战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_TargetNotInGroup) end end function UIGuildWarArray:AddTeam(index,teamName) local groupName = self:GetShowRoomByType(self.curIndex) local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_JoinTeamConfirm,groupName,teamName) UTL.MessageBox.ShowOKCancelBox(nil, str, function () if self:CanAdd() then local info = MDL.GuildWar.GetWarInfo() if info.Stage == MDL.GuildWar.Stages.StageTypePrepare and info.prePareStage == MDL.GuildWar.PrePareStages.AnyOne then MDL.GuildWar.ChangeSelfPosForWar(MDL.GuildWar.PrepareOperate.Join, self.curIndex, index) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1431_InfoCode_GuildWar_NotInMemberEditTime) end end end,nil) end function UIGuildWarArray:CanAdd() local groupInfos = MDL.GuildWar.GetGroupInfos() if groupInfos[self.curIndex].fightScoreLimit > MDL.Player.GetLineUpGs() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_FightingCapacityNotEnough) return false end -- local info = MDL.Guild.GetMyGuildMemberInfo() -- local joinTime = UTL.Time.GetServerTimestamp() - info.joinTime -- if joinTime < UTL.Time.TotalSecondsOneDay then -- local residueTime = UTL.Time.TotalSecondsOneDay - joinTime -- local timeStr = UTL.Time.FormatTimeClockBySeconds(residueTime) -- --CTL.Tips.AddTipsMsg(timeStr.."后方可报名") -- end if not MDL.GuildWar.InBattleTime() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1431_InfoCode_GuildWar_NotInMemberEditTime) return false end return true end function UIGuildWarArray:GetShowRoomByType(roomType) if roomType ==1 then --主战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName1) elseif roomType ==2 then -- 码头战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName3) elseif roomType == 3 then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName6) elseif roomType == 4 then --支援战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName7) elseif roomType == 5 then --支援战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_BattlegroundName8) else --无战场 return UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarChannel_TargetNotInGroup) end end function UIGuildWarArray:LeaveTeam(index,teamName) local groupName = self:GetShowRoomByType(self.curIndex) local str = string.FormatByIdsId(Const_IDS.IDS_GuildWar_LeaveTeamConfirm,groupName,teamName) UTL.MessageBox.ShowOKCancelBox(nil, str, function () local info = MDL.GuildWar.GetWarInfo() if info.Stage == MDL.GuildWar.Stages.StageTypePrepare and info.prePareStage == MDL.GuildWar.PrePareStages.AnyOne then MDL.GuildWar.ChangeSelfPosForWar(MDL.GuildWar.PrepareOperate.Leave, self.curIndex, index) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotInFormationTime) end end,nil) end function UIGuildWarArray:OnClosed() EventSystem.Dispatch(EventID.UI_GuildWarArrayOpen,true) UnityEngine.Input.multiTouchEnabled = true if self.drag_Cell then self.drag_Cell.transform:SetParent(self.group_ArrayScroll.content,false) end if self.curDragItem then local groupIndex = self.dropGroups[self.curDragItem].group local playerIndex = self.dropGroups[self.curDragItem].index local obj = self.groups[groupIndex].players[playerIndex] self.curDragItem.transform:SetParent(obj.gameObject.transform,false) self.curDragItem.transform:SetAnchoredPosition(0, 0) end self.curDragItem = nil self.keyBoardView = nil end function UIGuildWarArray:OnPointerClick(comp) if comp and not self.noClickPoint then local slotData = nil if self.editState == State.LeaderEdit then slotData = self.dropGroups[comp.gameObject] else slotData = self.clickGroups[comp.gameObject] end if slotData then local rIndex = (slotData.group-1)*3+slotData.index local groupInfos = MDL.GuildWar.GetGroupInfos() local removePlayer = groupInfos[self.curIndex].players[rIndex] if self.editState == State.LeaderEdit then local memberData = MDL.Guild.GetMemberData(removePlayer.headInfo.acid) table.insert(self.members,memberData) MDL.Guild.SortByGS(self.members) self.group_ArrayScroll:ReloadAll(self.members) self:RemovePlayer(rIndex) self:ShowPlayerByIndex(rIndex,removePlayer) self.event_Save:SetGray(false) self.hasChange = true self:InitGroupTitle() --slotData.hasPlayer = false else CTL.PlayerInteract.OpenFriendInteractView(removePlayer.headInfo.acid) end end end self.noClickPoint = false end function UIGuildWarArray:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildWarArray:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then if self.editState == State.LeaderEdit then self:QuitEdit(true) else self:CloseView() end elseif comp == self.UITemplateTitlePanel.btn_Home then if self.editState == State.LeaderEdit then self:QuitEdit(false, true) else CTL.HomeMain.CloseViewBackHomeMain() end elseif comp == self.btn_CEEdit then if not self.keyBoardView then local maxLimit = DataSheetManager.ConstData:GetDataByID("TeamPowerMaxLimitMax").IntValue self.keyBoardView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIKeypad), {parentView = self, x = -280, y = 0, minNum = 0, maxNum = maxLimit}) end elseif comp == self.event_Edit then if self:IsCanEdit() then self:BeginEditor() end elseif comp == self.btn_Close then self:QuitEdit() elseif comp == self.event_Save then if not self.hasChange then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NothingToSave) self:InitEditor() MDL.GuildWar.EndEdit() else self:SaveEdit() end self:ShowArrayByIndex(self.curIndex) elseif comp == self.btn_Before then self:ShowBeforePage() elseif comp == self.btn_Next then self:ShowNextPage() elseif comp == self.group_Info then if self.curIndex == 4 or self.curIndex == 5 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarBattleGround, {selectIndex = 3}) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarBattleGround, {selectIndex = self.curIndex}) end elseif comp == self.btn_Notice then self.panel_Array.gameObject:SetActive(true) self.btn_Notice.gameObject:SetActive(false) elseif comp == self.UITemplateTitlePanel.btn_Info then CTL.GuildWar.OpenGuildWarNoteView() else self:OnClickSlot(comp) end end function UIGuildWarArray:ExcuteKeyBoardBack(count, paramData) self:RefreshCENumber(count) end function UIGuildWarArray:CloseKeyBoardView() self.keyBoardView:CloseView() self.keyBoardView = nil local value = tonumber(self.obj_CEInputField.text) or 0 self:ChangeLimitGs(value) end function UIGuildWarArray:ShowBeforePage() self.curIndex = self.curIndex - 1 self.group_Toggle:SelectIndex(self.curIndex - 1) end function UIGuildWarArray:ShowNextPage() self.curIndex = self.curIndex + 1 self.group_Toggle:SelectIndex(self.curIndex - 1) end function UIGuildWarArray:HidePreAndNextBtn( ... ) if self.curIndex == self.group_Toggle.Count then self.btn_Next.gameObject:SetActive(false) else self.btn_Next.gameObject:SetActive(true) end if self.curIndex == 1 then self.btn_Before.gameObject:SetActive(false) else self.btn_Before.gameObject:SetActive(true) end end function UIGuildWarArray:ChangeLimitGs(value) local info = MDL.GuildWar.GetWarInfo() if self:IsCanEdit() then MDL.GuildWar.ChangeLimitGs(self.curIndex, value or 0 ) if value > 0 then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_GuildWar_QuickKickPlayerConfirm, function () if self:IsCanEdit() then MDL.GuildWar.KickLowScorePlayer(self.curIndex) end end,nil) end end end function UIGuildWarArray:IsCanEdit() local info = MDL.GuildWar.GetWarInfo() if info.Stage ~= MDL.GuildWar.Stages.StageTypePrepare or info.prePareStage == MDL.GuildWar.PrePareStages.SysTem then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotInFormationTime) return false end if not MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildWarPrepareEdit) then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_EditAuthority) return false end return true end ------------------------------------drag----------------- function UIGuildWarArray:AddPlayer(playerInfo,index) local groupInfos = MDL.GuildWar.GetGroupInfos() local players = groupInfos[self.curIndex].players players[index].isHasPlayer = true players[index].headInfo.acid = playerInfo.acid players[index].headInfo.name = playerInfo.name players[index].headInfo.level = playerInfo.level players[index].headInfo.teamRankID = playerInfo.teamRankID players[index].headInfo.mainHeroId = playerInfo.mainHeroId players[index].headInfo.gsSum = playerInfo.gsSum players[index].headInfo.isOnline = playerInfo.isOnline players[index].headInfo.guildName = playerInfo.guildName players[index].headInfo.PortraitId = playerInfo.PortraitId end function UIGuildWarArray:RemovePlayer(index) local groupInfos = MDL.GuildWar.GetGroupInfos() local players = groupInfos[self.curIndex].players players[index].isHasPlayer = false end function UIGuildWarArray:ShowMember() local groupInfos = MDL.GuildWar.GetGroupInfos() self.memberCells = {} self.members = {} for _, member in MDL.Guild.GetGuildMembersIterator(true) do local isExits = false for i, v in ipairs(groupInfos) do for _, player in ipairs(v.players) do if player.isHasPlayer and player.headInfo.acid == member.roleInfo.acid then isExits = true end end end if not isExits then table.insert(self.members, member) end end MDL.Guild.SortByGS(self.members) for i,v in ipairs(self.members) do self.group_ArrayScroll:AddData(v,0) end end function UIGuildWarArray:QuitEdit(isClose, isBackHome) if self.hasChange then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_GuildWar_ChangesConfirm, function () if self:IsCanEdit() then self:SaveEdit() end end, function () MDL.GuildWar.C2GGetGuildWarPrepareInfo() if isClose then MDL.GuildWar.EndEdit() self:CloseView() elseif isBackHome then MDL.GuildWar.EndEdit() CTL.HomeMain.CloseViewBackHomeMain() else MDL.GuildWar.EndEdit() self:InitEditor() end end) else MDL.GuildWar.EndEdit() self:InitEditor() end end function UIGuildWarArray:SaveEdit() MDL.GuildWar.SaveEdit() self:InitEditor() end function UIGuildWarArray:RefreshCENumber(count) self.obj_CEInputField.text = count end function UIGuildWarArray:OnCellInit(scrollRect, index, cellTable, data) self.memberCells[index+1] = {cellTable,data} CTL.Character.SetImgPortrait(cellTable.img_PlayerHead, data.roleInfo.PortraitId) cellTable.MainWar_Name.text = data.roleInfo.name cellTable.txt_CEPresent.text = data.roleInfo.gsSum self.group_ArrayScroll:RegistTriggerEvent(cellTable.bg_Head, UIEventTriggerType.BeginDrag,index) self.group_ArrayScroll:RegistTriggerEvent(cellTable.bg_Head, UIEventTriggerType.Drag,index) self.group_ArrayScroll:RegistTriggerEvent(cellTable.bg_Head, UIEventTriggerType.EndDrag,index) self.group_ArrayScroll:RegistTriggerEvent(cellTable.bg_Head, UIEventTriggerType.PointerDown,index) self.group_ArrayScroll:RegistTriggerEvent(cellTable.bg_Head, UIEventTriggerType.PointerUp,index) self:RegistDropEvent(cellTable.bg_Head,self.dropSlots) end function UIGuildWarArray:Cell_OnPointerUp(scrollRect, index, target, eventData) if not self.curDragObj and self.curPointerDownTime and Time.realtimeSinceStartup - self.curPointerDownTime <=0.5 then local data = self.memberCells[index+1][2] local groupInfos = MDL.GuildWar.GetGroupInfos() local players = groupInfos[self.curIndex].players for i,v in ipairs(players) do if not v.isHasPlayer then local playerInfo = data.roleInfo v.isHasPlayer = true v.headInfo.acid = playerInfo.acid v.headInfo.name = playerInfo.name v.headInfo.level = playerInfo.level v.headInfo.teamRankID = playerInfo.teamRankID v.headInfo.mainHeroId = playerInfo.mainHeroId v.headInfo.gsSum = playerInfo.gsSum v.headInfo.isOnline = playerInfo.isOnline v.headInfo.guildName = playerInfo.guildName v.headInfo.PortraitId = playerInfo.PortraitId self:ShowPlayerByIndex(i,v) table.remove(self.memberCells,index+1) table.remove(self.members,index+1) self.group_ArrayScroll:RemoveIndex(index) self.event_Save:SetGray(false) self.hasChange = true self:InitGroupTitle() return end end CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_GroupNoVacancy) end end function UIGuildWarArray:Cell_OnPointerDown(scrollRect, index, target, eventData) self.curPointerDownTime = Time.realtimeSinceStartup end function UIGuildWarArray:Cell_OnBeginDrag(scrollRect, index, target, eventData) if math.abs(eventData.delta.y) > 8 then local cell = self.memberCells[index+1] if cell then self.drag_Cell = cell[1].cell.gameObject self.curDragData = {isInSlotPlayer = false , playerInfo = cell[2].roleInfo , index = self.drag_Cell.transform:GetSiblingIndex() ,cellIndex = index} self.drag_Cell.transform:SetParent(self.dragParent,false) self.curPointerDownTime = nil else logging.error(LTAG.XuQian, "重大错误 拖拽对象 越界 ",index, #self.memberCells) end else self.curDragObj = self.group_ArrayScroll.gameObject UIUtils.ExecuteBeginDrag(self.curDragObj, eventData) end end function UIGuildWarArray:Cell_OnEndDrag(scrollRect, index, comp, eventData) if self.curDragObj then UIUtils.ExecuteEndDrag(self.curDragObj, eventData) self.curDragObj = nil end end function UIGuildWarArray:Cell_OnDrop(scrollRect, index, target, eventData) if not self.curDragObj and self.curDragData then self.drag_Cell.transform:SetParent(self.group_ArrayScroll.content,false) self.drag_Cell.transform:SetSiblingIndex(self.curDragData.index) end end function UIGuildWarArray:SetDragItem(roleInfo) CTL.Character.SetImgPortrait(self.drag_Cell.img_PlayerHead, roleInfo.PortraitId) self.drag_Cell.MainWar_Name.text = roleInfo.name self.drag_Cell.txt_CEPresent.text = roleInfo.gsSum end function UIGuildWarArray:Cell_OnDrag(scrollRect, index, target, eventData) if self.curDragObj then UIUtils.ExecuteDrag(self.curDragObj, eventData) else UIUtils.ScreenPointToWorldPointInRectangle(self.drag_Cell, eventData) end end function UIGuildWarArray:OnDrop(comp, eventData) if not self.curDragData then return end if comp then local slotData = self.dropGroups[comp.gameObject] if slotData then if self.dropGroups[eventData.pointerDrag] then --已上阵的拖拽到上阵区 local groupIndex = self.dropGroups[eventData.pointerDrag].group local playerIndex = self.dropGroups[eventData.pointerDrag].index if slotData.hasPlayer then self:ExchangePlayer(slotData.group-1,slotData.index) elseif groupIndex ~= slotData.group or playerIndex~= slotData.index then self:AddSlotPlayer(slotData.group-1,slotData.index,self.curDragData.playerInfo) self:RemoveSlotPlayer(self.curDragData.groupIndex,self.curDragData.playerIndex) end else self.drag_Cell.transform:SetParent(self.group_ArrayScroll.content,false) self.drag_Cell.transform:SetSiblingIndex(self.curDragData.index) if slotData.hasPlayer then self:ExchangeCellPlayer((slotData.group-1)*3+slotData.index ,self.curDragData.cellIndex) else self.group_ArrayScroll:RemoveIndex(self.curDragData.cellIndex) table.remove(self.memberCells,self.curDragData.cellIndex+1) table.remove(self.members,self.curDragData.cellIndex+1) end self:AddSlotPlayer(slotData.group-1,slotData.index,self.curDragData.playerInfo) self.drag_Cell = nil end self.event_Save:SetGray(false) self.hasChange = true elseif comp.gameObject == self.loop_drop.gameObject and self.curDragData.isInSlotPlayer then --拖拽到未上阵区 local memberData = MDL.Guild.GetMemberData(self.curDragData.playerInfo.acid) table.insert(self.members,memberData) MDL.Guild.SortByGS(self.members) self.group_ArrayScroll:ReloadAll(self.members) local rIndex = self.curDragData.groupIndex*3 + self.curDragData.playerIndex self:RemovePlayer(rIndex) local groupInfos = MDL.GuildWar.GetGroupInfos() local removePlayer = groupInfos[self.curIndex].players[rIndex] self:ShowPlayerByIndex(rIndex,removePlayer) self.event_Save:SetGray(false) self.hasChange = true end self:InitGroupTitle() end if self.curDragData.isInSlotPlayer then local groupIndex = self.dropGroups[eventData.pointerDrag].group local playerIndex = self.dropGroups[eventData.pointerDrag].index local obj = self.groups[groupIndex].players[playerIndex] eventData.pointerDrag.transform:SetParent(obj.gameObject.transform,false) eventData.pointerDrag.transform:SetAnchoredPosition(0, 0) eventData.pointerDrag.transform:SetSiblingIndex(1) self.curDragItem = nil else if self.drag_Cell then self.drag_Cell.transform:SetParent(self.group_ArrayScroll.content,false) self.drag_Cell.transform:SetSiblingIndex(self.curDragData.index) self.drag_Cell = nil end end self.curDragData = nil self.loop_drop.gameObject:SetActive(false) end function UIGuildWarArray:OnBeginDrag(comp, eventData) local groupIndex = self.dropGroups[comp.gameObject].group - 1 local playerIndex = self.dropGroups[comp.gameObject].index local groupInfos = MDL.GuildWar.GetGroupInfos() local playerInfo = groupInfos[self.curIndex].players[groupIndex*3 + playerIndex] self.curDragData = {isInSlotPlayer = true , playerInfo = playerInfo.headInfo , groupIndex = groupIndex , playerIndex = playerIndex} comp.transform:SetParent(self.dragParent,false) self.noClickPoint = true self.loop_drop.gameObject:SetActive(true) self.curDragItem = comp.gameObject end function UIGuildWarArray:OnDrag(comp, eventData) UIUtils.ScreenPointToWorldPointInRectangle(comp.gameObject, eventData) end function UIGuildWarArray:ExchangePlayer(groupIndex,playerIndex) local groupInfos = MDL.GuildWar.GetGroupInfos() local index1 = groupIndex*3 + playerIndex local index2 = self.curDragData.groupIndex*3 + self.curDragData.playerIndex local isHasPlayer = groupInfos[self.curIndex].players[index1].isHasPlayer local playerInfo = groupInfos[self.curIndex].players[index1].headInfo -- 不一定有数据 local scrPlayerInfo = self.curDragData.playerInfo --肯定有数据 local tmp = {} tmp.acid = scrPlayerInfo.acid tmp.name = scrPlayerInfo.name tmp.level = scrPlayerInfo.level tmp.teamRankID = scrPlayerInfo.teamRankID tmp.mainHeroId = scrPlayerInfo.mainHeroId tmp.gsSum = scrPlayerInfo.gsSum tmp.isOnline = scrPlayerInfo.isOnline tmp.guildName = scrPlayerInfo.guildName if isHasPlayer then scrPlayerInfo.acid = playerInfo.acid scrPlayerInfo.name = playerInfo.name scrPlayerInfo.level = playerInfo.level scrPlayerInfo.teamRankID = playerInfo.teamRankID scrPlayerInfo.mainHeroId = playerInfo.mainHeroId scrPlayerInfo.gsSum = playerInfo.gsSum scrPlayerInfo.isOnline = playerInfo.isOnline scrPlayerInfo.guildName = playerInfo.guildName else self:RemovePlayer(self.curDragData.groupIndex,self.curDragData.playerIndex) end playerInfo.acid = tmp.acid playerInfo.name = tmp.name playerInfo.level = tmp.level playerInfo.teamRankID = tmp.teamRankID playerInfo.mainHeroId = tmp.mainHeroId playerInfo.gsSum = tmp.gsSum playerInfo.isOnline = tmp.isOnline playerInfo.guildName = tmp.guildName self:ShowPlayerByIndex(index1,groupInfos[self.curIndex].players[index1]) if self.curDragData.isInSlotPlayer then self:ShowPlayerByIndex(index2,groupInfos[self.curIndex].players[index2]) else self.group_ArrayScroll:RefreshCells() end end function UIGuildWarArray:ItemAddSlotPlayer(groupIndex,playerIndex) self:AddSlotPlayer(groupIndex,playerIndex,self.curDragData.playerInfo) self:RemoveSlotPlayer(self.curDragData.groupIndex,self.curDragData.playerIndex) end function UIGuildWarArray:AddSlotPlayer(groupIndex,playerIndex,playerInfo) local pIndex = groupIndex*3 + playerIndex self:AddPlayer(playerInfo, pIndex) local groupInfos = MDL.GuildWar.GetGroupInfos() local inGroupInfo = groupInfos[self.curIndex].players[pIndex] self:ShowPlayerByIndex(pIndex,inGroupInfo) end function UIGuildWarArray:RemoveSlotPlayer(groupIndex,playerIndex) local pIndex = groupIndex*3 + playerIndex self:RemovePlayer(pIndex) local groupInfos = MDL.GuildWar.GetGroupInfos() local removePlayer = groupInfos[self.curIndex].players[pIndex] self:ShowPlayerByIndex(pIndex,removePlayer) end function UIGuildWarArray:ExchangeCellPlayer(itemIndex,cellIndex) local groupInfos = MDL.GuildWar.GetGroupInfos() local removePlayer = groupInfos[self.curIndex].players[itemIndex] local memberData = MDL.Guild.GetMemberData(removePlayer.headInfo.acid) self.group_ArrayScroll:UpdateIndex(cellIndex,memberData) end function UIGuildWarArray:OnUpdateFun(deltaTime, timeSinceUpdate) self:CloseView() UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView) end function UIGuildWarArray:OnJobChange() if not MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildWarPrepareEdit) then if self.keyBoardView then self.keyBoardView:CloseView() end self.btn_CEEdit.gameObject:SetActive(false) if self.editState == State.LeaderEdit then self:CloseView() end end end function UIGuildWarArray:OnEndDrag() end return UIGuildWarArray