源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

374 行
11 KiB

  1. GuideStartView = GuideStartView or BaseClass(BaseView)
  2. local GuideStartView = GuideStartView
  3. GuideStartView.StartTime = 0.2 --点击指纹后,进度延时多久才开始加
  4. GuideStartView.UpdateSpeed = 5 --进度增加的速率
  5. GuideStartView.CloseViewTime = 200 --界面关闭的时间(其实是进度增加到当前进度才关闭)
  6. function GuideStartView:__init()
  7. self.base_file = "guide"
  8. self.layout_file = "GuideStartView"
  9. self.layer_name = "Top"
  10. self.destroy_imm = true
  11. self.use_background = true
  12. self.change_scene_close = true
  13. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  14. self.need_show_money = false --是否要显示顶部的金钱栏
  15. self.hide_maincancas = true
  16. -- self.hide_maincancas = true
  17. self.click_bg_toClose = false
  18. self.cur_progress = 0
  19. self.is_auto = false
  20. self.is_start = false
  21. self.load_callback = function ()
  22. self:LoadSuccess()
  23. self:AddEvent()
  24. end
  25. self.open_callback = function ( )
  26. self:OpenSuccess()
  27. end
  28. self.destroy_callback = function ( )
  29. self:DestroySuccess()
  30. end
  31. end
  32. function GuideStartView:Open(chapter_id)
  33. self.chapter_id = chapter_id or 1
  34. BaseView.Open(self)
  35. end
  36. function GuideStartView:Close( )
  37. --超过这个等级就不自动做任务
  38. if RoleManager.Instance.mainRoleInfo.level <= 2 then
  39. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
  40. end
  41. local function func( )
  42. lua_viewM:SetUICameraBloomEnable(true)
  43. end
  44. setTimeout(func,1)
  45. BaseView.Close(self)
  46. end
  47. function GuideStartView:LoadSuccess()
  48. if RoleManager.Instance.mainRoleInfo.level > 1 then
  49. self:Close()
  50. return
  51. end
  52. local nodes = {
  53. "content:tmp",
  54. "time_left:tmp",
  55. "progress_txt:tmp",
  56. "complete:obj",
  57. "girl_icon:raw",
  58. "bg:img",
  59. "name:tmp",
  60. "click_btn:obj",
  61. "content_line_complete_1:tmp",
  62. "content_line_complete_2:tmp",
  63. "content_line_complete_3:tmp",
  64. "content_line_1:tmp:obj",
  65. "content_line_2:tmp:obj",
  66. "content_line_3:tmp:obj",
  67. "content_line_4:tmp:obj",
  68. "content_line_5:tmp:obj",
  69. "content_line_6:tmp:obj",
  70. "effect_con_1:obj",
  71. "effect_con_2:obj",
  72. "effect_con_3:obj",
  73. "zhiwen:obj:img",
  74. "role:raw",
  75. }
  76. self:GetChildren(nodes)
  77. --elf:AddUIEffect("ui_feiye", self.effect_con_1, self.layer_name, nil, 1, true, nil, nil, nil)
  78. self:AddUIEffect("ui_zhiwen2", self.effect_con_3, self.layer_name, nil, 1, true, nil, nil, nil)
  79. self.effect_con_2_obj:SetActive(true)
  80. self.effect_con_3_obj:SetActive(false)
  81. self.zhiwen_obj:SetActive(true)
  82. SetImageGray(self.zhiwen_img, true)
  83. local function bg_back_func( ... )
  84. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  85. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  86. end
  87. end
  88. if self.background_wnd then
  89. bg_back_func()
  90. else
  91. self.bg_back_func = bg_back_func
  92. end
  93. self:MoveUIToBack(self.bg_img)
  94. self:UpdateVeiw()
  95. end
  96. function GuideStartView:AddEvent()
  97. local function on_btn_click(target)
  98. if target == self.click_btn_obj then
  99. self:DoAutoCheck()
  100. end
  101. end
  102. AddClickEvent(self.click_btn_obj, on_btn_click)
  103. local onExitGame = function()
  104. self:Close()
  105. end
  106. self:BindEvent(GlobalEventSystem, EventName.CHANGE_ACCOUNT, onExitGame)
  107. self:BindEvent(GlobalEventSystem, EventName.CHANGE_ROLE, onExitGame)
  108. self:BindEvent(GlobalEventSystem, EventName.GAME_DISCONNECT, onExitGame)
  109. end
  110. function GuideStartView:OpenSuccess()
  111. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  112. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT)
  113. self:UpdateTimer()
  114. end
  115. function GuideStartView:UpdateTimer( )
  116. local left_time = 0 --倒计时时间
  117. local left_tiem_max = 6 --倒计时最大时间
  118. local auto_time = 6 --自动验证时间
  119. local left_time_step = 0 --进度增加速率
  120. local point_step = 0.2 -- ... 动画频率
  121. self.cur_progress = 0
  122. local function on_timer( )
  123. left_time = left_time + 0.05
  124. self.cur_progress = self.cur_progress + left_time_step
  125. if not self.is_start then
  126. local str = string.format("自动验证 . . . (%ds)", math.floor(left_tiem_max - left_time))
  127. self.time_left_tmp.text = str
  128. if left_time >= auto_time then
  129. self:DoAutoCheck()
  130. end
  131. else
  132. if self.is_auto then
  133. left_time_step = GuideStartView.UpdateSpeed
  134. end
  135. end
  136. if self.content_line_flag_1 then
  137. if self.cur_progress <= 30 then
  138. self.content_line_flag_1 = self:GetCnt(self.content_line_flag_1, point_step)
  139. self.content_line_1_tmp.text = self.line_text[1] .. self:GetPointStrings(self.content_line_flag_1)
  140. else
  141. self.content_line_flag_1 = false
  142. self.content_line_1_tmp.text = self.line_text[1] .. " . . . "
  143. self.content_line_complete_1_tmp.text = HtmlColorTxt("通过!", "#2cf86f")
  144. end
  145. end
  146. if self.content_line_flag_2 then
  147. if self.cur_progress <= 50 then
  148. self.content_line_flag_2 = self:GetCnt(self.content_line_flag_2, point_step)
  149. self.content_line_2_tmp.text = self.line_text[2] .. self:GetPointStrings(self.content_line_flag_2)
  150. else
  151. self.content_line_flag_2 = false
  152. self.content_line_2_tmp.text = self.line_text[2] .. " . . . "
  153. self.content_line_complete_2_tmp.text = HtmlColorTxt("通过!", "#2cf86f")
  154. end
  155. end
  156. if self.content_line_flag_3 then
  157. if self.cur_progress <= 70 then
  158. self.content_line_flag_3 = self:GetCnt(self.content_line_flag_3, point_step)
  159. self.content_line_3_tmp.text = self.line_text[3] .. self:GetPointStrings(self.content_line_flag_3)
  160. else
  161. self.content_line_flag_3 = false
  162. self.content_line_3_tmp.text = self.line_text[3] .. " . . . "
  163. self.content_line_complete_3_tmp.text = HtmlColorTxt("通过!", "#2cf86f")
  164. end
  165. end
  166. if self.content_line_flag_4 and self.cur_progress >= 80 then
  167. self.content_line_flag_4 = false
  168. self.content_line_4_obj:SetActive(true)
  169. end
  170. if self.content_line_flag_5 and self.cur_progress >= 90 then
  171. self.content_line_flag_5 = false
  172. self.content_line_5_obj:SetActive(true)
  173. end
  174. if self.content_line_flag_6 and self.cur_progress >= 95 then
  175. self.content_line_flag_6 = false
  176. self.content_line_6_obj:SetActive(true)
  177. end
  178. if self.cur_progress < 100 then
  179. self.progress_txt_tmp.text = math.floor(self.cur_progress) .. "%"
  180. else
  181. if self.content_line_flag_7 then
  182. self.content_line_flag_7 = false
  183. self.progress_txt_tmp.text = "100%"
  184. self.complete_obj:SetActive(true)
  185. end
  186. if self.cur_progress >= GuideStartView.CloseViewTime then
  187. self:CancelCountDownTimer()
  188. self:Close()
  189. end
  190. end
  191. end
  192. on_timer()
  193. if not self.count_down_timer then
  194. self.count_down_timer = GlobalTimerQuest:AddPeriodQuest(on_timer, 0.05, -1)
  195. end
  196. end
  197. function GuideStartView:DoAutoCheck()
  198. if self.is_start then
  199. return
  200. end
  201. self.is_start = true
  202. if self.delay_start_id then
  203. GlobalTimerQuest:CancelQuest(self.delay_start_id)
  204. self.delay_start_id = false
  205. end
  206. self:AddUIEffect("ui_zhiwen1", self.effect_con_2, self.layer_name, nil, 1, false, nil, nil, nil)
  207. lua_soundM:PlayEffect(self, "zhiwen", false, LuaSoundManager.SOUND_TYPE.UI)
  208. self.time_left_tmp.text = ""
  209. local function DelayStart( ... )
  210. self.is_auto = true
  211. self.effect_con_3_obj:SetActive(true)
  212. SetImageGray(self.zhiwen_img, false)
  213. end
  214. self.delay_start_id = GlobalTimerQuest:AddDelayQuest(DelayStart,GuideStartView.StartTime)
  215. end
  216. function GuideStartView:GetCnt(crrent, step)
  217. local t = crrent + step
  218. t = t > 4 and 0 or t
  219. return t
  220. end
  221. function GuideStartView:GetPointStrings(cnt)
  222. local t = math.floor(cnt)
  223. return t == 0 and "" or (t == 1 and " . " or (t == 2 and " . . " or " . . . "))
  224. end
  225. function GuideStartView:CancelCountDownTimer( )
  226. if self.count_down_timer then
  227. GlobalTimerQuest:CancelQuest(self.count_down_timer)
  228. self.count_down_timer = nil
  229. end
  230. end
  231. function GuideStartView:UpdateVeiw( )
  232. local chapter_id = self.chapter_id or 1
  233. self.line_text =
  234. {
  235. [1] = "指纹信息",
  236. [2] = "DNA序列",
  237. [3] = "虹膜信息",
  238. }
  239. --lua_resM:setOutsideRawImage(self, self.role_raw, GameResPath.GetGuideImage("guide_start_role_".. RoleManager.Instance.mainRoleInfo.career), false)
  240. lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetViewBigBg("guide_start_view_bg_".. chapter_id), false)
  241. --lua_resM:setOutsideImageSprite(self, self.girl_icon_raw, GameResPath.GetRoleBg("guide_girl_399_603"), true)
  242. -- local res_data = {
  243. -- father_node = self,
  244. -- transform = self.girl_icon,
  245. -- fashion_type = FuncOpenModel.TypeId.FJarvis,
  246. -- figure_id = 1001,
  247. -- action_name_list = {"show"},
  248. -- size = Vector2(720,720),
  249. -- scale = 450,
  250. -- position = {x = 60, y = -247},
  251. -- show_shadow = true,
  252. -- can_rotate = false,
  253. -- ui_model_type = UIModelCommon.ModelType.BackModel,
  254. -- }
  255. -- FuncOpenModel:getInstance():SetModelRes(res_data)
  256. local icon_id = 100301
  257. local weapon_id = 0
  258. local texture_id = 0
  259. local data = {
  260. clothe_res_id = icon_id,
  261. weapon_res_id = weapon_id,
  262. role_type = SceneBaseType.Npc,
  263. texture_id = texture_id,
  264. image_id = texture_id,
  265. size = Vector2(720,720),
  266. scale = 380,
  267. position = Vector3(0, -100, 0),
  268. action_name_list = {"show"},
  269. show_shadow = false,
  270. raycastParent = false,
  271. can_rotate = false,
  272. }
  273. lua_resM:SetBackRoleModel(self,self.girl_icon,data)
  274. local role_con_pos =
  275. {
  276. [1] = {x = 150, y = -231,},
  277. [2] = {x = 115, y = -182,},
  278. [3] = {x = 129, y = -226,},
  279. [4] = {x = 154, y = -185,},
  280. }
  281. local my_career = RoleManager.Instance.mainRoleInfo.career
  282. local my_icon_id = my_career
  283. local res_data = {
  284. clothe_res_id = my_icon_id,
  285. weapon_res_id = weapon_id,
  286. role_type = SceneBaseType.Role,
  287. texture_id = texture_id,
  288. image_id = texture_id,
  289. size = Vector2(720,720),
  290. scale = 380,
  291. position = Vector3(0, -100, 0),
  292. action_name_list = {"show"},
  293. show_shadow = false,
  294. raycastParent = false,
  295. can_rotate = false,
  296. }
  297. lua_resM:SetBackRoleModel(self,self.role,res_data)
  298. lua_viewM:SetUICameraBloomEnable(false)
  299. SetAnchoredPosition(self.role, role_con_pos[my_career].x, role_con_pos[my_career].y)
  300. self.name_tmp.text = "指挥官"
  301. self.content_tmp.text = "任务编号S-301,追捕秘密实验室的逃窜生物,所有单位立即行动!"
  302. self.content_line_complete_1_tmp.text = ""-- HtmlColorTxt("", "#A9C1E1")
  303. self.content_line_complete_2_tmp.text = ""-- HtmlColorTxt("", "#A9C1E1")
  304. self.content_line_complete_3_tmp.text = ""-- HtmlColorTxt("", "#A9C1E1")
  305. self.content_line_1_tmp.text = self.line_text[1]
  306. self.content_line_2_tmp.text = self.line_text[2]
  307. self.content_line_3_tmp.text = self.line_text[3]
  308. self.content_line_4_obj:SetActive(false)
  309. self.content_line_5_obj:SetActive(false)
  310. self.content_line_6_obj:SetActive(false)
  311. self.complete_obj:SetActive(false)
  312. self.content_line_flag_1 = 0
  313. self.content_line_flag_2 = 0
  314. self.content_line_flag_3 = 0
  315. self.content_line_flag_4 = 0
  316. self.content_line_flag_5 = 0
  317. self.content_line_flag_6 = 0
  318. self.content_line_flag_7 = 0
  319. end
  320. function GuideStartView:DestroySuccess( )
  321. if self.delay_close_id then
  322. GlobalTimerQuest:CancelQuest(self.delay_close_id)
  323. self.delay_close_id = false
  324. end
  325. self:CancelCountDownTimer()
  326. --self:ClearUIEffect(self.effect_con_1)
  327. self:ClearUIEffect(self.effect_con_2)
  328. self:ClearUIEffect(self.effect_con_3)
  329. end