源战役客户端
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

116 linhas
4.5 KiB

  1. SoulPowerConditionItem = SoulPowerConditionItem or BaseClass(BaseItem)
  2. local SoulPowerConditionItem = SoulPowerConditionItem
  3. function SoulPowerConditionItem:__init()
  4. self.base_file = "soulPower"
  5. self.layout_file = "SoulPowerConditionItem"
  6. self.model = SoulPowerModel:getInstance()
  7. self:Load()
  8. end
  9. function SoulPowerConditionItem:Load_callback()
  10. self.nodes = {
  11. "state1:img",
  12. "conditionDes:tmp",
  13. "state2:obj",
  14. "goText:obj",
  15. }
  16. self:GetChildren(self.nodes)
  17. self:AddEvents()
  18. if self.need_refreshData then
  19. self:UpdateView()
  20. end
  21. end
  22. function SoulPowerConditionItem:AddEvents( )
  23. local on_click = function ( click_obj )
  24. if self.goText_obj == click_obj then
  25. if self.data[1] == SoulPowerConst.UpGradeConditionType.Lv then
  26. GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW)
  27. GlobalEventSystem:Fire(EventName.SHOW_MAIN_TASK_TIPS_VIEW, true)
  28. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunTower then
  29. GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW)
  30. OpenFun.Open(610,4)
  31. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.Power then
  32. GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW)
  33. OpenFun.Open(157,0)
  34. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunExp then
  35. GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW)
  36. -- ExpDunModel:getInstance():Fire(ExpDunModel.OPEN_EXP_DUN_MAIN_VIEW, true)
  37. ExpDunModel:getInstance():Fire(ExpDunModel.OPEN_EXP_HANGUP_MAIN_VIEW, true)
  38. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.WarSoulStar then
  39. GlobalEventSystem:Fire(EventName.CLOSE_NEW_MAIN_ROLE_VIEW)
  40. OpenFun.Open(143,0)
  41. end
  42. end
  43. end
  44. AddClickEvent(self.goText_obj, on_click)
  45. local update_condition_item = function(red_type)
  46. if red_type ~= SoulPowerConst.RedType.UpGrade then return end
  47. if not self.is_loaded then return end
  48. self:UpdateView()
  49. end
  50. self:BindEvent(self.model, SoulPowerConst.UPDATE_RED_DOT, update_condition_item)
  51. end
  52. function SoulPowerConditionItem:UpdateView( )
  53. local is_arrive = false
  54. if self.data[1] == SoulPowerConst.UpGradeConditionType.Lv then --玩家等级
  55. is_arrive = RoleManager.Instance.mainRoleInfo.level >= self.data[2]
  56. local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK
  57. ------------------------------
  58. self.conditionDes_tmp.text = string.format("角色等级达到 <%s>%s级</color>", str_color, self.data[2])
  59. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunTower then --爬塔层数
  60. local easy_pass_num,diffcult_pass_num = BaseDungeonModel:getInstance():GetOneTowerPassRecord()
  61. is_arrive = easy_pass_num >= self.data[2]
  62. local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK
  63. ------------------------------
  64. self.conditionDes_tmp.text = string.format("完成无尽回廊 <%s>第%s层</color>", str_color, self.data[2])
  65. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.Power then --玩家战力
  66. is_arrive = RoleManager.Instance.mainRoleInfo.fighting >= self.data[2]
  67. local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK
  68. ------------------------------
  69. self.conditionDes_tmp.text = string.format("角色战力达到 <%s>%s</color>", str_color, self.data[2])
  70. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.DunExp then --经验副本波数
  71. local cur_assult_wave = ExpDunModel:getInstance():GetCurrentWave()
  72. is_arrive = cur_assult_wave >= self.data[2]
  73. local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK
  74. ------------------------------
  75. self.conditionDes_tmp.text = string.format("完成放置冒险 <%s>第%s波</color>", str_color, self.data[2])
  76. elseif self.data[1] == SoulPowerConst.UpGradeConditionType.WarSoulStar then --战魂星数
  77. local star_sum_num = WarSoulModel:getInstance():GetAllWarSoulSumStar()
  78. is_arrive = star_sum_num >= self.data[2]
  79. local str_color = is_arrive and ColorUtil.GREEN_TIPS or ColorUtil.RED_DARK
  80. ------------------------------
  81. self.conditionDes_tmp.text = string.format("上阵战魂达到 <%s>%s星</color>", str_color, self.data[2])
  82. end
  83. lua_resM:setImageSprite(self, self.state1_img, "soulPower_asset", is_arrive and "soul_power_img_4" or "soul_power_img_3")
  84. self.state2_obj:SetActive(is_arrive)
  85. self.goText_obj:SetActive(not is_arrive)
  86. end
  87. function SoulPowerConditionItem:SetData( data )
  88. self.data = data
  89. if self.is_loaded then
  90. self.need_refreshData = false
  91. self:UpdateView()
  92. else
  93. self.need_refreshData = true
  94. end
  95. end
  96. function SoulPowerConditionItem:__delete( )
  97. end