local LandLockBoard = BaseClass("LandLockBoard")
local Localization = CS.GameEntry.Localization
local RewardUtil = require("Util.RewardUtil")
local root_path = "Root"
local icon_path = "Root/Icon"
local count_path = "Root/Count"
local __init = function(self)
  self.param = nil
end
local __delete = function(self)
  self.param = nil
end
local OnCreate = function(self, req)
  self.req = req
  self.gameObject = self.req.gameObject
  self.transform = self.gameObject.transform
  self.root_go = self.transform:Find(root_path).gameObject
  self.icon_sprite = self.transform:Find(icon_path):GetComponent(typeof(CS.UnityEngine.SpriteRenderer))
  self.count_text = self.transform:Find(count_path):GetComponent(typeof(CS.SuperTextMesh))
end
local OnDestroy = function(self)
  self.gameObject = nil
  self.transform = nil
  self.root_go = nil
  self.icon_sprite = nil
  self.count_text = nil
  if self.req ~= nil then
    self.req:Destroy()
    self.req = nil
  end
end
local SetParam = function(self, param)
  self.count_text.text = "x" .. param.count
  local pic = RewardUtil.GetPic(param.rewardType, param.itemId)
  self.icon_sprite:LoadSprite(pic)
end
local Fly = function(self, callback)
  CS.GameEntry.Sound:PlayEffect(SoundAssets.Music_Effect_pve_reward_land_lock)
  self.transform:DOMove(self.transform.position + Vector3.New(0, 3, 0), 1):OnComplete(function()
    if callback ~= nil then
      callback()
    end
    if self.req ~= nil then
      self.req:Destroy()
    end
  end)
end
LandLockBoard.__init = __init
LandLockBoard.__delete = __delete
LandLockBoard.OnCreate = OnCreate
LandLockBoard.OnDestroy = OnDestroy
LandLockBoard.SetParam = SetParam
LandLockBoard.Fly = Fly
return LandLockBoard
