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

384 行
11 KiB

  1. GuideShowView = GuideShowView or BaseClass(BaseView)
  2. local GuideShowView = GuideShowView
  3. function GuideShowView:__init()
  4. self.base_file = "guide"
  5. self.layout_file = "GuideShowView"
  6. self.layer_name = "Activity"
  7. self.destroy_imm = true
  8. self.change_scene_close = true
  9. self.close_mode = CloseMode.CloseVisible
  10. self.is_set_zdepth = true
  11. self.sound_id = 0
  12. self.mainVo = RoleManager.Instance.mainRoleInfo
  13. self.is_set_order_sorting = true
  14. -- self.use_local_view = true
  15. self.load_callback = function ()
  16. self:LoadSuccess()
  17. self:InitEvent()
  18. end
  19. self.open_callback = function ()
  20. if not self.params then
  21. return
  22. end
  23. Scene.Instance:ChangeFogEnable(false)
  24. self:LayoutUI()
  25. self:PlaySound()
  26. end
  27. self.close_callback = function ()
  28. if self.close_call then
  29. self.close_call()
  30. end
  31. Scene.Instance:ChangeFogEnable(true)
  32. self:ClearUIEffect(self.effect_con)
  33. self:RemoveTimer()
  34. self:StopAnim()
  35. if self.show_figure_timer_id then
  36. GlobalTimerQuest:CancelQuest(self.show_figure_timer_id)
  37. self.show_figure_timer_id = nil
  38. end
  39. --坐骑后面有手指引导。所以不继续任务
  40. if not self.stop_task and self.type ~= 3 then
  41. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK, true)
  42. end
  43. end
  44. self.destroy_callback = function ()
  45. self:Clear()
  46. end
  47. end
  48. function GuideShowView:Open(params, saying, close_call,stop_task)
  49. if params then
  50. self.type = tonumber(params[1])
  51. self.params = params
  52. self.saying = saying
  53. self.close_call = close_call
  54. self.stop_task = stop_task
  55. self.time_diff = 8
  56. end
  57. BaseView.Open(self)
  58. end
  59. function GuideShowView:Clear()
  60. self:ClearUIEffect(self.effect_con)
  61. self:RemoveTimer()
  62. self:StopAnim()
  63. end
  64. function GuideShowView:Close()
  65. -- self.downCon.localPosition = co.TableXYZ(0, -38, 0)
  66. BaseView.Close(self)
  67. end
  68. function GuideShowView:LayoutUI()
  69. self.roleCon.localRotation = Quaternion.Euler(0,0,0)
  70. self.roleCon.localPosition = Vector3(-6,28,0)
  71. self.expGet_tips1:SetActive(false)
  72. self.expGet_tips2:SetActive(false)
  73. local function load_end_func()
  74. self:SetUIDepth(self.roleCon.gameObject)
  75. end
  76. self:AddUIEffect("ui_getobj_light", self.effect_con, self.layer_name, nil, 1, true, nil, nil, nil, load_end_func)
  77. self:StopAnim()
  78. if self.show_figure_timer_id then
  79. GlobalTimerQuest:CancelQuest(self.show_figure_timer_id)
  80. self.show_figure_timer_id = nil
  81. end
  82. local function timer_func()
  83. if self.type == 1 then
  84. self:DealWithSpecialWeapon()
  85. elseif self.type == 2 then
  86. self:DealWithPet()
  87. elseif self.type == 3 then
  88. self:DealWithHorse()
  89. elseif self.type == 4 then
  90. self:DealWithWing()
  91. elseif self.type == 5 then
  92. self:DealEMo()
  93. elseif self.type == 6 then --星灵奖励
  94. self:DealWithStarSoulReward()
  95. end
  96. end
  97. self.show_figure_timer_id = GlobalTimerQuest:AddDelayQuest(timer_func, 0.08)
  98. self:SetDesc(self.saying)
  99. self:ShowTimer()
  100. end
  101. function GuideShowView:DealWithSpecialWeapon()
  102. local career = RoleManager.Instance.mainRoleInfo.career
  103. local cfg = {}
  104. local name = ""
  105. local pos_y = 0
  106. local position, rotate = nil
  107. local scale = 140
  108. if career == 1 then
  109. cfg.resource_id = 101000
  110. name = "爆炎大剑"
  111. pos_y = -100
  112. position = co.TableXYZ(120, -80, 0)--[[Vector3.zero--]]
  113. rotate = --[[nil--]]{x = 0, y = -180, z = -145}
  114. scale = 110
  115. elseif career == 2 then
  116. cfg.resource_id = 102000
  117. name = "龙牙长枪"
  118. pos_y = 0
  119. position = co.TableXYZ(50, 0, 0)--Vector3.zero
  120. rotate = {x = 0, y = -180, z = -145}
  121. scale = 100
  122. elseif career == 3 then
  123. cfg.resource_id = 103000
  124. name = "龙牙长枪"
  125. pos_y = 0
  126. position = Vector3.zero
  127. rotate = nil
  128. elseif career == 4 then
  129. cfg.resource_id = 104000
  130. name = "魔力重炮"
  131. pos_y = 0
  132. position = Vector3(70, -53, 0)
  133. rotate = {x = 0, y = 0, z = -45}
  134. scale = 120
  135. else
  136. cfg.resource_id = 101000
  137. name = "爆炎大剑"
  138. pos_y = -100
  139. position = Vector3.zero
  140. rotate = nil
  141. end
  142. if Config.UIModelConfig[cfg.resource_id] then
  143. local data = {
  144. res_id = cfg.resource_id,
  145. modelPartPos = Config.UIModelConfig[cfg.resource_id].pos,
  146. type = Config.UIModelConfig[cfg.resource_id].type,
  147. texture_size = Vector2(450, 270),
  148. scale = scale,
  149. layer_name = self.layer_name,
  150. position = position,
  151. rotate = rotate
  152. }
  153. lua_resM:NewSetPartModel(self, self.roleCon, data)
  154. self:FloatUDAnima()
  155. else
  156. logWarn("[CultureViewItem:CreateModel] "..cfg.resource_id.."找不到配置")
  157. end
  158. self.roleCon.transform:Rotate(Vector3(0, 0, 90))
  159. -- self.roleCon.localPosition = Vector3(-6,pos_y,0)
  160. self:SetName(name)
  161. end
  162. --武器的上下浮动效果
  163. function GuideShowView:FloatUDAnima()
  164. self.tween_id3 = TweenLite.to(self, self.roleCon, TweenLite.UiAnimationType.POSY, 60, 1.5, call_fun, TweenFunc.PINGPONG, true)
  165. end
  166. function GuideShowView:StopAnim()
  167. if self.tween_id3 then
  168. TweenLite.Stop(self.tween_id3)
  169. self.tween_id3 = nil
  170. end
  171. end
  172. function GuideShowView:DealWithPet()
  173. local id = tonumber(self.params[2])
  174. local cfg = Config.Petstage[id]
  175. if cfg then
  176. local data = {
  177. clothe_res_id = cfg.figure,
  178. type = SceneBaseType.Horse,
  179. layer_name = self.layer_name,
  180. action_name_list = {"idle"},
  181. can_rotate = true,
  182. scale = 220,
  183. position = Vector3(0, -57, 0),
  184. }
  185. lua_resM:SetRoleModel(self, self.roleCon, data)
  186. self:SetDesc(cfg.name)
  187. end
  188. self.roleCon.localPosition = Vector3(0, -80, 0)
  189. end
  190. function GuideShowView:DealWithHorse()
  191. local id = tonumber(self.params[2])
  192. local cfg = Config.Mountstage[id]
  193. if cfg then
  194. local data = {
  195. clothe_res_id = cfg.ride_figure,
  196. type = SceneBaseType.Horse,
  197. layer_name = self.layer_name,
  198. rotate = -30,
  199. action_name_list = {"idle"},
  200. can_rotate = true,
  201. scale = 140,
  202. position = Vector3(-15, -155, 0),
  203. }
  204. lua_resM:SetRoleModel(self, self.roleCon, data)
  205. self:SetName(Trim(cfg.name))
  206. end
  207. self.roleCon.localPosition = Vector3(0, 50, 0)
  208. end
  209. function GuideShowView:DealWithWing()
  210. local career = RoleManager.Instance.mainRoleInfo.career
  211. local type_id = tonumber(self.params[career + 1])
  212. local goods_basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
  213. if not goods_basic then
  214. return
  215. end
  216. local data = {
  217. clothe_res_id = goods_basic.model_id,
  218. type = SceneBaseType.Horse,
  219. layer_name = self.layer_name,
  220. action_name_list = {"idle"},
  221. can_rotate = true,
  222. scale = 220,
  223. position = Vector3(0, -15, 0),
  224. }
  225. lua_resM:SetRoleModel(self, self.roleCon, data)
  226. self:SetName(Trim(goods_basic.goods_name))
  227. end
  228. function GuideShowView:DealEMo()
  229. local data = {
  230. clothe_res_id = 503001,
  231. type = SceneBaseType.Horse,
  232. layer_name = self.layer_name,
  233. action_name_list = {"idle"},
  234. can_rotate = true,
  235. scale = 300,
  236. position = Vector3(0, -350, 0),
  237. }
  238. lua_resM:SetRoleModel(self, self.roleCon, data)
  239. self.expGet_tips1:SetActive(true)
  240. self.expGet_tips2:SetActive(true)
  241. self:SetName("经验馆主")
  242. self.roleCon.localPosition = Vector3(0, 0, 0)
  243. -- self.downCon.localPosition = co.TableXYZ(-6, -10, 0)
  244. end
  245. function GuideShowView:LoadSuccess()
  246. self.info_con,
  247. self.sure_btn,
  248. self.mask_btn,
  249. self.expGet_tips1,
  250. self.expGet_tips2 = self:GetChildGameObjects({
  251. "InfoCon",
  252. "InfoCon/SureBtn",
  253. "Mask",
  254. "InfoCon/expGet_tips1",
  255. "InfoCon/expGet_tips2",
  256. })
  257. self.name_txt,
  258. self.desc_txt,
  259. self.sure_btn_txt = self:GetChildTexts({
  260. "InfoCon/Name/Text",
  261. "InfoCon/Desc/Text",
  262. "InfoCon/SureBtn/Text"
  263. })
  264. self.roleCon,
  265. self.effect_con,
  266. self.mask_bg,
  267. self.downCon = self:GetChildTransforms({
  268. "InfoCon/Texture",
  269. "EffectCon",
  270. "Mask",
  271. "InfoCon/downCon",
  272. })
  273. lua_resM:setOutsideImageSprite(self, self.downCon:GetComponent("Image"), GameResPath.GetGuideImage("wgui_taizi"), false)
  274. self.mask_bg.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight)
  275. end
  276. function GuideShowView:SureBtnClickEvent()
  277. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TASK_ITEM_SHOW, 1) or GuideModel:getInstance():GetHelpVo(HelpType.TASK_ITEM_SHOW, 2)
  278. or GuideModel:getInstance():GetHelpVo(HelpType.TASK_ITEM_SHOW, 3)
  279. if helpVo then
  280. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP, helpVo)
  281. end
  282. self:Close()
  283. end
  284. function GuideShowView:InitEvent()
  285. local function onBtnClickHandler(target)
  286. if target == self.sure_btn or target == self.mask_btn then
  287. self:SureBtnClickEvent()
  288. end
  289. end
  290. AddClickEvent(self.sure_btn, onBtnClickHandler)
  291. AddClickEvent(self.mask_btn, onBtnClickHandler)
  292. end
  293. function GuideShowView:SetName(name)
  294. self.name_txt.text = name
  295. end
  296. function GuideShowView:SetDesc(str)
  297. self.desc_txt.text = str
  298. end
  299. function GuideShowView:PlaySound()
  300. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TASK_ITEM_SHOW, 1) or GuideModel:getInstance():GetHelpVo(HelpType.TASK_ITEM_SHOW, 2)
  301. if helpVo then
  302. lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.FUNC, self.sound_id)
  303. if helpVo.sound and Trim(helpVo.sound) ~= "" then
  304. if lua_soundM then
  305. self.sound_id = lua_soundM:PlayEffect(self, Trim(helpVo.sound), false, LuaSoundManager.SOUND_TYPE.FUNC)
  306. end
  307. end
  308. end
  309. end
  310. function GuideShowView:ShowTimer()
  311. self:RemoveTimer()
  312. self.sure_btn_txt.text = "确定(" .. self.time_diff .. "秒)"
  313. local function onTimer()
  314. self.time_diff = self.time_diff - 1
  315. if self.time_diff > 0 then
  316. self.sure_btn_txt.text = "确定(" .. self.time_diff .. "秒)"
  317. else
  318. self:RemoveTimer()
  319. self:SureBtnClickEvent()
  320. end
  321. end
  322. self.time_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
  323. end
  324. function GuideShowView:RemoveTimer()
  325. if self.time_id then
  326. GlobalTimerQuest:CancelQuest(self.time_id)
  327. self.time_id = nil
  328. end
  329. end
  330. function GuideShowView:DealWithStarSoulReward()
  331. local id = tonumber(self.params[2])
  332. local data = {
  333. clothe_res_id = id,
  334. type = SceneBaseType.Partner,
  335. layer_name = self.layer_name,
  336. rotate = 0,
  337. action_name_list = {"idle"},
  338. can_rotate = true,
  339. scale = 220,
  340. position = Vector3(0, -170, 0),
  341. layout_file = self.layout_file
  342. }
  343. lua_resM:SetRoleModel(self, self.roleCon, data)
  344. self:SetName(self.params[3])
  345. self.roleCon.localPosition = Vector3(0, 50, 0)
  346. end