miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_ChooseUpHero.lua

120 lines
4.3 KiB
Lua
Raw Normal View History

2021-05-28 10:36:55 +08:00
----- 送神弹窗 -----
local this = {}
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local args=nil
local currHeroId=0
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
2021-05-31 11:31:15 +08:00
this.titleText.text="许愿神将"
2021-05-28 10:36:55 +08:00
this.cancelBtn=Util.GetGameObject(gameObject,"CancelBtn")
this.confirmBtn=Util.GetGameObject(gameObject,"ConfirmBtn")
this.FourStarUpTip=Util.GetGameObject(gameObject,"tip"):GetComponent("Text")
this.FourStarUpTip.text = "长按头像可查看神将详情"
this.selectObj=Util.GetGameObject(gameObject,"choosed")
this.prefab=Util.GetGameObject(gameObject,"item")
--滚动条根节点
this.root = Util.GetGameObject(gameObject, "Root")
this.preList={}
end
function this:BindEvent()
Util.AddClick(this.cancelBtn,function()
parent:ClosePanel()
end)
Util.AddClick(this.confirmBtn,function()
NetManager.ChoiceHeroRewardRequest(args[1],currHeroId,function()
ActivityGiftManager.SetActivityInfoRewardId(args[1],currHeroId)
Game.GlobalEvent:DispatchEvent(GameEvent.Activity.TimeLimitUpHeroChange,currHeroId)
2021-05-28 10:36:55 +08:00
parent:ClosePanel()
end)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
args = {...}
local upConfig=ConfigManager.GetConfigDataByKey(ConfigName.WishActivityUp,"ActivityId",args[1])
if not upConfig then
return
end
local str=upConfig.UpList
local heros={}
for i = 1, #str do
table.insert(heros,str[i][1])
end
local heroDatas={}
currHeroId=args[2]
for i = 1, #heros do
table.insert(heroDatas,heroConfig[heros[i]])
end
for i = 1, math.max(#this.preList,#heroDatas) do
local item=this.preList[i]
if not item then
item=newObject(this.prefab)
item.transform:SetParent(this.root.transform)
item.transform.localScale=Vector3.one
item.transform.localPosition=Vector3.zero
this.preList[i]=item
end
item.gameObject:SetActive(false)
end
for key, value in pairs(heroDatas) do
this.SingleHeroDataShow(this.preList[key],heroDatas[key])
end
end
--英雄单个数据展示
function this.SingleHeroDataShow(go,_heroData)
local heroData = _heroData
local _go = go
_go.gameObject:SetActive(true)
Util.GetGameObject(_go.transform, "frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.Quality,heroData.Star))
Util.GetGameObject(_go.transform, "Text"):GetComponent("Text").text = SubString2(GetLanguageStrById(heroData.ReadingName),8)
Util.GetGameObject(_go.transform, "icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(artResourcesConfig[_heroData.Icon].Name)
Util.GetGameObject(_go.transform, "posIcon"):SetActive(false)
Util.GetGameObject(_go.transform, "proIcon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.PropertyName))
local starGrid = Util.GetGameObject(_go.transform, "star")
if _heroData.Id==currHeroId then
this.selectObj.transform:SetParent(_go.transform)
this.selectObj.transform.localScale=Vector3.one
this.selectObj.transform.localPosition=Vector3.New(0,30,0)
end
SetHeroStars(this.spLoader, starGrid, heroData.Star,1,nil,-15)
local cardclickBtn = Util.GetGameObject(_go.transform, "icon")
Util.AddOnceClick(cardclickBtn, function()
this.selectObj.transform:SetParent(_go.transform)
this.selectObj.transform.localScale=Vector3.one
this.selectObj.transform.localPosition=Vector3.New(0,30,0)
currHeroId=_heroData.Id
end)
Util.AddLongPressClick(cardclickBtn, function()
UIManager.OpenPanel(UIName.RoleGetInfoPopup, false, heroData.Id, heroData.Star)
end, 0.5)
end
function this:OnClose()
currHeroId=0
args=nil
end
function this:OnDestroy()
this.spLoader:Destroy()
end
return this