miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/AttriTips.lua

83 lines
2.4 KiB
Lua

require("Base/BasePanel")
AttriTips = Inherit(BasePanel)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local Thread = nil
local proList = {}
--初始化组件(用于子类重写)
function AttriTips:InitComponent()
AttriTips.proPre = Util.GetGameObject(AttriTips.gameObject,"proPre")
AttriTips.attriParent = Util.GetGameObject(AttriTips.gameObject,"AttriParent")
end
--添加事件监听(用于子类重写)
function AttriTips:AddListener()
end
--移除事件监听(用于子类重写)
function AttriTips:RemoveListener()
end
function AttriTips:OnDestroy()
Thread = nil
proList = {}
end
function AttriTips:OnOpen()
end
--关闭弹出信息
function AttriTips.CloseAttriTip()
AttriTips:ClosePanel()
end
--显示弹出信息
--type=null List[num]=属性ID#属性值; type=1 List[属性ID]=属性值;
function AttriTips.ShowAttriTip(_attriList,_type)
UIManager.OpenPanel(UIName.AttriTips)
local attriList = {}
if _type then
for key, value in pairs(_attriList) do
attriList[#attriList + 1][1] = key
attriList[#attriList + 1][2] = value
end
else
attriList = _attriList
end
for i = 1, #attriList do
local data = attriList[i]
if not proList[i] then
proList[i] = newObject(AttriTips.proPre)
proList[i].transform.name = "proPre"..i
proList[i].transform:SetParent(AttriTips.attriParent.transform)
proList[i].transform.localScale = Vector3.one
proList[i].transform.localPosition = Vector3.zero
end
proList[i]:SetActive(false)
local proData = propertyConfig[data[1]]
Util.GetGameObject(proList[i],"name"):GetComponent("Text").text = proData.Info
local str = data[2]
if proData.Style == 2 then
str = tostring(data[2]/100).."%"
end
Util.GetGameObject(proList[i],"value"):GetComponent("Text").text = str
end
if Thread then
coroutine.stop(Thread)
Thread = nil
end
Thread = coroutine.start(function()
for i = 1, #proList do
proList[i]:SetActive(false)
PlayUIAnims(proList[i])
coroutine.wait(0.04)
proList[i]:SetActive(true)
coroutine.wait(0.08)
proList[i]:SetActive(true)
end
coroutine.wait(1)
AttriTips:ClosePanel()
end)
end
return AttriTips