local AllianceCitySoldierTips = BaseClass("AllianceCitySoldierTips")
local time_text_path = "PosGo/Bg/TimeText"
local slider_path = "PosGo/Bg/Slider"
local bg_path = "PosGo/Bg"
local PositionDelta7 = Vector3.New(-6, 5, -6)
local PositionDelta = Vector3.New(0, 5, 0)
local SliderLength = Vector2.New(4.692847, 0.63)
local OnCreate = function(self, go)
  if go ~= nil then
    self.request = go
    self.gameObject = go.gameObject
    self.transform = go.gameObject.transform
  end
  self:ComponentDefine()
end
local OnDestroy = function(self)
  self:ComponentDestroy()
end
local ComponentDefine = function(self)
  self.time_text = self.transform:Find(time_text_path):GetComponent(typeof(CS.SuperTextMesh))
  self.slider = self.transform:Find(slider_path):GetComponent(typeof(CS.UnityEngine.SpriteRenderer))
  self.bg = self.transform:Find(bg_path)
end
local ComponentDestroy = function(self)
  self.time_text = nil
  self.slider = nil
  self.bg = nil
end
local StartShowBlood = function(self, param)
  self.data = param
  self:UpdatePosition(self.data.pointId)
  self.curSize = Vector2.New(SliderLength.x, SliderLength.y)
  self:RefreshSlider()
end
local RefreshSlider = function(self)
  local value = math.min(self.data.startValue / self.data.maxValue, 1)
  self.curSize.x = SliderLength.x * value
  self.slider.size = self.curSize
  local temp = math.floor(value * self.data.targetNum)
  self.time_text.text = string.GetFormattedSeperatorNum(temp) .. "/" .. string.GetFormattedSeperatorNum(self.data.targetNum)
end
local RefreshData = function(self, curBlood, maxBlood)
  self.data.startValue = curBlood
  self.data.maxValue = maxBlood
  self:RefreshSlider()
end
local UpdatePosition = function(self, index)
  local worldPos
  if self.data.tileX == BuildTilesSize.Seven then
    worldPos = SceneUtils.TileIndexToWorld(index) + PositionDelta7 + PositionDelta
  else
    worldPos = BuildingUtils.GetBuildModelDownVec(index, self.data.tileX, self.data.tileY) + PositionDelta
  end
  self.transform.position = worldPos
end
AllianceCitySoldierTips.OnCreate = OnCreate
AllianceCitySoldierTips.OnDestroy = OnDestroy
AllianceCitySoldierTips.ComponentDefine = ComponentDefine
AllianceCitySoldierTips.ComponentDestroy = ComponentDestroy
AllianceCitySoldierTips.RefreshSlider = RefreshSlider
AllianceCitySoldierTips.UpdatePosition = UpdatePosition
AllianceCitySoldierTips.StartShowBlood = StartShowBlood
AllianceCitySoldierTips.RefreshData = RefreshData
return AllianceCitySoldierTips
