PGRData/Script/matrix/xui/xuifubenbabeltower/XUiBabelMemberHead.lua

51 lines
1.5 KiB
Lua
Raw Normal View History

local XUiBabelMemberHead = XClass(nil, "XUiBabelMemberHead")
function XUiBabelMemberHead:Ctor(ui, index)
self.GameObject = ui.gameObject
self.Transform = ui.transform
self.Index = index
XTool.InitUiObject(self)
self.UiButtonComp = self.Transform:GetComponent("XUiButton")
end
function XUiBabelMemberHead:ClearMemberHead()
self.RImgRole.gameObject:SetActiveEx(false)
self.ImgLeader.gameObject:SetActiveEx(self:IsLeader())
self.ImgSword.gameObject:SetActiveEx(false)
end
function XUiBabelMemberHead:SetMemberInfo(characterId, isHalf, captainPos)
self.CharacterId = characterId
self.CaptainPos = captainPos
2024-09-01 20:49:41 +00:00
local characterViewModel = XEntityHelper.GetCharacterViewModelByEntityId(characterId)
if not characterViewModel then
self:ClearMemberHead()
return
end
self.RImgRole.gameObject:SetActiveEx(true)
self.ImgLeader.gameObject:SetActiveEx(self:IsLeader())
self.ImgSword.gameObject:SetActiveEx(true)
if isHalf then
2024-09-01 20:49:41 +00:00
self.RImgRole:SetRawImage(characterViewModel:GetHalfBodyCommonIcon())
else
2024-09-01 20:49:41 +00:00
self.RImgRole:SetRawImage(characterViewModel:GetSmallHeadIcon())
end
2024-09-01 20:49:41 +00:00
self.TxtSword.text = math.floor(characterViewModel:GetAbility())
end
function XUiBabelMemberHead:SetMemberCallBack(cb)
if cb and self.UiButtonComp then
self.UiButtonComp.CallBack = function() cb() end
end
end
function XUiBabelMemberHead:IsLeader()
return self.Index == self.CaptainPos
end
return XUiBabelMemberHead