2023-07-14 19:35:33 +00:00
|
|
|
local XUiGuildDormNameGrid = XClass(nil, "XUiGuildDormNameGrid")
|
|
|
|
|
|
|
|
function XUiGuildDormNameGrid:Ctor(ui)
|
|
|
|
XUiHelper.InitUiClass(self, ui)
|
|
|
|
self.CurrentRoom = XDataCenter.GuildDormManager.GetCurrentRoom()
|
2024-09-01 20:49:41 +00:00
|
|
|
self.RLEntity = nil
|
|
|
|
self.EntityId = nil
|
|
|
|
self.ShowDistance = 0
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
function XUiGuildDormNameGrid:SetData(rlEntity, offsetHeight)
|
|
|
|
self.RLEntity = rlEntity
|
2023-07-14 19:35:33 +00:00
|
|
|
self.Offset = CS.UnityEngine.Vector3(0, offsetHeight, 0)
|
2024-09-01 20:49:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGuildDormNameGrid:SetName(value)
|
|
|
|
if XTool.UObjIsNil(self.TxtName) then return end
|
|
|
|
self.TxtName.text = value or "unknow"
|
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGuildDormNameGrid:SetTriangle(value)
|
|
|
|
for i = 1, 2 do
|
|
|
|
self["Triangle" .. i].gameObject:SetActiveEx(value == i)
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
function XUiGuildDormNameGrid:SetShowDistance(value)
|
|
|
|
self.ShowDistance = value
|
|
|
|
end
|
|
|
|
|
2023-07-14 19:35:33 +00:00
|
|
|
function XUiGuildDormNameGrid:UpdateTransform()
|
2024-09-01 20:49:41 +00:00
|
|
|
self.CurrentRoom:SetViewPosToTransformLocalPosition(self.Transform, self.RLEntity:GetTransform(), self.Offset)
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGuildDormNameGrid:Hide()
|
2024-09-01 20:49:41 +00:00
|
|
|
if XTool.UObjIsNil(self.GameObject) then return end
|
2023-07-14 19:35:33 +00:00
|
|
|
self.GameObject:SetActiveEx(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
function XUiGuildDormNameGrid:Show(parent)
|
|
|
|
self.GameObject:SetActiveEx(true)
|
|
|
|
if parent then
|
|
|
|
self.Transform:SetParent(parent, false)
|
|
|
|
end
|
2024-09-01 20:49:41 +00:00
|
|
|
-- 小于等于0默认显示
|
|
|
|
if self.ShowDistance <= 0 then return end
|
|
|
|
-- 判断一下与主要玩家的距离
|
|
|
|
local role = self.CurrentRoom:GetRoleByPlayerId(XPlayer.Id)
|
|
|
|
local distance = CS.XGuildDormHelper.GetDistance(self.RLEntity:GetTransform(), role:GetRLEntity():GetTransform())
|
|
|
|
self.GameObject:SetActiveEx(distance <= self.ShowDistance)
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
function XUiGuildDormNameGrid:SetEntityId(value)
|
|
|
|
self.EntityId = value
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
function XUiGuildDormNameGrid:GetEntityId()
|
|
|
|
return self.EntityId
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return XUiGuildDormNameGrid
|