miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_RoleGodSoul...

209 lines
8.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

local GeneralBigPopup_RoleGodSoulUp = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
--初始化组件(用于子类重写)
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.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 ()
end)
Util.AddClick(self.sureBtn,function()
if self.isenuough then
NetManager.HeroGodSoulBindRequest(self.curHeroData.dynamicId,self.lv,self.choosedIdList,function()
parent:ClosePanel()
end)
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)
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
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")
self.itemlist[index].frame.sprite=self.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
self.itemlist[index].icon.sprite=self.spLoader:LoadSprite(heroData.icon)
end
self.itemlist[index].go.gameObject:SetActive(true)
if HarmonyManager.IsChangeColor(heroData.dynamicId) then
self.itemlist[index].lv.text="<color=#0f0>"..heroData.lv.."</color>"
elseif HarmonyManager:IsEnvoy(heroData.dynamicId) and HarmonyManager:HongMengTowerUpLimit() >= HarmonyManager.TowerStartLimit then
self.itemlist[index].lv.text="<color=#ffbe22>"..heroData.lv.."</color>"
else
self.itemlist[index].lv.text = heroData.lv
end
self.itemlist[index].name.text = heroData.heroConfig.ReadingName
self.itemlist[index].pro.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
self.itemlist[index].pos.sprite = self.spLoader:LoadSprite(heroData.professionIcon)
SetHeroStars(self.spLoader, self.itemlist[index].starGrid, heroData.star,1,Vector2.New(30,30),-8)
if self:CheckIsChooseId(heroData.dynamicId) then
self.itemlist[index].select.gameObject:SetActive(true)
else
self.itemlist[index].select.gameObject:SetActive(false)
if GodSoulManager.CheckExistBindHeroDataByDid(self.curHeroData.dynamicId,heroData.dynamicId) > 0 then
self.itemlist[index].using.gameObject:SetActive(true)
else
self.itemlist[index].using.gameObject:SetActive(false)
end
end
-- 点击事件
Util.AddOnceClick(self.itemlist[index]._go, function()
if self:CheckIsChooseId(heroData.dynamicId) then
table.removebyvalue(self.choosedIdList,heroData.dynamicId)
self.itemlist[index].select.gameObject:SetActive(false)
else
table.insert(self.choosedIdList,heroData.dynamicId)
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)
for i = 1,#self.choosedIdList do
if heroId == self.choosedIdList[i] then
return true
end
end
return false
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
self.costItemlist[i].frame.sprite = self.spLoader:LoadSprite("s_shenhunxitong_zuanshitouxiangkuang")
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].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].profession])
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("<color=#B5AA95>×%s</color>",self.costItems[i].num)
else
if self.enoughNums[i] >= self.costItems[i].num then
self.costItemlist[i].num.text = string.format("<color=#B5AA95>×%s</color>",self.costItems[i].num)
else
self.costItemlist[i].num.text = string.format("<color=#B5AA95>×%s</color>",self.costItems[i].num)
end
end
end
end
--界面关闭时调用(用于子类重写)
function GeneralBigPopup_RoleGodSoulUp:OnClose()
end
--界面销毁时调用(用于子类重写)
function GeneralBigPopup_RoleGodSoulUp:OnDestroy()
self.spLoader:Destroy()
self.itemlist = {}
self.costItemlist = {}
end
return GeneralBigPopup_RoleGodSoulUp