local MonsterRewardBoxEffect = BaseClass("MonsterRewardBoxEffect")
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:RemoveTimer()
  self:ComponentDestroy()
end
local ComponentDefine = function(self)
  self.isDoAnim = false
  
  function self.__update_handle()
    self:Update()
  end
  
  UpdateManager:GetInstance():AddUpdate(self.__update_handle)
end
local ComponentDestroy = function(self)
end
local RemoveTimer = function(self)
  if self.__update_handle ~= nil then
    UpdateManager:GetInstance():RemoveUpdate(self.__update_handle)
    self.__update_handle = nil
  end
end
local ReInit = function(self, param)
  self.data = param
  self:UpdatePosition(self.data.pointId)
  self.curTime = 0
  self.isDoAnim = true
  self:Update()
end
local Update = function(self)
  if self.isDoAnim then
    self.curTime = self.curTime + Time.deltaTime
    if self.curTime > 3 then
      self:RemoveTimer()
      MonsterRewardBoxEffectManager:GetInstance():RemoveOneEffect(self.data.pointId)
    end
  end
end
local UpdatePosition = function(self, index)
  local worldPos = SceneUtils.TileIndexToWorld(index, ForceChangeScene.World)
  self.transform.position = worldPos
end
MonsterRewardBoxEffect.OnCreate = OnCreate
MonsterRewardBoxEffect.OnDestroy = OnDestroy
MonsterRewardBoxEffect.ComponentDefine = ComponentDefine
MonsterRewardBoxEffect.ComponentDestroy = ComponentDestroy
MonsterRewardBoxEffect.Update = Update
MonsterRewardBoxEffect.RemoveTimer = RemoveTimer
MonsterRewardBoxEffect.ReInit = ReInit
MonsterRewardBoxEffect.UpdatePosition = UpdatePosition
return MonsterRewardBoxEffect
