-- 布阵界面模型比较多穿戴特效会互相穿模,策划戴雨倩决定这个界面不播武将特效 local UICommonLineUpView = UIViewClass() local UIEffectPath = { LockEffect = ConstAssetPathConfig.LockEffect, BeingSelected = ConstAssetPathConfig.BeingSelected, OnDropEffect = ConstAssetPathConfig.OnDropEffect, AllowLineUpEffect = ConstAssetPathConfig.AllowLineUpEffect, EmptySpaceEffect = ConstAssetPathConfig.AllowLineUpEffect, } local CheckParams = { FormationIndex = 0, MainHeroIndex = 0, SubHeroIndex = 0, heroIdList = nil } local ArrayCameraPos = Vector3.New(-992.1, -999.3, -999.3) local ArrayCameraRot = Vector3.New(-6.28, -87.75, -0.04) local DefaultFov = 30 function UICommonLineUpView:OnOpened(context) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.RefreshArrayInfo) self:RegistSystemEvent(EventID.UI_HeroMatch1v1_CloseView, self.CheckActiveFinishCloseView) -- 赛程结束关闭界面 self:RegistSystemEvent(EventID.UI_HeroMatch3v3_CloseView, self.CheckActiveFinishCloseView) -- 赛程结束关闭界面 self.FunctionType = context.functionType -- 演武屏蔽助战和连携 UIUtils.SetActive(self.btn_AssistanceFight, false) UIUtils.SetActive(self.group_TeamBuff, false) -- 攻城略地需要显示阵容详情 UIUtils.SetActive(self.root_Formation, self.FunctionType == MDL.Unlock.FunctionType.GVGFight) -- 攻城略地屏蔽放大镜详细阵容 for _, v in ipairs(self.group_TeamGs) do UIUtils.SetActive(v.btn_Check, false) end UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Fomation_Array) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info.gameObject ,false) UnityEngine.Input.multiTouchEnabled = false; self.heroInfoList = {} self.lineUpHeroList = {} self.cellDictData = {} self.effectId = {} self.modelEffectID = {} self:RegistHeroPanel() self.isOut = false self.oldIndex = nil self.ArrayShow:EnterArrayShowWithCameraParam(ArrayCameraPos, ArrayCameraRot, DefaultFov) self:RefreshArrayInfo() end function UICommonLineUpView:RegistHeroPanel() self.heroPanel = {} self.heroEffect = {} self.heroPanelId = {} for i = 1,6 do self.heroPanel[i] = self["Hero0"..i] self.heroEffect[i] = self["HeroEffect0"..i] self.heroPanelId["Hero0"..i] = i self:RegistTriggerEvent(self.heroPanel[i], UIEventTriggerType.BeginDrag) self:RegistTriggerEvent(self.heroPanel[i], UIEventTriggerType.Drag) self:RegistTriggerEvent(self.heroPanel[i], UIEventTriggerType.EndDrag) self:RegistTriggerEvent(self.heroPanel[i], UIEventTriggerType.Drop) end end function UICommonLineUpView:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) UIUtils.SetActive(self.root_Formation, false) UnityEngine.Input.multiTouchEnabled = true; for k,v in pairs(self.effectId) do AuxUtil.StopPsEffect(v) end for k,v in pairs(self.modelEffectID) do AuxUtil.StopPsEffect(v) end if self.FunctionType == MDL.Unlock.FunctionType.GVGFight then self:ReqFreeLineChange(MDL.FreeLineUp.FuncType.GvGFight, true) else MDL.FreeLineUp.UpdateLineUpReq(self.lineUpHeroList, self.FunctionType) end if self.dropEffectId then AuxUtil.StopPsEffect(self.dropEffectId) end end function UICommonLineUpView:ReqFreeLineChange(functionType, isClose) local lineNumber = MDL.FreeLineUp.GetFreeLineUpLineNumber(functionType) MDL.FreeLineUp.FreeLineUpSetRequest(functionType, lineNumber, MDL.FreeLineUp.SetType.Official, self.lineUpHeroList, isClose) end function UICommonLineUpView:CheckActiveFinishCloseView() if self.FunctionType == MDL.Unlock.FunctionType.HeroMatch1v1 or self.FunctionType == MDL.Unlock.FunctionType.HeroMatch3v3 then self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end end function UICommonLineUpView:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UICommonLineUpView:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_AssistanceFight then CTL.AssistanceFight.OpenAssistancePanel(1) elseif comp == self.group_TeamBuff then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonTipsPanel) elseif comp == self.btn_Formation then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFreeLineupDetailPanel, {id = MDL.FreeLineUp.FuncType.GvGFight, heroList = self.lineUpHeroList}) else for i = 1, 3 do if comp == self.group_TeamGs[i].btn_Check then CheckParams.FormationIndex = i CheckParams.MainHeroIndex = i * 2 - 1 CheckParams.SubHeroIndex = i * 2 UIManager.OpenView(Const_UI_Lua.UIEnum.UIAssistanceInfoTips, CheckParams) end end end end function UICommonLineUpView:ConvertIndex(index) if index == 1 or index == 2 then return "Left" elseif index == 3 or index == 4 then return "Middle" elseif index == 5 or index == 6 then return "Right" end end function UICommonLineUpView:RefreshArrayInfo() self:SetLineUpHeroModel() self:SetLineUpHeroPower() self:RefreshPanelEffect() end local ShowAttrNum = 13 function UICommonLineUpView:RefreshSinglePropertiesScroll(loopScroll, mainIndex, viceIndex) local mainHeroId = self.lineUpHeroList[mainIndex] local viceHeroId = self.lineUpHeroList[viceIndex] local mainAttrList = nil local viceAttrList = nil local length = 0 if mainHeroId and mainHeroId > 0 then mainAttrList = MDL.HeroDetail.GetAttrDataFromSheet(MDL.HeroDetail.GetTotalAttr(mainHeroId)) length = ShowAttrNum end if viceHeroId and viceHeroId > 0 then viceAttrList = MDL.HeroDetail.GetAttrDataFromSheet(MDL.HeroDetail.GetTotalAttr(viceHeroId)) length = ShowAttrNum end for i = 1, length do local attr = {} if mainAttrList then attr.main = mainAttrList[i] else attr.main = nil end if viceAttrList then attr.vice = viceAttrList[i] else attr.vice = nil end if loopScroll.Count >= length then loopScroll:UpdateIndex(i - 1, attr) else loopScroll:AddData(attr, 0) end end end function UICommonLineUpView:SetLineUpHeroModel() local arrayIdList = {} if self.FunctionType == MDL.Unlock.FunctionType.SoloFight then arrayIdList = MDL.SoloFight.GetSoloFightInfo().lineUpHeroIds elseif self.FunctionType == MDL.Unlock.FunctionType.GVGFight then arrayIdList = MDL.FreeLineUp.GetLineUpArrayIdListByFunctionType(MDL.FreeLineUp.FuncType.GvGFight, false) else arrayIdList = MDL.FreeLineUp.GetCommonLineUpInfoByFunctionType(self.FunctionType) end -- 清理模型 防止多次加载 for _, heroId in ipairs(self.lineUpHeroList) do self.ArrayShow:CheckAndDestroyModel(heroId) -- 卸载模型 防止频繁加载 end for i, v in ipairs(arrayIdList) do local heroId, index, modelPath, equipTable, modelScale, animCtrlPath, heroEffectPath,heroLightEffects = UTL.UIRender.LoadArrayHero(v, i, true) self.ArrayShow:LoadArrayModel(heroId, index, modelPath, equipTable, modelScale, animCtrlPath) if not string.isNilOrEmpty(heroEffectPath) then local modelEffectId = SystemManager.PlayPsEffect(heroEffectPath, self.ArrayShow:GetHeroModelTransform(index)) table.insert(self.modelEffectID, modelEffectId) end end self.lineUpHeroList = arrayIdList CheckParams.heroIdList = arrayIdList end function UICommonLineUpView:GetIndexByHeroId(id) for i,v in ipairs(self.lineUpHeroList) do if v == id then return i end end end function UICommonLineUpView:SetHero(id, index) local oldIndex = self:GetIndexByHeroId(id) local oldId = self.lineUpHeroList[index] self.lineUpHeroList[index] = id self.lineUpHeroList[oldIndex] = oldId end function UICommonLineUpView:SetLineUpHeroImage() local arrayId = self.lineUpHeroList for i = 2, 6, 2 do if arrayId[i] < 0 then UIUtils.SetActive(self["group_Position"..self:ConvertIndex(i)].gameObject, false) else UIUtils.SetActive(self["group_Position"..self:ConvertIndex(i)].gameObject, true) end end end function UICommonLineUpView:SetLineUpHeroPower() if self.FunctionType == MDL.Unlock.FunctionType.GVGFight then local lineUpPowerList = MDL.FreeLineUp.GetLineUpPowerListByFunctionType(MDL.FreeLineUp.FuncType.GvGFight) for i, v in ipairs(self.group_TeamGs) do local power = lineUpPowerList[i * 2] + lineUpPowerList[i * 2 - 1] UIUtils.SetLabel(v.txt_PowerNumber, power) end UIUtils.SetLabel(self.txt_PowerNumber, MDL.FreeLineUp.GetLineUpTotalGsByFunctionType(MDL.FreeLineUp.FuncType.GvGFight)) else UIUtils.SetLabel(self.txt_PowerNumber, MDL.Player.GetLineUpGs()) local ids = self.lineUpHeroList for i, v in ipairs(self.group_TeamGs) do local value = MDL.HeroSelect.GetHeroGs(self.lineUpHeroList[i*2]) + MDL.HeroSelect.GetHeroGs(self.lineUpHeroList[i*2-1]) -- 添加助战战力 local assistanceGs = 0 local formationInfos = MDL.AssistanceFight.GetFormationInfo(i) if formationInfos and #formationInfos > 0 then for _, slotInfo in ipairs (formationInfos) do if slotInfo and slotInfo.data and slotInfo.data.gs then assistanceGs = assistanceGs + slotInfo.data.gs end end end v.txt_PowerNumber.text = value + assistanceGs end end end function UICommonLineUpView:OnBeginDrag(comp, eventData) self.dragItemId = self.cellDictData[comp] if not self.dragItemId then self.dragItemId = self.lineUpHeroList[self.heroPanelId[comp.name]] end local data = MDL.HeroSelect.GetHeroInfo(self.dragItemId) if not data then return end self:RefreshHeroCell(self.cell_ArrayHero, data) UIUtils.SetActive(self.cell_ArrayHero.gameObject, true) end function UICommonLineUpView:OnDrag(comp, eventData) if self.cell_ArrayHero.gameObject.activeSelf then UIUtils.ScreenPointToWorldPointInRectangle(self.cell_ArrayHero.gameObject, eventData) if eventData.pointerEnter then self:ShowAvailableEffectDuringDrag(self.heroPanelId[eventData.pointerEnter.name]) end end end function UICommonLineUpView:OnEndDrag(comp, eventData) UIUtils.SetActive(self.cell_ArrayHero.gameObject, false) self.oldIndex = nil self:RefreshPanelEffect() self:StopEffectDuringDrag() end function UICommonLineUpView:OnDrop(comp, eventData) if not eventData.pointerEnter or not self.dragItemId or self.dragItemId <= 0 then self.dragItemId = nil return end local index = self.heroPanelId[eventData.pointerEnter.name] if MDL.Array.IsArrayPositionUnlock(index) then local oldHeroId = self.lineUpHeroList[index] local oldIndex = self:GetIndexByHeroId(self.dragItemId) if oldHeroId ~= self.dragItemId then self:StopEffectDuringDrag() self.ArrayShow:MoveModelToIndex(self.dragItemId, index) self.ArrayShow:MoveModelToIndex(oldHeroId, oldIndex) CTL.Sound.PlayGameSound("UI_sound_Qiejiang") if self.dropEffectId then AuxUtil.StopPsEffect(self.dropEffectId) end self.dropEffectId = SystemManager.PlayPsEffect(UIEffectPath.OnDropEffect, self.ArrayShow:GetHeroModelTransform(index):GetChild(0)) self:SetHero(self.dragItemId, index) end if self.FunctionType == MDL.Unlock.FunctionType.GVGFight then self:ReqFreeLineChange(MDL.FreeLineUp.FuncType.GvGFight) else self:SetLineUpHeroPower() end else local arrayData = DataSheetManager.BattleArray:GetDataByArrayID(index) CTL.Tips.AddTipsMsg(arrayData.UnlockDes, arrayData.UnlockConditionParam) end end function UICommonLineUpView:ShowAvailableEffectDuringDrag(index) if index and self.oldIndex ~= index then self.oldIndex = index self:StopEffectDuringDrag() local arrayIds = self.lineUpHeroList if arrayIds[index] and arrayIds[index] >= 0 then self.availableEffectId = SystemManager.PlayPsEffect(UIEffectPath.AllowLineUpEffect, self.ArrayShow:GetHeroModelTransform(index)) end end end function UICommonLineUpView:StopEffectDuringDrag() if self.availableEffectId then AuxUtil.StopPsEffect(self.availableEffectId) self.availableEffectId = nil end end function UICommonLineUpView:RefreshPanelEffect() local arrayIds = self.lineUpHeroList for i = 1, 6 do if arrayIds[i] < 0 then self:PlayUIEffect(UIEffectPath.LockEffect, i) end end end function UICommonLineUpView:PlayUIEffect(path, index) if self.effectId[index] then AuxUtil.StopPsEffect(self.effectId[index]) end self.effectId[index] = SystemManager.PlayPsEffect(path,self.ArrayShow:GetHeroModelTransform(index)) end function UICommonLineUpView:RefreshHeroCell(cellTable, data) local id = data.heroId UIUtils.SetLabel(cellTable.txt_ArrayCE, data.Gs) --上阵图标显示 if MDL.Player.HeroIsLineUp(id) then UIUtils.SetActive(cellTable.group_BgZhen.gameObject, true) else UIUtils.SetActive(cellTable.group_BgZhen.gameObject, false) end UTL.Item.SetHeroIconByHeroId(cellTable.btn_ClickItem, id, MDL.HeroAwaken.GetIsHeroAwaken(id)) UTL.Color.SetQualityImageByType(cellTable.img_Quality, CTL.HeroAwaken.GetHeroQuality(id, MDL.HeroAwaken.GetIsHeroAwaken(id)), UTL.Color.QualityType.HeroSelectBg) end return UICommonLineUpView