2023-07-14 19:35:33 +00:00
|
|
|
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
|
2023-07-14 19:35:33 +00:00
|
|
|
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())
|
2023-07-14 19:35:33 +00:00
|
|
|
else
|
2024-09-01 20:49:41 +00:00
|
|
|
self.RImgRole:SetRawImage(characterViewModel:GetSmallHeadIcon())
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
self.TxtSword.text = math.floor(characterViewModel:GetAbility())
|
2023-07-14 19:35:33 +00:00
|
|
|
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
|