69 lines
1.8 KiB
Lua
69 lines
1.8 KiB
Lua
------------------------------------------------
|
|
--作者: 杨全福
|
|
--日期: 2019-09-20
|
|
--文件: UIXianPoIcon.lua
|
|
--模块: UIXianPoIcon
|
|
--描述: 仙魄ICON组件
|
|
------------------------------------------------
|
|
|
|
local ItemBase = CS.Thousandto.Code.Logic.ItemBase
|
|
|
|
local UIXianPoIcon ={
|
|
RootTrans = nil,
|
|
RootGO = nil,
|
|
--品质框图片
|
|
QualitySpr = nil,
|
|
-- 数量
|
|
NumLabel = nil,
|
|
-- icon图标
|
|
Icon = nil,
|
|
IconSpr = nil,
|
|
--按钮
|
|
Btn = nil,
|
|
|
|
--当前配置
|
|
CurCfg = nil,
|
|
}
|
|
|
|
function UIXianPoIcon:New(res)
|
|
local _M = Utils.DeepCopy(self)
|
|
_M.RootTrans = res
|
|
_M.RootGO = res.gameObject
|
|
|
|
_M.Btn = UIUtils.FindBtn(_M.RootTrans)
|
|
UIUtils.AddBtnEvent(_M.Btn, _M.OnBtnItemClick, _M)
|
|
_M.QualitySpr = UIUtils.FindSpr(_M.RootTrans, "Quality")
|
|
_M.Icon = UIUtils.RequireUIIconBase(UIUtils.FindTrans(_M.RootTrans, "Icon"))
|
|
_M.IconSpr = UIUtils.FindSpr(_M.RootTrans, "Icon")
|
|
local trans = UIUtils.FindTrans(_M.RootTrans, "Num")
|
|
if(trans ~= nil) then
|
|
_M.NumLabel = UIUtils.FindLabel(trans)
|
|
end
|
|
return _M
|
|
end
|
|
|
|
function UIXianPoIcon:InItWithCfgid(itemID, num)
|
|
itemID = tonumber(itemID);
|
|
num = tonumber(num);
|
|
|
|
self.CurCfg = DataConfig.DataImmortalSoulAttribute[itemID];
|
|
if self.CurCfg ~= nil then
|
|
self.Icon:UpdateIcon(self.CurCfg.Icon)
|
|
self.QualitySpr.spriteName = Utils.GetQualitySpriteName(self.CurCfg.Quality)
|
|
if self.NumLabel ~= nil then
|
|
if num > 1 then
|
|
UIUtils.SetTextByNumber(self.NumLabel, num)
|
|
else
|
|
UIUtils.ClearText(self.NumLabel)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 按钮事件
|
|
function UIXianPoIcon:OnBtnItemClick()
|
|
GameCenter.PushFixEvent(UIEventDefine.UIXianPoTipsForm_OPEN,{self.CurCfg.Id, 1, self.RootTrans})
|
|
end
|
|
|
|
return UIXianPoIcon
|