local UIHeroSkillStar = BaseClass("UIHeroSkillStar", UIBaseContainer)
local base = UIBaseContainer
local Localization = CS.GameEntry.Localization
local Resource = CS.GameEntry.Resource
local UIGray = CS.UIGray
local OnCreate = function(self)
  base.OnCreate(self)
  self:DataDefine()
  self:ComponentDefine()
end
local StopBreathEffect = function(self)
  if self.breathEffect then
    self.breathEffect:Kill()
    self.breathEffect = nil
  end
  if self.canvasGroup then
    self.canvasGroup:SetAlpha(1)
  end
  if self.filled then
    self.filled:SetAlpha(1)
  end
end
local OnDestroy = function(self)
  self:DataDestroy()
  self:ComponentDestroy()
  base.OnDestroy(self)
end
local DataDefine = function(self)
end
local DataDestroy = function(self)
end
local OnEnable = function(self)
  base.OnEnable(self)
  self.active = true
end
local OnDisable = function(self)
  base.OnDisable(self)
  self.active = false
  StopBreathEffect(self)
end
local ComponentDefine = function(self)
  self.filled = self:AddComponent(UIImage, "Filled")
  self.canvasGroup = self:AddComponent(UICanvasGroup, "")
end
local ComponentDestroy = function(self)
  self.filled = nil
  self.canvasGroup = nil
end
local SetFilled = function(self, filled)
  StopBreathEffect(self)
  self.filled:SetActive(filled)
end
local PlayBreathEffect = function(self, roundTime)
  StopBreathEffect(self)
  if not self.canvasGroup then
    return
  end
  local Getter = function()
    if self.canvasGroup then
      return self.canvasGroup:GetAlpha()
    end
  end
  local Setter = function(x)
    if self.canvasGroup then
      self.canvasGroup:SetAlpha(x)
    end
  end
  self.canvasGroup:SetAlpha(0)
  roundTime = roundTime or 0.25
  self.breathEffect = DOTween.To(Getter, Setter, 1, roundTime):SetEase(CS.DG.Tweening.Ease.InOutCubic):SetLoops(-1, CS.DG.Tweening.LoopType.Yoyo)
end
local SetStarIndex = function(self, index)
  if not self.filled:GetActive() then
    return
  end
  if index <= 5 then
    self.filled:LoadSprite("Assets/Main/Sprites/UI/LWCommon/Sprite/lrb_wurenjixinpian_zhujiemian_star02.png")
  else
    self.filled:LoadSprite("Assets/Main/Sprites/UI/LWCommon/Sprite/lrb_wurenjixinpian_zhujiemian_star01.png")
  end
end
UIHeroSkillStar.OnCreate = OnCreate
UIHeroSkillStar.OnDestroy = OnDestroy
UIHeroSkillStar.OnEnable = OnEnable
UIHeroSkillStar.OnDisable = OnDisable
UIHeroSkillStar.DataDefine = DataDefine
UIHeroSkillStar.DataDestroy = DataDestroy
UIHeroSkillStar.ComponentDefine = ComponentDefine
UIHeroSkillStar.ComponentDestroy = ComponentDestroy
UIHeroSkillStar.SetFilled = SetFilled
UIHeroSkillStar.PlayBreathEffect = PlayBreathEffect
UIHeroSkillStar.SetStarIndex = SetStarIndex
return UIHeroSkillStar
