源战役客户端
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.

264 lines
8.4 KiB

преди 1 месец
  1. --[[@------------------------------------------------------------------
  2. @description:
  3. @author:huangcong
  4. ----------------------------------------------------------------------]]
  5. LightActiveView = LightActiveView or BaseClass(BaseView)
  6. local LightActiveView = LightActiveView
  7. function LightActiveView:__init()
  8. self.base_file = "light"
  9. self.layout_file = "LightActiveView"
  10. self.layer_name = "Activity"
  11. self.destroy_imm = true
  12. self.use_background = false
  13. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  14. self.need_show_money = false --是否要显示顶部的金钱栏
  15. self.use_background = true
  16. self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  17. self.append_to_ctl_queue = true --添加进入控制队列
  18. self.item_list = {}
  19. self.model = LightModel:getInstance()
  20. self.load_callback = function ()
  21. self:LoadSuccess()
  22. self:AddEvent()
  23. end
  24. self.open_callback = function ( )
  25. self:OpenSuccess()
  26. end
  27. self.destroy_callback = function ( )
  28. self:DestroySuccess()
  29. end
  30. end
  31. function LightActiveView:DestroySuccess( )
  32. if self.time_id then
  33. TimerQuest.CancelQuest(GlobalTimerQuest, self.time_id)
  34. self.time_id = nil
  35. end
  36. end
  37. function LightActiveView:Open(cur_select_right)
  38. self.cur_select_right = cur_select_right or 1001
  39. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  40. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT) --停止自动挂机
  41. BaseView.Open(self)
  42. end
  43. function LightActiveView:OpenSuccess( )
  44. self:UpdateView()
  45. end
  46. function LightActiveView:LoadSuccess()
  47. local nodes = {
  48. "bg:raw","closeBtn:obj","activeBtn:obj","roleCon",
  49. "attr_scroll", "attr_scroll/Viewport/attr_con",
  50. "powerText:txt", "skillDesc:txt", "lb_attr:txt", "skillName:txt", "lb_attr_des:txt",
  51. "lightNameImg:img", "skillImg:img","icon_special:img", "titleBg",
  52. }
  53. self:GetChildren(nodes)
  54. local function func( ... )
  55. self:MoveUIToBack(self.bg, nil,nil, {alpha = 0.8})
  56. self:MoveUIToBack(self.titleBg, nil,nil, {alpha = 0.8})
  57. end
  58. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("openFunc_light_bg"), false,func)
  59. if self.need_load_again then
  60. self:UpdateView()
  61. end
  62. end
  63. function LightActiveView:AddEvent()
  64. local on_click = function ( click_obj )
  65. if self.closeBtn_obj == click_obj then--关闭按钮
  66. self:Close()
  67. elseif self.activeBtn_obj == click_obj then--激活
  68. self:Close()
  69. --如果是引导,则在退出,统一跳转
  70. -- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,1)
  71. -- if not helpVo then
  72. -- GlobalEventSystem:Fire(EventName.OPEN_NEW_MAIN_ROLE_VIEW,NewMainRoleModel.TabId.Light,nil,self.cur_select_right)
  73. -- end
  74. end
  75. end
  76. AddClickEvent(self.activeBtn_obj, on_click)
  77. AddClickEvent(self.closeBtn_obj, on_click)
  78. end
  79. function LightActiveView:UpdateView()
  80. if not self.is_loaded then
  81. self.need_load_again = true
  82. return
  83. end
  84. if not self.cur_select_right then
  85. print("huangcong:LightActiveView [start:95] 数据不正确:")
  86. return
  87. end
  88. self:ShowModel()
  89. self:UpdateSkill()
  90. self:UpdateAttrProp()
  91. self:UpdateSpeacielProp()
  92. lua_resM:setImageSprite(self, self.lightNameImg_img, "light_asset", "light_"..self.cur_select_right,true)
  93. end
  94. --更新技能
  95. function LightActiveView:UpdateSkill( )
  96. if not self.is_loaded then return end
  97. local conf = self.model:GetLightConfOne( self.cur_select_right )
  98. if not conf then return end
  99. local skill_info = stringtotable(conf.skill)
  100. local skill_id = tonumber(skill_info[1])
  101. local skill_conf = SkillManager:getInstance():getSkillFromConfig(skill_info[1])
  102. self.skillName_txt.text = HtmlColorTxt(Trim(skill_conf.name or ""), "#ffde6c")
  103. --特殊写死,只需要描述的一部分
  104. if skill_id == 120001 then
  105. self.skillDesc_txt.text = "攻击时有30%的概率令敌人流血,每秒损失1%气血"
  106. else
  107. self.skillDesc_txt.text = Trim(skill_conf.lvs[tonumber(skill_info[2])].desc or "")
  108. end
  109. lua_resM:setOutsideImageSprite(self, self.skillImg_img, GameResPath.GetSkillIcon(tonumber(skill_info[1])),true)
  110. end
  111. --更新属性列表
  112. function LightActiveView:UpdateAttrProp( )
  113. if not self.is_loaded then return end
  114. local basic = self.model:GetLightInfoOne( self.cur_select_right )
  115. local grade,star = 0,0
  116. if basic then
  117. grade = basic.grade
  118. star = basic.lv
  119. end
  120. -------------------------
  121. local conf = self.model:GetLightLvConfOne( self.cur_select_right, grade, star )
  122. if not conf then return end
  123. -------------------------
  124. local base_attr = stringtotable(conf.attrs)
  125. self.powerText_txt.text = GetFighting(base_attr)
  126. --处理一下attr_list 改成两个一组
  127. local count = math.ceil(#base_attr / 2)
  128. local new_base_attr = {}
  129. for i = 1, count do
  130. local data = {
  131. attr_id1 = base_attr[i*2-1] and base_attr[i*2-1][1] or nil,
  132. value1 = base_attr[i*2-1] and base_attr[i*2-1][2] or nil,
  133. next_value1 = base_attr[i*2-1] and base_attr[i*2-1][3] or nil,
  134. attr_id2 = base_attr[i*2] and base_attr[i*2][1] or nil,
  135. value2 = base_attr[i*2] and base_attr[i*2][2] or nil,
  136. next_value2 = base_attr[i*2] and base_attr[i*2][3] or nil,
  137. }
  138. table.insert(new_base_attr, data)
  139. end
  140. if not self.attr_list_com then
  141. self.attr_list_com = self:AddUIComponent(UI.ItemListCreator)
  142. end
  143. local info = {
  144. data_list = new_base_attr,
  145. item_con = self.attr_con,
  146. item_class = LightAttrItem,
  147. item_width = 430,
  148. item_height = 36,
  149. space_x = 0,
  150. start_x = 4,
  151. scroll_view = self.attr_scroll,
  152. create_frequency = 0.05,
  153. is_scroll_back_on_update = false,
  154. init_value = "LightActiveItem",--不同的预制
  155. on_update_item = function(item, i, v)
  156. item:SetData(i,v,true)
  157. end,
  158. }
  159. self.attr_list_com:UpdateItems(info)
  160. end
  161. --更新特殊数
  162. function LightActiveView:UpdateSpeacielProp( )
  163. local basic = self.model:GetLightInfoOne( self.cur_select_right )
  164. local grade,star = 0,0
  165. if basic then
  166. grade = basic.grade
  167. star = basic.lv
  168. end
  169. -------------------------
  170. --当前属性,下层属性
  171. local lv_conf = self.model:GetLightLvConfOne( self.cur_select_right, grade, star )
  172. if not lv_conf then return end
  173. --特殊属性
  174. local temp_data2 = stringtotable(lv_conf.spe_attrs)
  175. if temp_data2[1] then
  176. local _, name1, _, val1 = WordManager:GetPropertyInfo(tonumber(temp_data[1][1]), tonumber(temp_data[1][2]))
  177. self.lb_attr_txt.text = name1 .. "" .. val1
  178. self.lb_attr_des_txt.text = ""
  179. SetAttrIconByColorType(self, self.icon_special_img, tonumber(temp_data[1][1]), nil, 2)
  180. else
  181. local min_val = 999
  182. local min_grade,min_lv = 0,0
  183. local attr_id = false
  184. for k,v in pairs(Config.Visuslv) do
  185. if v.id == self.cur_select_right then
  186. for a,b in pairs(stringtotable(v.spe_attrs)) do
  187. attr_id = attr_id or b[1]
  188. if b[1] == attr_id then
  189. if b[2] < min_val then
  190. min_val = b[2]
  191. min_grade = v.grade
  192. min_lv = v.lv
  193. end
  194. end
  195. end
  196. end
  197. end
  198. if attr_id then
  199. local _, name1, _, val1 = WordManager:GetPropertyInfo(attr_id, min_val)
  200. self.lb_attr_txt.text = name1 .. "" .. val1
  201. self.lb_attr_des_txt.text = "" .. min_grade .. "" .. min_lv .. "" .. "解锁)"
  202. SetAttrIconByColorType(self, self.icon_special_img, attr_id, nil, 2)
  203. else
  204. self.lb_attr_txt.text = ""
  205. self.lb_attr_des_txt.text = ""
  206. end
  207. end
  208. end
  209. function LightActiveView:ShowModel( )
  210. if not self.is_loaded then
  211. return
  212. end
  213. local res_data = {
  214. father_node = self,
  215. transform = self.roleCon,
  216. fashion_type = FuncOpenModel.TypeId.Clothes,
  217. raycast_size = Vector2(0,0),
  218. scale = 210,
  219. position = Vector3(0,-80,-142),
  220. layer_name = "UI",
  221. ui_model_type = UIModelCommon.ModelType.BackModel,
  222. show_shadow = false,
  223. use_bloom = false,
  224. light_id = self.cur_select_right,
  225. }
  226. FuncOpenModel:getInstance():SetModelRes(res_data)
  227. end
  228. function LightActiveView:Close()
  229. --完成引导
  230. local helpVo, endVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,1)
  231. if helpVo then
  232. GlobalEventSystem:Fire(EventName.OPEN_NEW_MAIN_ROLE_VIEW,NewMainRoleModel.TabId.Light,nil,self.cur_select_right)
  233. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
  234. end
  235. if not helpVo or endVo then
  236. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK) --引导需要 保留
  237. end
  238. BaseView.Close(self)
  239. self:ActivitySkill()
  240. end
  241. --关闭界面,直接激活节能
  242. function LightActiveView:ActivitySkill()
  243. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14703, self.cur_select_right)
  244. end