源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
3.6 KiB

  1. AllAdditionView = AllAdditionView or BaseClass(BaseView)
  2. function AllAdditionView:__init()
  3. self.base_file = "bag"
  4. self.layout_file = "AllAdditionView"
  5. self.layer_name = "Activity"
  6. self.close_mode = CloseMode.CloseDestroy
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.click_bg_toClose = true
  10. self.is_set_zdepth = true
  11. -- self.use_local_view = true
  12. self.type = 0 --加成类型
  13. self.strength_count = nil --次数
  14. self.title_list = {
  15. [1] = "全身精炼加成", [2] = "全身星级加成", [3] = "全身宝石加成", [4] = "圣印精炼加成"
  16. }
  17. self.step_list = {
  18. [1] = "全身装备精炼累积达:+", [2] = "全身装备星级累积达:", [3] = "全身宝石等级累积达:", [4] = "全身圣印精炼累积达:+"
  19. }
  20. self.cur_list = {
  21. [1] = "当前全身装备精炼:+", [2] = "当前全身装备星级:", [3] = "当前全身宝石等级:", [4] = "当前全身圣印精炼:+"
  22. }
  23. self.model = BagModel:getInstance()
  24. self.load_callback = function()
  25. self:LoadSuccess()
  26. self:InitEvent()
  27. end
  28. self.open_callback = function()
  29. self:SetData()
  30. end
  31. self.destroy_callback = function()
  32. if self.equip_event_id then
  33. GoodsModel:getInstance():UnBind(self.equip_event_id)
  34. self.equip_event_id = nil
  35. end
  36. end
  37. end
  38. function AllAdditionView:Open(type,strength_count)
  39. self.type = type
  40. self.strength_count = strength_count
  41. BaseView.Open(self)
  42. end
  43. function AllAdditionView:LoadSuccess()
  44. self.win_title,self.title,self.pro,self.next_pro,
  45. self.next_title,self.now_target = GetChildTexts(self.transform,
  46. {
  47. "Bg/Title","Bg/title","Bg/pro","Bg/next_pro",
  48. "Bg/next_title","Bg/now_target"
  49. })
  50. self.default_now,self.default_next = GetChildGameObjects (self.transform,
  51. {
  52. "Bg/default_now","Bg/default_next"
  53. })
  54. end
  55. function AllAdditionView:InitEvent()
  56. local function onBtnClickHandler(target)
  57. if target == self.close_btn then
  58. self:Close()
  59. end
  60. end
  61. AddClickEvent(self.close_btn,onBtnClickHandler)
  62. local update_equip = function ()
  63. self:SetData()
  64. end
  65. self.equip_event_id = GoodsModel:getInstance():Bind(GoodsModel.CHANGE_EQUIPLIST, update_equip)
  66. end
  67. function AllAdditionView:SetData()
  68. if self.type == nil then return end
  69. local num_list = {}
  70. if not self.strength_count then
  71. num_list[1], num_list[2], num_list[3], num_list[4] = self.model:GetAllAddition()
  72. end
  73. self.win_title.text = self.title_list[self.type]
  74. self.now_target.text = self.cur_list[self.type] .. (self.strength_count or num_list[self.type])
  75. local now_cfg, next_cfg = self.model:GetBodyPlusConfig(self.type,self.strength_count)
  76. if now_cfg then
  77. self.default_now:SetActive(false)
  78. self.title.text = self.step_list[self.type] .. now_cfg.need_lv
  79. local pro_list = ErlangParser:GetInstance():Parse(now_cfg.attr_list)
  80. local str = self:GetProperty(pro_list,ColorUtil.GREEN)
  81. self.pro.text = str
  82. else
  83. self.default_now:SetActive(true)
  84. self.title.text = ""
  85. self.pro.text = ""
  86. end
  87. if next_cfg then
  88. self.default_next:SetActive(false)
  89. self.next_title.text = self.step_list[self.type] .. next_cfg.need_lv
  90. local pro_list = ErlangParser:GetInstance():Parse(next_cfg.attr_list)
  91. local str = self:GetProperty(pro_list,"#979696")
  92. self.next_pro.text = str
  93. else
  94. self.default_next:SetActive(true)
  95. self.next_title.text = ""
  96. self.next_pro.text = ""
  97. end
  98. end
  99. function AllAdditionView:GetProperty(pro_list,color)
  100. local pro = ""
  101. for i, v in ipairs(pro_list) do
  102. pro = pro .. WordManager:GetProperties(tonumber(v[1])) .. ":<color="..color..">+" .. WordManager:GetPropertyValue(tonumber(v[1]), tonumber(v[2])) .. "</color>"
  103. if i < #pro_list then
  104. pro = pro .. "\n"
  105. end
  106. end
  107. return pro
  108. end