PGRData/Script/matrix/xui/xuireform2nd/XUiReformTool.lua

51 lines
1.7 KiB
Lua
Raw Normal View History

2024-09-01 20:49:41 +00:00
local XUiReformTool = {}
function XUiReformTool.UpdateStar(ui, starAmount, starMax, extraStar)
if not ui.UiStar then
ui.UiStar = {}
for i = 1, 4 do
local uiStar = ui["ImgIcon" .. i].transform
---@class XUiReformToolStar
local star = {
Root = uiStar,
Enable = XUiHelper.TryGetComponent(uiStar, "Icon1", "RectTransform"),
Disable = XUiHelper.TryGetComponent(uiStar, "IconDis1", "RectTransform"),
Effect = XUiHelper.TryGetComponent(uiStar, "effect", "RectTransform"),
}
ui.UiStar[i] = star
end
end
if not ui.UiStarExtra then
ui.UiStarExtra = {
Root = ui.ImgIcon5,
Enable = XUiHelper.TryGetComponent(ui.ImgIcon5, "Icon1", "RectTransform"),
Disable = XUiHelper.TryGetComponent(ui.ImgIcon5, "IconDis1", "RectTransform"),
Effect = XUiHelper.TryGetComponent(ui.ImgIcon5, "effect", "RectTransform"),
}
end
for i = 1, #ui.UiStar do
local star = ui.UiStar[i]
if star then
if i > starMax then
star.Root.gameObject:SetActiveEx(false)
else
star.Root.gameObject:SetActiveEx(true)
local enable = starAmount >= i
XUiReformTool.SetStarEnable(star, enable)
end
end
end
local star = ui.UiStarExtra
local enable = extraStar
XUiReformTool.SetStarEnable(star, enable)
end
function XUiReformTool.SetStarEnable(star, enable)
star.Enable.gameObject:SetActiveEx(enable)
star.Disable.gameObject:SetActiveEx(not enable)
if star.Effect then
star.Effect.gameObject:SetActive(enable)
end
end
return XUiReformTool