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

227 lines
7.2 KiB

пре 1 месец
  1. --[[@------------------------------------------------------------------
  2. @description:
  3. @author:huangcong
  4. ----------------------------------------------------------------------]]
  5. FirstRechargeTipView = FirstRechargeTipView or BaseClass(BaseView)
  6. local FirstRechargeTipView = FirstRechargeTipView
  7. function FirstRechargeTipView:__init()
  8. self.base_file = "rechargeActivity"
  9. self.layout_file = "FirstRechargeTipView"
  10. self.layer_name = "Activity"
  11. self.destroy_imm = true
  12. self.use_background = false
  13. self.change_scene_close = false
  14. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  15. self.need_show_money = false --是否要显示顶部的金钱栏
  16. self.force_no_ctl_queue = true
  17. self.item_list = {}
  18. self.model = RechargeActivityModel:getInstance()
  19. self.mainVo = RoleManager.Instance.mainRoleInfo
  20. self.show_type = 0
  21. self.cur_visible = true
  22. self.delay_time = 20---20s自动关闭
  23. self.load_callback = function ()
  24. self:LoadSuccess()
  25. self:AddEvent()
  26. end
  27. self.open_callback = function ( )
  28. self:OpenSuccess()
  29. end
  30. self.destroy_callback = function ( )
  31. self:DestroySuccess()
  32. end
  33. end
  34. function FirstRechargeTipView:Open(data)
  35. self.data = data
  36. BaseView.Open(self)
  37. end
  38. function FirstRechargeTipView:OpenSuccess( )
  39. self:UpdateView()
  40. end
  41. function FirstRechargeTipView:LoadSuccess()
  42. local nodes = {
  43. "layout/Panel/closeBtn:obj", "layout/Panel/bg:raw", "layout/Panel/rechargeBtn:obj"
  44. ,"layout/Panel/roleCon", "layout","layout/Panel","layout/Panel/effect",
  45. "layout/Panel/effect1",
  46. }
  47. self:GetChildren(nodes)
  48. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetRechargeActivityImage("recharge_sub_bg"))
  49. if self.need_load_again then
  50. self:UpdateView()
  51. end
  52. local pos = ActivityIconManager.Instance:GetActivityIconPos(15901)
  53. if pos and pos.x then
  54. self.layout.anchoredPosition = Vector3(pos.x-360+45,pos.y-225,0)
  55. self.layout.gameObject:SetActive(true)
  56. end
  57. self:ClearUIEffect(self.effect)
  58. self:ClearUIEffect(self.effect1)
  59. self:AddUIEffect("ui_shouchongtanchuang_2", self.effect, "Top", nil, 1, false,nil,nil,nil,nil,nil)
  60. -- local function load_finish_func( go )
  61. -- self:SetUIDepthEx(go,true,610)
  62. -- end
  63. -- self:AddUIEffect("ui_shouchongtanchuang_1", self.effect1, "Activity", nil, 1, true,nil,nil,nil,load_finish_func)
  64. self:UpdateTime()
  65. end
  66. function FirstRechargeTipView:AddEvent()
  67. local on_click = function ( click_obj )
  68. if self.closeBtn_obj == click_obj then
  69. self:StartAction()
  70. elseif self.rechargeBtn_obj == click_obj then
  71. self:StartAction()
  72. OpenFun.Open(159,1)
  73. end
  74. end
  75. AddClickEvent(self.closeBtn_obj, on_click)
  76. AddClickEvent(self.rechargeBtn_obj, on_click)
  77. local function onUpdateMainCanvasVisible(view, visible)
  78. if visible then
  79. self:Close()
  80. end
  81. end
  82. self:BindEvent(LuaViewManager:getInstance(), LuaViewManager.CHANGE_MAIN_CANVAS_VISIBLE, onUpdateMainCanvasVisible)--更新红点顺便更新界面
  83. end
  84. function FirstRechargeTipView:UpdateView()
  85. if not self.is_loaded then
  86. self.need_load_again = true
  87. return
  88. end
  89. local show_str = RechargeActivityModel.FIRST_RECHARGE_PRODUCKT_ID .. "@" .. RoleManager.Instance.mainRoleInfo.career .. "@" ..1
  90. local show_cfg = DeepCopy(Config.Rechargefirst[show_str])
  91. print("huangcong:FirstRechargeTipView [start:101] 111:", 111)
  92. if show_cfg then
  93. self:UpdateModelCon(show_cfg.right_res)
  94. end
  95. end
  96. function FirstRechargeTipView:DestroySuccess( )
  97. self:ClearUIEffect(self.effect1)
  98. self:ClearUIEffect(self.effect)
  99. self:StopAction()
  100. if self.timer_id then
  101. GlobalTimerQuest:CancelQuest(self.timer_id)
  102. self.timer_id = nil
  103. end
  104. end
  105. --更新模型
  106. function FirstRechargeTipView:UpdateModelCon( model_data )
  107. local model_data = stringtotable(model_data)
  108. local figure_data = nil
  109. if model_data then
  110. figure_data = model_data[1]
  111. end
  112. if figure_data then
  113. local model_cfg = CustomActivityModel:getInstance():GetActModelConShowCfg(self.base_type,tonumber(figure_data[3]),tonumber(figure_data[4]))
  114. local scale = 150
  115. local position = model_cfg and model_cfg.position or Vector3(0,20,-300)
  116. local fashion_type = tonumber(figure_data[3])
  117. local career = RoleManager.Instance.mainRoleInfo.career
  118. if fashion_type == FuncOpenModel.TypeId.FWeapon then--武器位置调高一点
  119. scale = 220
  120. position = Vector3(-15,45,-300)
  121. if career == 3 or career == 4 then
  122. scale = 330
  123. position = Vector3(20,-55,-300)
  124. end
  125. end
  126. if figure_data[1] == "show" then
  127. local res_data = {
  128. father_node = self,
  129. transform = self.roleCon,
  130. fashion_type = tonumber(figure_data[3]),
  131. raycast_size = Vector2(200,200),
  132. scale = scale,
  133. figure_id = figure_data[4],
  134. position = position,
  135. layer_name = self.layer_name,
  136. ui_model_type = UIModelCommon.ModelType.Model,
  137. show_shadow = false,
  138. use_bloom = false,
  139. can_rotate = true,
  140. }
  141. print("huangcong:FirstRechargeTipView [start:361] :", model_data)
  142. PrintTable(model_data)
  143. print("huangcong:FirstRechargeTipView [end]")
  144. if TableSize(model_data) > 1 then
  145. local career = self.mainVo.career
  146. for i,v in ipairs(model_data) do
  147. local fashion_type = tonumber(v[3])
  148. local figure_id = tonumber(v[4])
  149. if figure_id then
  150. if type_pos ~= FashionPartPos.wing and type_pos ~= FashionPartPos.Hat and type_pos ~= FashionPartPos.light then
  151. if career then
  152. if figure_id < 1000 then
  153. figure_id = figure_id + career * 1000
  154. end
  155. end
  156. else
  157. figure_id = figure_id
  158. end
  159. end
  160. if fashion_type == FuncOpenModel.TypeId.Clothes then --衣服
  161. res_data.fashion_model_id = figure_id
  162. elseif fashion_type == FuncOpenModel.TypeId.Weapon then --武器
  163. res_data.weapon_res_id = figure_id
  164. elseif fashion_type == FuncOpenModel.TypeId.Head then --头饰
  165. res_data.head_wear_id = figure_id
  166. elseif fashion_type == FuncOpenModel.TypeId.Footprint then --足迹
  167. type_pos = FashionPartPos.Footmark
  168. elseif fashion_type == FuncOpenModel.TypeId.wing then --背部
  169. res_data.wing_id = figure_id
  170. elseif fashion_type == FuncOpenModel.TypeId.Hat then--头套
  171. res_data.hat_wear_id = figure_id
  172. elseif fashion_type == FuncOpenModel.TypeId.RoleLight then--人物幻光
  173. res_data.light_id = figure_id
  174. end
  175. end
  176. end
  177. FuncOpenModel:getInstance():SetModelRes(res_data)
  178. else
  179. end
  180. end
  181. end
  182. function FirstRechargeTipView:UpdateTime( )
  183. local time = self.delay_time
  184. local function countDown()
  185. if self._use_delete_method then return end
  186. time = time - 1
  187. if time > 0 then
  188. else
  189. -- self:Close()
  190. self:StartAction()
  191. end
  192. end
  193. countDown()
  194. if not self.timer_id then
  195. self.timer_id = GlobalTimerQuest:AddPeriodQuest(countDown,1)
  196. end
  197. end
  198. function FirstRechargeTipView:StartAction( )
  199. -- self.layout.transform.pivot = Vector2(1, 1)
  200. -- self.layout.transform.anchorMin = Vector2(1, 1)
  201. -- self.layout.transform.anchorMax = Vector2(1, 1)
  202. local function end_func()
  203. self:Close()
  204. end
  205. local action1 = cc.ScaleTo.New(0.2,0.1,0.1,0.1)
  206. local action = cc.Sequence.New(action1,cc.CallFunc.New(end_func))
  207. cc.ActionManager:getInstance():addAction(action, self.Panel.transform)
  208. end
  209. function FirstRechargeTipView:StopAction( )
  210. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.Panel.transform)
  211. end