2021-10-22 15:47:59 +08:00
|
|
|
|
local GeneralBigPopup_RoleGodSoulUp = {}
|
|
|
|
|
|
--传入父脚本模块
|
|
|
|
|
|
local parent
|
|
|
|
|
|
--传入特效层级
|
|
|
|
|
|
local sortingOrder=0
|
|
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local curList = {}
|
2021-10-22 15:47:59 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
|
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")
|
2021-10-28 16:19:59 +08:00
|
|
|
|
self.costItem1 = Util.GetGameObject(gameObject, "costItem")
|
2021-10-22 15:47:59 +08:00
|
|
|
|
self.costGrid = Util.GetGameObject(gameObject, "costItem/costGrid")
|
|
|
|
|
|
|
|
|
|
|
|
self.oneKeyBtn = Util.GetGameObject(gameObject, "oneKey")
|
|
|
|
|
|
self.sureBtn = Util.GetGameObject(gameObject, "sure")
|
|
|
|
|
|
|
|
|
|
|
|
self.itemlist = {}
|
|
|
|
|
|
self.costItemlist = {}
|
|
|
|
|
|
self.choosedIdList = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
|
function GeneralBigPopup_RoleGodSoulUp:BindEvent()
|
|
|
|
|
|
Util.AddClick(self.oneKeyBtn,function ()
|
2021-10-27 12:50:15 +08:00
|
|
|
|
local isenuough,enoughNums,enoughDatas,oldEnoughDatas = false,nil,nil,nil
|
|
|
|
|
|
self.choosedIdList = {}
|
|
|
|
|
|
for i = 1,#self.allDatas do
|
2021-10-26 16:00:31 +08:00
|
|
|
|
table.insert(self.choosedIdList,self.allDatas[i].herodata.dynamicId)
|
2021-10-27 12:50:15 +08:00
|
|
|
|
isenuough,enoughNums,enoughDatas = GodSoulManager.CheckCanUpGodSoul(self.curHeroData,self.lv,self.choosedIdList)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if isenuough then
|
|
|
|
|
|
self:RefreshCostItemNums()
|
2021-10-27 12:50:15 +08:00
|
|
|
|
self:RefreshItemDatas()
|
2021-10-26 16:00:31 +08:00
|
|
|
|
break
|
2021-10-27 12:50:15 +08:00
|
|
|
|
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
|
2021-10-26 16:00:31 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2021-10-27 12:50:15 +08:00
|
|
|
|
if not isenuough then
|
|
|
|
|
|
PopupTipPanel.ShowTip("无法满足激活条件!")
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end)
|
|
|
|
|
|
Util.AddClick(self.sureBtn,function()
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local isSave = false
|
2021-10-22 15:47:59 +08:00
|
|
|
|
if self.isenuough then
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if #curList == #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
|
2021-10-22 15:47:59 +08:00
|
|
|
|
parent:ClosePanel()
|
2021-10-26 16:00:31 +08:00
|
|
|
|
end
|
|
|
|
|
|
elseif #self.choosedIdList == 0 then
|
|
|
|
|
|
PopupTipPanel.ShowTip("请选择神将!")
|
|
|
|
|
|
else
|
|
|
|
|
|
PopupTipPanel.ShowTip("所选神将无法激活神魂效果!")
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
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.allDatas = GodSoulManager.GetGodSoulData(self.curHeroData,self.lv)
|
|
|
|
|
|
self.choosedIdList = GodSoulManager.GetBindHeroDatasByLevel(self.curHeroData.dynamicId,self.lv)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
curList = GodSoulManager.GetBindHeroDatasByLevel(self.curHeroData.dynamicId,self.lv)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
self:Refresh(true,true)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function GeneralBigPopup_RoleGodSoulUp:Refresh(isTop,isAni)
|
|
|
|
|
|
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)
|
|
|
|
|
|
self:UpdateCostItem()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
2021-10-22 15:47:59 +08:00
|
|
|
|
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].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
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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))
|
|
|
|
|
|
self.itemlist[index].icon.sprite=self.spLoader:LoadSprite(self.itemlist[index].data.icon)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
self.itemlist[index].go.gameObject:SetActive(true)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
if HarmonyManager.IsChangeColor(self.itemlist[index].data.dynamicId) then
|
|
|
|
|
|
self.itemlist[index].lv.text="<color=#0f0>"..self.itemlist[index].data.lv.."</color>"
|
|
|
|
|
|
elseif HarmonyManager:IsEnvoy(self.itemlist[index].data.dynamicId) and HarmonyManager:HongMengTowerUpLimit() >= HarmonyManager.TowerStartLimit then
|
|
|
|
|
|
self.itemlist[index].lv.text="<color=#ffbe22>"..self.itemlist[index].data.lv.."</color>"
|
2021-10-22 15:47:59 +08:00
|
|
|
|
else
|
2021-10-26 16:00:31 +08:00
|
|
|
|
self.itemlist[index].lv.text = self.itemlist[index].data.lv
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local star,starType = self.itemlist[index].data.GetStar(1)
|
2021-10-27 12:50:15 +08:00
|
|
|
|
local starSize = Vector2.New(30,30)
|
|
|
|
|
|
local starScale = -8
|
|
|
|
|
|
if starType == 3 then
|
|
|
|
|
|
starSize = Vector2.New(33.43,83.61)
|
2021-10-28 11:07:50 +08:00
|
|
|
|
starScale = -13.77
|
2021-10-27 12:50:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
SetHeroStars(self.spLoader, self.itemlist[index].starGrid, star,starType,starSize,starScale)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
|
2021-10-26 16:00:31 +08:00
|
|
|
|
self.itemlist[index].select.gameObject:SetActive(false)
|
|
|
|
|
|
self.itemlist[index].mask.gameObject:SetActive(false)
|
|
|
|
|
|
self.itemlist[index].using.gameObject:SetActive(false)
|
|
|
|
|
|
if self:CheckIsChooseId(self.itemlist[index].data.dynamicId) > 0 then
|
2021-10-22 15:47:59 +08:00
|
|
|
|
self.itemlist[index].select.gameObject:SetActive(true)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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)
|
2021-10-28 16:19:59 +08:00
|
|
|
|
self.itemlist[index].mask.gameObject:SetActive(true)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 点击事件
|
|
|
|
|
|
Util.AddOnceClick(self.itemlist[index]._go, function()
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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 then
|
|
|
|
|
|
table.remove(self.choosedIdList,isChoosed)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
self.itemlist[index].select.gameObject:SetActive(false)
|
|
|
|
|
|
else
|
2021-10-26 16:00:31 +08:00
|
|
|
|
table.insert(self.choosedIdList,self.itemlist[index].data.dynamicId)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
self.itemlist[index].select.gameObject:SetActive(true)
|
|
|
|
|
|
end
|
|
|
|
|
|
self:RefreshCostItemNums()
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
Util.AddLongPressClick(self.itemlist[index]._go, function()
|
|
|
|
|
|
|
|
|
|
|
|
end, 0.5)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function GeneralBigPopup_RoleGodSoulUp:CheckIsChooseId(heroId)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
local index = 0
|
2021-10-22 15:47:59 +08:00
|
|
|
|
for i = 1,#self.choosedIdList do
|
|
|
|
|
|
if heroId == self.choosedIdList[i] then
|
2021-10-26 16:00:31 +08:00
|
|
|
|
index = i
|
|
|
|
|
|
return index
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2021-10-26 16:00:31 +08:00
|
|
|
|
return index
|
2021-10-22 15:47:59 +08:00
|
|
|
|
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
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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
|
2021-10-22 15:47:59 +08:00
|
|
|
|
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)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite(PropertySmallIcon[self.costItems[i].star][self.costItems[i].property])
|
2021-10-22 15:47:59 +08:00
|
|
|
|
elseif self.costItems[i].profession > 0 then
|
|
|
|
|
|
self.costItemlist[i].icon.gameObject:SetActive(false)
|
2021-10-26 16:00:31 +08:00
|
|
|
|
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])
|
2021-10-22 15:47:59 +08:00
|
|
|
|
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
|
2021-10-26 16:00:31 +08:00
|
|
|
|
self.costItemlist[i].num.text = string.format("<color=#00FF00>×%s</color>",self.costItems[i].num)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
else
|
|
|
|
|
|
if self.enoughNums[i] >= self.costItems[i].num then
|
2021-10-26 16:00:31 +08:00
|
|
|
|
self.costItemlist[i].num.text = string.format("<color=#00FF00>×%s</color>",self.costItems[i].num)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
else
|
2021-10-26 16:00:31 +08:00
|
|
|
|
self.costItemlist[i].num.text = string.format("<color=#FF0000>×%s</color>",self.costItems[i].num)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
2021-10-28 16:19:59 +08:00
|
|
|
|
ForceRebuildLayout(self.costItem1.transform)
|
2021-10-22 15:47:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
|
function GeneralBigPopup_RoleGodSoulUp:OnClose()
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
|
function GeneralBigPopup_RoleGodSoulUp:OnDestroy()
|
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
|
self.itemlist = {}
|
|
|
|
|
|
self.costItemlist = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return GeneralBigPopup_RoleGodSoulUp
|