源战役客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

239 строки
6.2 KiB

1 месяц назад
  1. StrengthMainItem = StrengthMainItem or BaseClass(BaseItem)
  2. function StrengthMainItem:__init()
  3. self.base_file = "strength"
  4. self.layout_file = "StrengthMainItem"
  5. self.layer_name = "UI"
  6. -- self.use_local_view = true
  7. self.model = StrengthModel:getInstance()
  8. self.mainRoleVo = RoleManager.Instance.mainRoleInfo
  9. self.star = {}
  10. self.tween_list = {}
  11. self:Load()
  12. end
  13. function StrengthMainItem:Load_callback()
  14. self.goBtn,
  15. self.bar,
  16. self.star_obj,
  17. self.star[1],
  18. self.star[2],
  19. self.star[3],
  20. self.star[4],
  21. self.star[5],
  22. self.complete
  23. = GetChildGameObjects(self.transform,
  24. {
  25. "goBtn",
  26. "bar",
  27. "star",
  28. "star/1/image",
  29. "star/2/image",
  30. "star/3/image",
  31. "star/4/image",
  32. "star/5/image",
  33. "complete",
  34. })
  35. self.title,
  36. self.desc,
  37. self.prise,
  38. self.condition,
  39. self.num
  40. = GetChildTexts(self.transform,
  41. {
  42. "msg",
  43. "tips1",
  44. "tips2",
  45. "label1",
  46. "bar/num",
  47. })
  48. self.progress,
  49. self.textImg,
  50. self.iconImg
  51. = GetChildImages(self.transform,
  52. {
  53. "bar/value",
  54. "complete/textImg",
  55. "icon/iconImg",
  56. })
  57. self.complete:SetActive(false)
  58. if self.need_refreshData then
  59. self:SetData()
  60. end
  61. self:InitEvent()
  62. end
  63. function StrengthMainItem:InitEvent()
  64. local function onClickHandler(target)
  65. if target == self.goBtn then
  66. -- GlobalEventSystem:Fire(EventName.CLOSE_STRENGTH_MAIN_VIEW)
  67. if self.data then
  68. OpenFun.Open(self.data.tagplace,self.data.sub_tag)
  69. end
  70. end
  71. end
  72. AddClickEvent(self.goBtn, onClickHandler, 2)
  73. end
  74. function StrengthMainItem:SetData(type_id, data, index)
  75. self.type_id = type_id or self.type_id
  76. self.data = data or self.data
  77. self.index = index or self.index
  78. if self.is_loaded then
  79. self.title.text = self.data.task_name
  80. self.prise.text = self.data.task_des
  81. if self.data.icon and self.data.icon ~= "" and self.data.icon ~= "0" and self.data.icon ~= 0 then
  82. lua_resM:setImageSprite(self, self.iconImg, "activityIcon_asset", Trim(self.data.icon))
  83. end
  84. local is_unlock = false
  85. if self.data.open_flag == 1 then
  86. is_unlock = true
  87. else
  88. is_unlock = false
  89. end
  90. self:SetBasicShow(self.type_id, is_unlock, self.data.per, self.data.cur_num, self.data.max_num)
  91. else
  92. self.need_refreshData = true
  93. end
  94. end
  95. function StrengthMainItem:SetBasicShow(id, is_unlock, progress, cur_num, max_num)
  96. if id == 1 then
  97. self.star_obj:SetActive(false)
  98. self.bar:SetActive(true)
  99. self.desc.gameObject:SetActive(true)
  100. if cur_num and max_num then
  101. self.num.transform.sizeDelta = co.TableXY(250,27)
  102. self.num.transform.anchoredPosition = co.TableXYZ(0,0,0)
  103. -- self.num.text = cur_num.."/"..max_num
  104. if cur_num == "" then
  105. self.num.text = Trim(self.data.process_des)
  106. else
  107. self.num.text = cur_num.."/"..Trim(self.data.process_des)
  108. end
  109. end
  110. local color,str = "#ffffff", ""
  111. if progress then
  112. local progress_num = progress >= 100 and 100 or progress
  113. -- 50%以下显示 急需提升,红色ff381e
  114. -- 80以下显示 仍需努力,黄色e2d94a
  115. -- 90以下显示 独立风骚,绿色93e725
  116. -- 90以上一代宗师 橙色 df7904
  117. local cfg = Config.Improveconstant
  118. if cfg and cfg[1] and cfg[1].value then
  119. local grade_list = ErlangParser:GetInstance():Parse(cfg[1].value)
  120. table.sort(grade_list, function(a, b)
  121. return tonumber(a[1]) < tonumber(b[1])
  122. end)
  123. for k,v in pairs(grade_list) do
  124. if progress_num <= tonumber(v[2]) then
  125. color = Config.ConfigStrength.StrongGradeWord[k].color
  126. str = Config.ConfigStrength.StrongGradeWord[k].desc
  127. break
  128. end
  129. end
  130. end
  131. -- if progress < 50 then
  132. -- color = "#ff381e"
  133. -- str = "继续提升"
  134. -- elseif progress < 80 then
  135. -- color = "#e2d94a"
  136. -- str = "仍需努力"
  137. -- elseif progress < 90 then
  138. -- color = "#93e725"
  139. -- str = "独领风骚"
  140. -- else
  141. -- color = "#df7904"
  142. -- str = "一代宗师"
  143. -- end
  144. end
  145. self.desc.text = HtmlColorTxt(str, color)
  146. -- self.progress.fillAmount = progress/100
  147. self.progress.fillAmount = 0
  148. self.tween_list[1] = TweenLite.to(self, self.progress,TweenLite.UiAnimationType.FILLAMOUNT,progress/100,0.2)
  149. else
  150. self.bar:SetActive(false)
  151. self.star_obj:SetActive(true)
  152. self.desc.gameObject:SetActive(false)
  153. self:SetStarsNum(self.data.task_lv)
  154. end
  155. if progress >= 100 or (not is_unlock) then
  156. self.goBtn:SetActive(false)
  157. self.condition.gameObject:SetActive(true)
  158. if not is_unlock then
  159. local is_huodong = false
  160. local str = ErlangParser:GetInstance():Parse(self.data.condition)[1]
  161. str = Trim(str)
  162. for i,v in pairs(StrengthModel.Strengthen.IconNoticeList) do
  163. if str == v then
  164. is_huodong = true
  165. end
  166. end
  167. if is_huodong and not self.data.IsNull then
  168. if self.data.huodong_des then
  169. if self.data.huodong_des == "over" then
  170. -- self.condition.text = "<color=#f14041>已结束</color>"
  171. self.complete:SetActive(true)
  172. self.condition.gameObject:SetActive(false)
  173. lua_resM:setImageSprite(self, self.textImg, "strength_asset", "bq_over_text", true)
  174. else
  175. self.complete:SetActive(false)
  176. self.condition.text = "<color=#4eae1a>"..self.data.huodong_des.."</color>"
  177. end
  178. end
  179. else
  180. self.complete:SetActive(false)
  181. self.condition.text = "<color=#f14041>"..self.data.task_nonopen.."</color>"
  182. end
  183. end
  184. local str = Trim(self.data.task_nonopen)
  185. local list = Split(str, "_")
  186. if is_unlock and progress >= 100 then
  187. -- self.condition.text = "<color=#4eae1a>已完成</color>"
  188. self.complete:SetActive(true)
  189. self.condition.gameObject:SetActive(false)
  190. lua_resM:setImageSprite(self, self.textImg, "strength_asset", "bq_complete_text", true)
  191. end
  192. if list[1] == "level" then
  193. local _str = string.format("%s%s%s", list[2], RoleManager.Instance.mainRoleInfo.level+1, list[4])
  194. self.complete:SetActive(false)
  195. self.condition.text = "<color=#f14041>".._str.."</color>"
  196. end
  197. else
  198. self.goBtn:SetActive(true)
  199. self.condition.gameObject:SetActive(false)
  200. self.complete:SetActive(false)
  201. end
  202. end
  203. function StrengthMainItem:SetStarsNum(num)
  204. for i= 1 , 5 do
  205. if i<num+1 then
  206. self.star[i]:SetActive(true)
  207. else
  208. self.star[i]:SetActive(false)
  209. end
  210. end
  211. end
  212. function StrengthMainItem:__delete()
  213. if #self.tween_list > 0 then
  214. for i,v in ipairs(self.tween_list) do
  215. TweenLite.Stop(v)
  216. v = nil
  217. end
  218. end
  219. self.tween_list = {}
  220. end