源战役客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

84 rader
2.5 KiB

1 månad sedan
  1. EquipDecomposeView = EquipDecomposeView or BaseClass(BaseView)
  2. function EquipDecomposeView:__init(parent)
  3. self.base_file = "bag"
  4. self.layout_file = "EquipDecomposeView"
  5. self.layer_name = "UI"
  6. self.destroy_imm = true
  7. self.use_background = true
  8. self.change_scene_close = true
  9. self.is_set_zdepth = true
  10. --self:AddPreLoadList("common", {"AwardItem"})
  11. self.item_list = {}
  12. --self.use_local_view = true
  13. self.load_callback = function()
  14. self:LoadSuccess()
  15. self:InitEvent()
  16. end
  17. self.open_callback = function()
  18. self:SetData()
  19. end
  20. self.close_callback = function()
  21. end
  22. self.destroy_callback = function()
  23. self:Clear()
  24. end
  25. end
  26. function EquipDecomposeView:LoadSuccess()
  27. self.closeBtn = self:GetChild("Window/windowCloseBtn").gameObject
  28. self.okBtn = self:GetChild("okBtn").gameObject
  29. self.item_content = self:GetChild("itemContent")
  30. self.text = self:GetChild("text"):GetComponent("Text")
  31. self.text.text = "拆解道具后,将获得以下材料哦\n"
  32. .."<color="..ColorUtil.GREEN..">必得</color>道具一定会获得\n"
  33. .."<color="..ColorUtil.GREEN..">概率</color>道具会随机获得"
  34. end
  35. function EquipDecomposeView:InitEvent()
  36. local function onClickHandler(target)
  37. if target == self.okBtn then
  38. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT, 15019, {[self.vo.goods_id] = 1})
  39. end
  40. self:Close()
  41. end
  42. AddClickEvent(self.closeBtn,onClickHandler)
  43. AddClickEvent(self.okBtn,onClickHandler)
  44. end
  45. function EquipDecomposeView:Open(vo)
  46. self.vo = vo
  47. BaseView.Open(self)
  48. end
  49. function EquipDecomposeView:SetData()
  50. if not self.vo then return end
  51. local config = Config.Goodsdecompose[self.vo.type_id]
  52. if config then
  53. local regular_mat = ErlangParser:GetInstance():Parse(config.regular_mat)
  54. local irregular_mat = ErlangParser:GetInstance():Parse(config.irregular_mat)
  55. for i = 1, config.regular_num do
  56. self.item_list[i] = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_content)
  57. self.item_list[i]:SetData(regular_mat[i][2], regular_mat[i][3])
  58. self.item_list[i]:SetRandomDropTip(true,"必得")
  59. end
  60. for i= #regular_mat + 1, #regular_mat + #irregular_mat do
  61. self.item_list[i] = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_content)
  62. self.item_list[i]:SetData(irregular_mat[i - config.regular_num][2])
  63. self.item_list[i]:SetRandomDropTip(true,"概率")
  64. end
  65. end
  66. end
  67. function EquipDecomposeView:Clear( )
  68. for i, v in pairs(self.item_list) do
  69. v:ReleaseObj()
  70. v = nil
  71. end
  72. self.item_list = {}
  73. end