miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/View/GeneralPopup_QiJieSingleTre...

106 lines
4.6 KiB
Lua

----- --七界试炼单个遗物 -----
local QiJieSingleTreasure = {}
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local QijieHolyConfig=ConfigManager.GetConfig(ConfigName.QijieHolyConfig)
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local QUALITY = {
[3] = {light="q_qjsl_yw_jhl",kuang="q_qjsl_yw_jsl"},
[4] = {light="q_qjsl_yw_jhz",kuang="q_qjsl_yw_jsz"},
[5] = {light="q_qjsl_yw_jhhs",kuang="q_qjsl_yw_jshs"},
[6] = {light="q_qjsl_yw_jhh",kuang="q_qjsl_yw_jsh"},
}
function QiJieSingleTreasure:InitComponent(gameObject)
self.spLoader = SpriteLoader.New()
self.attriText = Util.GetGameObject(gameObject,"AttriText"):GetComponent("Text")
self.title = Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
self.Img = Util.GetGameObject(gameObject,"Image"):GetComponent("Image")
self.light = Util.GetGameObject(gameObject,"light"):GetComponent("Image")
self.kuang = Util.GetGameObject(gameObject,"kuang"):GetComponent("Image")
self.cost = Util.GetGameObject(gameObject,"GameObject/cost")
self.costIcon = Util.GetGameObject(gameObject,"GameObject/cost/Icon"):GetComponent("Image")
self.costNum = Util.GetGameObject(gameObject,"GameObject/cost/Num"):GetComponent("Text")
self.activeBtn = Util.GetGameObject(gameObject,"GameObject/activeBtn")
self.activeText = Util.GetGameObject(self.activeBtn,"Text"):GetComponent("Text")
end
function QiJieSingleTreasure:BindEvent()
Util.AddClick(self.activeBtn,function()
local state = self.data.state
if state == 2 then
if BagManager.GetTotalItemNum(self.data.Cost[1])>=self.data.Cost[2] then
NetManager.SevenWorldRelicRequest(self.data.Id,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.QiJieShiLian.BuySingleTreasure)
self.parent:ClosePanel()
PopupTipPanel.ShowTip("<color=red>成功解锁遗物并将其激活!</color>")
end)
end
elseif state == 0 then
NetManager.SevenWorldRelicRequest(self.data.Id,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.QiJieShiLian.BuySingleTreasure)
self.parent:ClosePanel()
PopupTipPanel.ShowTip("<color=red>已激活遗物!</color>")
end)
elseif state == 1 then
NetManager.SevenWorldRelicRequest(self.data.Id,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.QiJieShiLian.BuySingleTreasure)
self.parent:ClosePanel()
PopupTipPanel.ShowTip("<color=red>已取消遗物激活状态!</color>")
end)
end
end)
end
function QiJieSingleTreasure:AddListener()
end
function QiJieSingleTreasure:RemoveListener()
end
function QiJieSingleTreasure:OnShow(_parent,...)
self.parent =_parent
self.data = ...
self.sortingOrder =_parent.sortingOrder
self:Refresh()
end
function QiJieSingleTreasure:Refresh()
self.title.text = string.format( "<color=%s>%s</color>",QualityTextDef[self.data.Quality],self.data.Name)
self.Img.sprite = self.spLoader:LoadSprite(artResourcesConfig[self.data.Icon].Name)
self.light.sprite = self.spLoader:LoadSprite(QUALITY[self.data.Quality].light)
self.kuang.sprite = self.spLoader:LoadSprite(QUALITY[self.data.Quality].kuang)
Util.SetGray(self.Img.gameObject,self.data.state == 2)
Util.SetGray(self.kuang.gameObject,self.data.state == 2)
self.light.gameObject:SetActive(self.data.state == 1)
if self.data.state == 2 then
self.cost:SetActive(true)
self.costIcon.sprite = self.spLoader:LoadSprite(GetSpriteNameByItemId(self.data.Cost[1]))
local text1 = string.format( "%s/%s",BagManager.GetTotalItemNum(self.data.Cost[1]),self.data.Cost[2])
if BagManager.GetTotalItemNum(self.data.Cost[1]) < self.data.Cost[2] then
text1 = string.format( "<color=#d70f09>%s</color>",text1)
end
self.costNum.text = text1
self.activeText.text = "解 锁"
else
self.cost:SetActive(false)
if self.data.state == 1 then
self.activeText.text = "取消激活"
elseif self.data.state == 0 then
self.activeText.text = "激 活"
end
end
local text2,text3 = QiJieShiLianManager.GetTreasureEffect({self.data.Id})
self.attriText.text = text2.."\n"..tostring(QiJieShiLianManager.GetSring(text3))
ForceRebuildLayout(self.cost.transform)
end
function QiJieSingleTreasure:OnClose()
end
function QiJieSingleTreasure:OnDestroy()
self.spLoader:Destroy()
end
return QiJieSingleTreasure