local BuildLabelTip = BaseClass("BuildLabelTip")
local name_path = "NameLabel/NameText"
local OnCreate = function(self, go)
  if go ~= nil then
    self.request = go
    self.gameObject = go.gameObject
    self.transform = go.gameObject.transform
  end
  self:ComponentDefine()
  self:DataDefine()
end
local OnDestroy = function(self)
  self:ComponentDestroy()
  self:DataDestroy()
end
local ComponentDefine = function(self)
  self.name_txt = self.transform:Find(name_path):GetComponent(typeof(CS.SuperTextMesh))
end
local ComponentDestroy = function(self)
  self.gameObject = nil
  self.transform = nil
  self.name_txt = nil
end
local DataDefine = function(self)
  self.param = nil
  self.curPosition = nil
end
local DataDestroy = function(self)
  self.param = nil
  self.curPosition = nil
end
local ReInit = function(self, param)
  self.param = param
  self:ShowPanel()
end
local ShowPanel = function(self)
  self.gameObject.transform.position = SceneUtils.TileIndexToWorld(self.param.posIndex)
  if self.param.abbr ~= nil and self.param.abbr ~= "" then
    if self.param.name ~= nil then
      self.name_txt.text = "[" .. self.param.abbr .. "] " .. self.param.name
    end
  elseif self.param.name ~= nil then
    self.name_txt.text = self.param.name
  end
  if self.param.State == CS.PlayerType.PlayerSelf then
    self.name_txt.color32 = WorldGreenColor32
  elseif self.param.State == CS.PlayerType.PlayerAlliance then
    self.name_txt.color32 = WorldBlueColor32
  elseif self.param.State == CS.PlayerType.PlayerAllianceLeader then
    self.name_txt.color32 = WorldPurpleColor32
  else
    self.name_txt.color32 = WorldWhiteColor32
  end
end
BuildLabelTip.OnCreate = OnCreate
BuildLabelTip.OnDestroy = OnDestroy
BuildLabelTip.ComponentDefine = ComponentDefine
BuildLabelTip.ComponentDestroy = ComponentDestroy
BuildLabelTip.DataDefine = DataDefine
BuildLabelTip.DataDestroy = DataDestroy
BuildLabelTip.ReInit = ReInit
BuildLabelTip.ShowPanel = ShowPanel
return BuildLabelTip
