local GolloesExploreTimeTip = BaseClass("GolloesExploreTimeTip")
local ResourceManager = CS.GameEntry.Resource
local Init = function(self, request)
  if request then
    self.request = request
    self.gameObject = request.gameObject
    self.transform = request.gameObject.transform
  end
end
local SetTime = function(self, worldMarch)
  if not self.gameObject then
    return
  end
  self.gameObject:SetActive(true)
  local pointId = worldMarch.targetUuid
  local pointPos = SceneUtils.TileIndexToWorld(pointId)
  local worldTroop = CS.SceneManager.World:GetTroop(worldMarch.uuid)
  if worldMarch and worldTroop then
    self.gameObject:SetActive(true)
    self.gameObject.transform:SetParent(worldTroop:GetTransform())
    self.gameObject.transform.position = pointPos
    self.gameObject.transform:Set_localScale(ResetScale.x, ResetScale.y, ResetScale.z)
    self.gameObject.name = "GolloesExploreTime" .. worldMarch.ownerFormationUuid
    self.gameObject.transform:SetParent(CS.SceneManager.World.DynamicObjNode)
    self.changeSceneCircleSlider = self.transform:GetComponent(typeof(CS.ChangeSceneCircleSlider))
    self.golloesExploreTimeN = self.changeSceneCircleSlider.transform:Find("PosGo/TimeText"):GetComponent(typeof(CS.SuperTextMesh))
    local startT = worldMarch.startTime
    self.golloesExploreEndT = worldMarch.endTime
    self.changeSceneCircleSlider:Init(startT, self.golloesExploreEndT)
    self:AddGolloesExploreTimer()
    self:SetGolloesExploreTime()
  end
end
local Refresh = function(self, worldMarch)
  self:SetTime(worldMarch)
end
local AddGolloesExploreTimer = function(self)
  function self.GolloesExploreTimerAction()
    self:SetGolloesExploreTime()
  end
  
  if self.golloesExploreTimer == nil then
    self.golloesExploreTimer = TimerManager:GetInstance():GetTimer(1, self.GolloesExploreTimerAction, self, false, false, false)
  end
  self.golloesExploreTimer:Start()
end
local SetGolloesExploreTime = function(self)
  local curTime = UITimeManager:GetInstance():GetServerTime()
  local remainTime = self.golloesExploreEndT - curTime
  if 0 < remainTime then
    self.golloesExploreTimeN.text = UITimeManager:GetInstance():MilliSecondToFmtString(remainTime)
  else
    self.golloesExploreTimeN.text = UITimeManager:GetInstance():MilliSecondToFmtString(0)
    self:DelGolloesExploreTimer()
  end
end
local DelGolloesExploreTimer = function(self)
  if self.golloesExploreTimer ~= nil then
    self.golloesExploreTimer:Stop()
    self.golloesExploreTimer = nil
  end
end
local Recycle = function(self)
  self:DelGolloesExploreTimer()
  self.gameObject:SetActive(false)
end
GolloesExploreTimeTip.Init = Init
GolloesExploreTimeTip.SetTime = SetTime
GolloesExploreTimeTip.Refresh = Refresh
GolloesExploreTimeTip.Recycle = Recycle
GolloesExploreTimeTip.AddGolloesExploreTimer = AddGolloesExploreTimer
GolloesExploreTimeTip.SetGolloesExploreTime = SetGolloesExploreTime
GolloesExploreTimeTip.DelGolloesExploreTimer = DelGolloesExploreTimer
return GolloesExploreTimeTip
