local GeneralBigPopup_RoleGodSoulUp = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig) local curList = {} local oldSelect = 0 --初始化组件(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:InitComponent(gameObject) self.spLoader = SpriteLoader.New() self.Scroll = Util.GetGameObject(gameObject,"Scroll") self.itemPre = Util.GetGameObject(gameObject,"itemPre") local rootHight = self.Scroll.transform.rect.height local width = self.Scroll.transform.rect.width self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.Scroll.transform, self.itemPre,nil, Vector2.New(width, rootHight), 1, 5,Vector2.New(20, 10)) self.ScrollView.moveTween.MomentumAmount = 1 self.ScrollView.moveTween.Strength = 2 self.ScrollView.elastic = false self.costItemPre = Util.GetGameObject(gameObject, "costPre") self.costItem1 = Util.GetGameObject(gameObject, "costItem") self.costGrid = Util.GetGameObject(gameObject, "costItem/costGrid") self.oneKeyBtn = Util.GetGameObject(gameObject, "oneKey") self.sureBtn = Util.GetGameObject(gameObject, "sure") self.bglist = Util.GetGameObject(gameObject,"bglist") self.heroSelect = Util.GetGameObject(gameObject,"heroSelect") self.select = Util.GetGameObject(gameObject,"select") self.reSelectList = {} for i = 1,self.bglist.transform.childCount do if not self.reSelectList[i] then self.reSelectList[i] = {} end self.reSelectList[i].go = Util.GetGameObject(self.bglist,"itemPre"..i) self.reSelectList[i].btn = Util.GetGameObject(self.reSelectList[i].go,"HeroPre") self.reSelectList[i].frame = Util.GetGameObject(self.reSelectList[i].btn,"frame"):GetComponent("Image") self.reSelectList[i].icon = Util.GetGameObject(self.reSelectList[i].btn,"icon"):GetComponent("Image") self.reSelectList[i].posIcon = Util.GetGameObject(self.reSelectList[i].btn,"posIcon"):GetComponent("Image") self.reSelectList[i].proIcon = Util.GetGameObject(self.reSelectList[i].btn,"proIcon"):GetComponent("Image") self.reSelectList[i].star = Util.GetGameObject(self.reSelectList[i].btn,"star") self.reSelectList[i].name = Util.GetGameObject(self.reSelectList[i].btn,"name"):GetComponent("Text") end self.itemlist = {} self.costItemlist = {} self.choosedIdList = {} end --绑定事件(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:BindEvent() -- Util.AddClick(self.oneKeyBtn,function () -- local isenuough,enoughNums,enoughDatas,oldEnoughDatas = false,nil,nil,nil -- self.choosedIdList = {} -- for i = 1,#self.allDatas do -- table.insert(self.choosedIdList,self.allDatas[i].herodata.dynamicId) -- isenuough,enoughNums,enoughDatas = GodSoulManager.CheckCanUpGodSoul(self.curHeroData,self.lv,self.choosedIdList) -- if isenuough then -- self:RefreshCostItemNums() -- self:RefreshItemDatas() -- break -- else -- if not oldEnoughDatas then -- oldEnoughDatas = enoughDatas -- else -- local ismove = true -- for k,v in pairs(oldEnoughDatas) do -- if v ~= enoughDatas[k] then -- ismove = false -- break -- end -- end -- if ismove then -- table.remove(self.choosedIdList,#self.choosedIdList) -- end -- oldEnoughDatas = enoughDatas -- end -- end -- end -- if not isenuough then -- PopupTipPanel.ShowTip("无法满足激活条件!") -- return -- end -- end) Util.AddClick(self.sureBtn,function() local curLv = GodSoulManager.GetGodSoulLv(self.curHeroData.dynamicId) if self.lv > curLv + 1 then PopupTipPanel.ShowTip("需要激活上一个神魂才可解锁!") return end if self:CheckEmptyList() then PopupTipPanel.ShowTip("请选择神将!") return end if self:CheckHaveEmptyValue() then PopupTipPanel.ShowTip("所选神将无法激活神魂效果!") return end local isSave = false --已激活 if #curList > 0 then if #curList == LengthOfTable(self.choosedIdList) then for i = 1,#curList do if self:CheckIsChooseId(curList[i]) < 1 then isSave = true break end end else isSave = true end if isSave then NetManager.HeroGodSoulBindRequest(self.curHeroData.dynamicId,self.lv,self.choosedIdList,function() parent:ClosePanel() end) else parent:ClosePanel() end else NetManager.HeroGodSoulBindRequest(self.curHeroData.dynamicId,self.lv,self.choosedIdList,function() parent:ClosePanel() end) end end) for i = 1,self.bglist.transform.childCount do Util.AddClick(self.reSelectList[i].btn,function() if i == self.curPage then return end self.curPage = i self:SetSeclet(self.select,self.reSelectList[self.curPage].go.transform,Vector3.New(0,-75,0)) self:Refresh(true,false) end) end end function GeneralBigPopup_RoleGodSoulUp:CheckHaveEmptyValue() for k,v in pairs(self.choosedIdList) do if not v or v == "" then return true end end return false end function GeneralBigPopup_RoleGodSoulUp:CheckEmptyList() for k,v in pairs(self.choosedIdList) do if v and v ~= "" then return false end end return true end --添加事件监听(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:AddListener() end --移除事件监听(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:RemoveListener() end --界面打开时调用(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:OnShow(_parent,_Data) parent =_parent sortingOrder = _parent.sortingOrder self.costItems = _Data[1] self.curHeroData = _Data[2] self.lv = _Data[3] self.curPage = _Data[4] or 1 self.choosedIdList = GodSoulManager.GetBindHeroDatasByLevel(self.curHeroData.dynamicId,self.lv) if LengthOfTable(self.choosedIdList) < 1 then for i = 1,#self.costItems do self.choosedIdList[i] = "" end end curList = GodSoulManager.GetBindHeroDatasByLevel(self.curHeroData.dynamicId,self.lv) self:Refresh(true,true) self:SetCostItem(true) self:SetSeclet(self.select,self.reSelectList[self.curPage].go.transform,Vector3.New(0,-75,0)) end function GeneralBigPopup_RoleGodSoulUp:SetCostItem(isAllRefresh) for i = 1, math.max(#self.reSelectList,#self.costItems) do if not self.costItems[i] then self.reSelectList[i].go.gameObject:SetActive(false) else if not self.reSelectList[i] then self.reSelectList[i] = {} self.reSelectList[i].go = newObjToParent(self.reSelectList[1].go,self.bglist.transform) self.reSelectList[i].btn = Util.GetGameObject(self.reSelectList[i].go,"HeroPre") self.reSelectList[i].frame = Util.GetGameObject(self.reSelectList[i].btn,"frame"):GetComponent("Image") self.reSelectList[i].icon = Util.GetGameObject(self.reSelectList[i].btn,"icon"):GetComponent("Image") self.reSelectList[i].posIcon = Util.GetGameObject(self.reSelectList[i].btn,"posIcon"):GetComponent("Image") self.reSelectList[i].proIcon = Util.GetGameObject(self.reSelectList[i].btn,"proIcon"):GetComponent("Image") self.reSelectList[i].star = Util.GetGameObject(self.reSelectList[i].btn,"star") self.reSelectList[i].name = Util.GetGameObject(self.reSelectList[i].btn,"name"):GetComponent("Text") end self.reSelectList[i].go.gameObject:SetActive(true) end end self:RefreshCostItemNums2(true) end function GeneralBigPopup_RoleGodSoulUp:SetSeclet(select,selectPar,pos) select.gameObject:SetActive(true) select.transform:SetParent(selectPar) select.gameObject:GetComponent("RectTransform").anchoredPosition3D = pos select.transform.localScale = Vector3.one end function GeneralBigPopup_RoleGodSoulUp:Refresh(isTop,isAni) self.allDatas = GodSoulManager.GetGodSoulData(self.curHeroData,self.lv,self.curPage) if self.choosedIdList[self.curPage] and self.choosedIdList[self.curPage] ~= "" then for i = 1,#self.allDatas do if self.allDatas[i].herodata.dynamicId == self.choosedIdList[self.curPage] then self.allDatas[i].state = 999 end end table.sort(self.allDatas,function(a,b) if a.state == b.state then if a.herodata.star == b.herodata.star then return a.herodata.star > b.herodata.star end return a.herodata.heroConfig.Sort < b.herodata.heroConfig.Sort end return a.state > b.state end) end if not self.itemlist then self.itemlist = {} end for k,v in ipairs(self.itemlist) do v.go.gameObject:SetActive(false) end self.ScrollView:SetData(self.allDatas, function(index, go) self:SetSingleData(index,go,self.allDatas[index]) end,not isTop,not isAni) end function GeneralBigPopup_RoleGodSoulUp:RefreshItemDatas() for k,v in ipairs(self.itemlist) do if self:CheckIsChooseId(v.data.dynamicId) > 0 then v.select.gameObject:SetActive(true) else v.select.gameObject:SetActive(false) end end end function GeneralBigPopup_RoleGodSoulUp:SetSingleData(index,go,heroData) if not self.itemlist[index] then self.itemlist[index] = {} self.itemlist[index].go = go self.itemlist[index].mask = Util.GetGameObject(go,"mask") self.itemlist[index].allSelect = Util.GetGameObject(go,"allSelect") self.itemlist[index].select = Util.GetGameObject(go,"select") self.itemlist[index].using = Util.GetGameObject(go,"using") self.itemlist[index]._go = Util.GetGameObject(go,"HeroPre") self.itemlist[index].frame = Util.GetGameObject(self.itemlist[index]._go,"frame"):GetComponent("Image") self.itemlist[index].icon = Util.GetGameObject(self.itemlist[index]._go, "icon"):GetComponent("Image") self.itemlist[index].pos = Util.GetGameObject(self.itemlist[index]._go, "posIcon"):GetComponent("Image") self.itemlist[index].pro = Util.GetGameObject(self.itemlist[index]._go, "proIcon"):GetComponent("Image") self.itemlist[index].lv = Util.GetGameObject(self.itemlist[index]._go, "lv/Text"):GetComponent("Text") self.itemlist[index].name = Util.GetGameObject(self.itemlist[index]._go, "name"):GetComponent("Text") self.itemlist[index].starGrid = Util.GetGameObject(self.itemlist[index]._go, "star") end self.itemlist[index]._data = heroData self.itemlist[index].data = heroData.herodata self.itemlist[index].frame.sprite=self.spLoader:LoadSprite(GetHeroQuantityImageByquality(self.itemlist[index].data.heroConfig.Quality,self.itemlist[index].data.star)) SetHeroIcon(self.spLoader,self.itemlist[index]._data,self.itemlist[index].icon,self.itemlist[index].data.heroConfig) self.itemlist[index].go.gameObject:SetActive(true) if HarmonyManager.IsChangeColor(self.itemlist[index].data.dynamicId) then self.itemlist[index].lv.text=""..self.itemlist[index].data.lv.."" elseif HarmonyManager:IsEnvoy(self.itemlist[index].data.dynamicId) and HarmonyManager:HongMengTowerUpLimit() >= HarmonyManager.TowerStartLimit then self.itemlist[index].lv.text=""..self.itemlist[index].data.lv.."" else self.itemlist[index].lv.text = self.itemlist[index].data.lv end self.itemlist[index].name.text = self.itemlist[index].data.heroConfig.ReadingName self.itemlist[index].pro.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(self.itemlist[index].data.heroConfig.PropertyName)) self.itemlist[index].pos.sprite = self.spLoader:LoadSprite(self.itemlist[index].data.professionIcon) local star,starType = self.itemlist[index].data.GetStar(1) local starSize = Vector2.New(30,30) local starScale = -8 if starType == 3 then starSize = Vector2.New(1,-15.65) starScale = -13 elseif starType == 2 then starSize = Vector2.New(60,57) end SetHeroStars(self.spLoader, self.itemlist[index].starGrid, star,starType,starSize,starScale) Util.SetParticleSortLayer(self.itemlist[index].starGrid, sortingOrder + 1) self.itemlist[index].mask.gameObject:SetActive(false) self.itemlist[index].using.gameObject:SetActive(false) self.itemlist[index].allSelect.gameObject:SetActive(false) self.itemlist[index].select.gameObject:SetActive(false) local location = self:CheckIsChooseId(self.itemlist[index].data.dynamicId) if location > 0 and location == self.curPage then oldSelect = index self:SetSeclet(self.itemlist[index].select,self.itemlist[index].go.transform,Vector3.New(0,-75,0)) elseif location > 0 then self.itemlist[index].allSelect.gameObject:SetActive(true) elseif self.itemlist[index]._data.state == -1 then self.itemlist[index].mask.gameObject:SetActive(true) elseif self.itemlist[index]._data.state == 0 or self.itemlist[index]._data.state == 664 then self.itemlist[index].using.gameObject:SetActive(true) self.itemlist[index].mask.gameObject:SetActive(true) else end -- 点击事件 Util.AddOnceClick(self.itemlist[index]._go, function() if self.itemlist[index]._data.state == -1 then PopupTipPanel.ShowTip("该神将无法放入所选格子中!") return end if self.itemlist[index]._data.state == 0 or self.itemlist[index]._data.state == 664 then PopupTipPanel.ShowTip("该神将已用于激活其他等级的神魂!") return end local isChoosed = self:CheckIsChooseId(self.itemlist[index].data.dynamicId) if isChoosed > 0 and isChoosed ~= self.curPage then PopupTipPanel.ShowTip("该神将正处于其他格子中,无法选择!") return end if isChoosed > 0 then self.choosedIdList[self.curPage] = "" self.itemlist[index].select.gameObject:SetActive(false) else self.choosedIdList[self.curPage] = self.itemlist[index].data.dynamicId if self.itemlist[oldSelect] then self.itemlist[oldSelect].select.gameObject:SetActive(false) end oldSelect = index self:SetSeclet(self.itemlist[index].select,self.itemlist[index].go.transform,Vector3.New(0,-72,0)) end self:RefreshCostItemNums2(false) if self.choosedIdList[self.curPage] ~= "" then for m = self.curPage + 1,#self.costItems do if not self.choosedIdList[m] or self.choosedIdList[m] == "" then self.curPage = m self:SetSeclet(self.select,self.reSelectList[self.curPage].go.transform,Vector3.New(0,-75,0)) self:Refresh(true,false) break end end end end) Util.AddLongPressClick(self.itemlist[index]._go, function() end, 0.5) end function GeneralBigPopup_RoleGodSoulUp:CheckIsChooseId(heroId) local index = 0 for k,v in pairs(self.choosedIdList) do if heroId == v then index = k return index end end return index end function GeneralBigPopup_RoleGodSoulUp:UpdateCostItem() for i = 1,math.max(#self.costItemlist,#self.costItems) do if not self.costItems[i] then self.costItemlist[i].go.gameObject:SetActive(false) else if not self.costItemlist[i] then self.costItemlist[i] = {} self.costItemlist[i].go = newObjToParent(self.costItemPre,self.costGrid) self.costItemlist[i].frame = Util.GetGameObject(self.costItemlist[i].go,"frame"):GetComponent("Image") self.costItemlist[i].icon = Util.GetGameObject(self.costItemlist[i].frame.transform,"icon"):GetComponent("Image") self.costItemlist[i].num = Util.GetGameObject(self.costItemlist[i].go,"num"):GetComponent("Text") end self.costItemlist[i].go.gameObject:SetActive(true) if self.costItems[i].id > 0 then if self.costItems[i].star > 10 then self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite("s_shenhunxitong_zuanshitouxiangkuang") else self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite("s_shenhunxitong_hong") end self.costItemlist[i].icon.gameObject:SetActive(true) self.costItemlist[i].icon.sprite = self.spLoader:LoadSprite(GetResourcePath(heroConfig[self.costItems[i].id].Icon)) elseif self.costItems[i].property > 0 then self.costItemlist[i].icon.gameObject:SetActive(false) self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite(PropertySmallIcon[self.costItems[i].star][self.costItems[i].property]) elseif self.costItems[i].profession > 0 then self.costItemlist[i].icon.gameObject:SetActive(false) self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite(GodSoulProfession[self.costItems[i].star][self.costItems[i].profession]) else self.costItemlist[i].icon.gameObject:SetActive(false) self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite(StarImage[self.costItems[i].star]) end end end self:RefreshCostItemNums() end function GeneralBigPopup_RoleGodSoulUp:RefreshCostItemNums() self.isenuough,self.enoughNums = GodSoulManager.CheckCanUpGodSoul(self.curHeroData,self.lv,self.choosedIdList) for i = 1,#self.enoughNums do if self.isenuough then self.costItemlist[i].num.text = string.format("×%s",self.costItems[i].num) else if self.enoughNums[i] >= self.costItems[i].num then self.costItemlist[i].num.text = string.format("×%s",self.costItems[i].num) else self.costItemlist[i].num.text = string.format("×%s",self.costItems[i].num) end end end ForceRebuildLayout(self.costItem1.transform) end function GeneralBigPopup_RoleGodSoulUp:RefreshCostItemNums2(isAllRefresh) for i = 1, #self.costItems do if isAllRefresh or (not isAllRefresh and i == self.curPage) then local str = "" if self.costItems[i].star > 10 then str = "觉醒" else str = "十星" end if self.costItems[i].id > 0 then str = str..heroConfig[self.costItems[i].id].ReadingName elseif self.costItems[i].property > 0 then str = PropertyType[self.costItems[i].property]..str.."神将" elseif self.costItems[i].profession > 0 then str = str..ProfessionType[self.costItems[i].profession].."神将" else str = "任意"..str.."神将" end if self.choosedIdList[self.curPage] and self.choosedIdList[self.curPage] ~= "" then self.reSelectList[i].name.text = string.format("%s",str) self.reSelectList[i].posIcon.gameObject:SetActive(true) self.reSelectList[i].proIcon.gameObject:SetActive(true) local tempHeroData = HeroManager.GetSingleHeroData(self.choosedIdList[i]) self.reSelectList[i].frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(tempHeroData.heroConfig.Quality,tempHeroData.star)) SetHeroIcon(self.spLoader,tempHeroData,self.reSelectList[i].icon,tempHeroData.heroConfig) local star,starType = tempHeroData.GetStar(1) local starSize = Vector2.New(60,60) local starScale = -8 if starType == 3 then starSize = Vector2.New(1,-15.63) starScale = -14.64 elseif starType == 2 then starSize = Vector2.New(60,57) end SetHeroStars(self.spLoader,self.reSelectList[i].star,star,starType,starSize,starScale) Util.SetParticleSortLayer(self.reSelectList[i].star,sortingOrder + 1) self.reSelectList[i].proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(tempHeroData.heroConfig.PropertyName)) self.reSelectList[i].posIcon.sprite = self.spLoader:LoadSprite(tempHeroData.professionIcon) Util.SetGray(self.reSelectList[i].icon.gameObject,false) Util.SetGray(self.reSelectList[i].name.gameObject,false) else self.reSelectList[i].name.text = string.format("%s",str) self.reSelectList[i].frame.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(self.costItems[i].star,self.costItems[i].star)) SetHeroStars(self.spLoader,self.reSelectList[i].star,self.costItems[i].star,1,Vector2.New(60,57)) self.reSelectList[i].posIcon.gameObject:SetActive(false) self.reSelectList[i].proIcon.gameObject:SetActive(false) if self.costItems[i].id > 0 then self.reSelectList[i].icon.sprite = self.spLoader:LoadSprite(GetResourcePath(heroConfig[self.costItems[i].id].Icon)) Util.SetGray(self.reSelectList[i].icon.gameObject,true) else self.reSelectList[i].icon.sprite = self.spLoader:LoadSprite("r_hero_jinjie-touxiang2") if self.costItems[i].property > 0 then self.reSelectList[i].proIcon.gameObject:SetActive(true) self.reSelectList[i].proIcon.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(self.costItems[i].property)) elseif self.costItems[i].profession > 0 then self.reSelectList[i].posIcon.gameObject:SetActive(true) self.reSelectList[i].posIcon.sprite = self.spLoader:LoadSprite(GetHeroPosStr(self.costItems[i].profession)) else end Util.SetGray(self.reSelectList[i].icon.gameObject,false) end Util.SetGray(self.reSelectList[i].name.gameObject,true) end end end end --界面关闭时调用(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:OnClose() self.heroSelect.gameObject:SetActive(false) self.select.gameObject:SetActive(false) self.choosedIdList = {} Game.GlobalEvent:DispatchEvent(GameEvent.Role.RefreshSodSoulLayoutEffectMask) end --界面销毁时调用(用于子类重写) function GeneralBigPopup_RoleGodSoulUp:OnDestroy() self.spLoader:Destroy() self.itemlist = {} self.costItemlist = {} end return GeneralBigPopup_RoleGodSoulUp