local MonsterRewardBoxEffectManager = BaseClass("MonsterRewardBoxEffectManager", Singleton)
local MonsterRewardBoxEffect = require("Scene.MonsterRewardBoxEffect.MonsterRewardBoxEffect")
local ResourceManager = CS.GameEntry.Resource
local __init = function(self)
  self.allEffect = {}
  self:AddListener()
end
local __delete = function(self)
  self.allEffect = nil
  self:RemoveListener()
end
local MonsterRewardCreateSignal = function(data)
  local pointId = tonumber(data)
  MonsterRewardBoxEffectManager:GetInstance():ShowOneEffect(pointId)
end
local AddListener = function(self)
  EventManager:GetInstance():AddListener(EventId.MonsterRewardCreate, self.MonsterRewardCreateSignal)
end
local RemoveListener = function(self)
  EventManager:GetInstance():RemoveListener(EventId.MonsterRewardCreate, self.MonsterRewardCreateSignal)
end
local ShowOneEffect = function(self, pointId)
  if self.allEffect[pointId] ~= nil then
    return
  end
  local request = ResourceManager:InstantiateAsync(UIAssets.MonsterRewardBoxEffect)
  self.allEffect[pointId] = request
  request:completed("+", function()
    if request.isError then
      self.allEffect[pointId] = nil
      return
    end
    if CS.SceneManager.World == nil then
      request:Destroy()
      self.allEffect[pointId] = nil
      return
    end
    request.gameObject:SetActive(true)
    request.gameObject.transform:SetParent(CS.SceneManager.World.BuildBubbleNode)
    request.gameObject.transform:Set_localScale(ResetScale.x, ResetScale.y, ResetScale.z)
    local buildEffect = MonsterRewardBoxEffect.New()
    buildEffect:OnCreate(request)
    local param = {}
    param.pointId = pointId
    param.request = request
    buildEffect:ReInit(param)
  end)
end
local RemoveOneEffect = function(self, pointId)
  if self.allEffect[pointId] ~= nil then
    self.allEffect[pointId]:Destroy()
  end
  self.allEffect[pointId] = nil
end
MonsterRewardBoxEffectManager.__init = __init
MonsterRewardBoxEffectManager.__delete = __delete
MonsterRewardBoxEffectManager.RemoveOneEffect = RemoveOneEffect
MonsterRewardBoxEffectManager.MonsterRewardCreateSignal = MonsterRewardCreateSignal
MonsterRewardBoxEffectManager.AddListener = AddListener
MonsterRewardBoxEffectManager.RemoveListener = RemoveListener
MonsterRewardBoxEffectManager.ShowOneEffect = ShowOneEffect
return MonsterRewardBoxEffectManager
