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

171 lines
5.1 KiB
Lua
Raw Normal View History

----- 归元弹窗 -----
local this = {}
--传入父脚本模块
local parent
--层级
local sortingOrder = 0
--传入不定参
local _args = {}
--传入选择英雄计算返回奖励数据列表
local dropList = {}
--item容器
local itemList = {}
--传入选择英雄
local selectHeroData
local heroConfig=ConfigManager.GetConfig(ConfigName.HeroConfig)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local proId=0
local isCan=false
local curProId=0
local costConfig=ConfigManager.GetConfigData(ConfigName.SpecialConfig,147)
local itemNum=0
local costId=0
local func=nil
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
this.titleText = Util.GetGameObject(gameObject, "TitleText"):GetComponent("Text")
this.bodyText = Util.GetGameObject(gameObject, "BodyText"):GetComponent("Text")
this.cancelBtn = Util.GetGameObject(gameObject, "CancelBtn")
this.confirmBtn = Util.GetGameObject(gameObject, "ConfirmBtn")
this.itemImage = Util.GetGameObject(gameObject, "ConfirmBtn/itemImage"):GetComponent("Image")
this.itemImageText = Util.GetGameObject(gameObject, "ConfirmBtn/itemText"):GetComponent("Text")
this.selectBtn=Util.GetGameObject(gameObject, "Tabs/selectBtn")
this.hintTxt=Util.GetGameObject(gameObject, "tipTxt")
this.btns={}
2023-04-18 15:34:22 +08:00
for i = 1, 5 do
this.btns[i]=Util.GetGameObject(gameObject, "Tabs/grid/Btn"..i)
end
end
--页签选中效果设置
function this:SetSelectBtn(index)
this.selectBtn.transform:SetParent(this.btns[index].transform)
this.selectBtn.transform.localScale = Vector3.one
this.selectBtn.transform.localPosition=Vector3.zero
end
function this:BindEvent()
Util.AddClick(this.cancelBtn,function()
parent:ClosePanel()
end)
2023-04-18 15:34:22 +08:00
for i = 1, 5 do
Util.AddClick(this.btns[i], function()
if i == curProId then
return
end
proId=i
this:SetSelectBtn(i)
end)
end
Util.AddClick(this.confirmBtn,function()
if not isCan and selectHeroData.changeProId~=5 then
LogError("costid=="..costId)
PopupTipPanel.ShowTip(string.format( Language[10298],itemConfig[costId].Name))
return
end
local state=PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_ChangeHeroProConfirm")
if curProId==proId then
return
end
if selectHeroData.changeProId==5 then
this:ChangeHeroPro()
return
end
if state==1 then
this:ChangeHeroPro()
else
UIManager.OpenPanel(UIName.ChangeHeroProConfirmWindow,CostConfirmType.ChangeHeroPro,function()
this:ChangeHeroPro()
end)
end
end)
end
function this:ChangeHeroPro()
NetManager.ChangeHeroPro(selectHeroData.dynamicId,proId,function()
curProId=proId
parent:ClosePanel()
if func then
func()
end
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,...)
parent=_parent
sortingOrder =_parent.sortingOrder
local args = {...}
selectHeroData = args[1]
func=args[2]
LogError("selectHeroData.changeProId== "..selectHeroData.changeProId)
curProId=selectHeroData.changeProId
-- if curProId==5 then
-- proId=1
-- else
-- proId=curProId
-- end
for i = 1, 5 do
if i~=curProId then
proId=i
break
end
end
itemNum=0
this.titleText.text="阵营转换"
--this.bodyText.text = string.format("归元神将会返还所有的升级材料神将重置为1级\n 此操作不可逆,是否确认归元?")
for i = 1, #this.btns do
Util.GetGameObject(this.btns[i], "Image"):GetComponent("Image").sprite=this.spLoader:LoadSprite(GetProStrImageByProNum(i))
if i==curProId then
Util.SetGray(this.btns[i],true)
else
Util.SetGray(this.btns[i],false)
end
end
this:SetSelectBtn(proId)
if curProId==5 then
this.hintTxt.gameObject:SetActive(true)
this.itemImage.gameObject:SetActive(false)
this.itemImageText.gameObject:SetActive(false)
else
this.hintTxt.gameObject:SetActive(false)
this.itemImage.gameObject:SetActive(true)
this.itemImageText.gameObject:SetActive(true)
end
this:RefreshCostShow()
end
function this:RefreshCostShow()
if costConfig then
local cost=string.split(costConfig.Value,('#'))
costId=tonumber(cost[1])
itemNum = BagManager.GetItemCountById(costId)
if itemNum >=tonumber(cost[2]) then
this.itemImageText.text = string.format("<color=#FFF8EC>×%s</color>", cost[2])
isCan=true
else
isCan=false
this.itemImageText.text = string.format("<color=#C66366FF>×%s</color>", cost[2])
end
this.itemImage.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[tonumber(cost[1])].ResourceID))
end
end
function this:OnClose()
end
function this:OnDestroy()
this.spLoader:Destroy()
end
return this