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

404 lines
13 KiB

  1. UpSuccessView = UpSuccessView or BaseClass(BaseView)
  2. local UpSuccessView = UpSuccessView
  3. function UpSuccessView:__init()
  4. self.base_file = "upSuccess"
  5. self.layout_file = "UpSuccessView"
  6. self.layer_name = "Top"
  7. self.destroy_imm = true
  8. self.change_scene_close = true
  9. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  10. self.need_show_money = false --是否要显示顶部的金钱栏
  11. self.is_set_zdepth = true
  12. self.click_bg_toClose = true
  13. self.fire_change_visible_event = true
  14. ------------------------
  15. -- 一级全屏界面:
  16. self.hide_maincancas = false --隐藏主界面
  17. self.use_background = true --不一定显示遮罩
  18. -- 二级界面:
  19. -- self.hide_maincancas = false --是否需要隐藏主界面,看策划需求
  20. -- self.use_background = true --需要遮罩
  21. self.attr_item_list = {}
  22. ------------------------
  23. FosterModel:GetInstance().is_open_up_success = true
  24. self.load_callback = function ()
  25. self:LoadSuccess()
  26. self:AddEvent()
  27. end
  28. self.open_callback = function ( )
  29. self:OpenSuccess()
  30. end
  31. self.close_win_callback = function ( )
  32. self:Close()
  33. end
  34. self.destroy_callback = function ( )
  35. self:DestroySuccess()
  36. end
  37. end
  38. function UpSuccessView:Open( data )
  39. self.data = data
  40. BaseView.Open(self)
  41. end
  42. function UpSuccessView:LoadSuccess()
  43. local nodes = {
  44. "img_title:img:obj","con_model","bg_0:raw","lb_name:tmp","lb_name_des:tmp",
  45. "con_attr/title_attr:tmp","con_attr/scroll_attr","con_attr/scroll_attr/Viewport/Content_attr","con_attr:obj",
  46. "con_fight/lb_fight:txt","con_fight:obj","con_fight/lb_fight_change:tmp","con_fight/icon_fight_up:obj",
  47. "con_change/lb_change_2:tmp","con_change:obj","lb_close:tmp",
  48. "con_goods/scroll_goods/Viewport/Content_goods","con_goods:obj","con_goods/img_goods:img","con_goods/lb_tips:tmp", "con_title_effect", "con_title_effect2",
  49. "con_special_attr/lb_special_attr_value:tmp", "con_special_attr:obj", "con_special_attr/lb_special_attr_name:tmp",
  50. "con_change/con_star_old/lb_change_1:tmp","con_change/con_star_old",
  51. "con_change/con_star_old/star_1_6:img:obj", "con_change/star_2_1:img:obj", "con_change/star_2_3:img:obj", "con_change/con_star_old/star_1_3:img:obj", "con_change/star_2_5:img:obj", "con_change/con_star_old/star_1_5:img:obj", "con_change/con_star_old/star_1_1:img:obj", "con_change/star_2_4:img:obj", "con_change/con_star_old/star_1_4:img:obj", "con_change/star_2_6:img:obj", "con_change/con_star_old/star_1_2:img:obj", "con_change/star_2_2:img:obj",
  52. }
  53. self:GetChildren(nodes)
  54. -- local function bg_back_func( ... )
  55. -- if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  56. -- self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  57. -- end
  58. -- end
  59. -- if self.background_wnd then
  60. -- bg_back_func()
  61. -- else
  62. -- self.bg_back_func = bg_back_func
  63. -- end
  64. end
  65. function UpSuccessView:AddEvent()
  66. local function ChangeVisible( )
  67. if self.data and self.data.model_info then
  68. self:ShowModel(self.data.model_info)
  69. end
  70. end
  71. self:BindEvent(GlobalEventSystem, BaseView.ChangeVisible, ChangeVisible)
  72. end
  73. function UpSuccessView:OpenSuccess()
  74. self:UpdateView()
  75. end
  76. function UpSuccessView:UpdateView()
  77. print("huangcong:UpSuccessView [start:78] self.data:", self.data)
  78. PrintTable(self.data)
  79. print("huangcong:UpSuccessView [end]")
  80. self:SetBigBg(self.data.big_bg_res)
  81. self:SetBigTitle(self.data.big_title_res)
  82. self:SetBigTitleEffect(self.data.big_title_effect)
  83. self:ShowModel(self.data.model_info)
  84. self:ShowGrade(self.data.grade_change)
  85. self:ShowPower(self.data.power_data)
  86. self:ShowAttr(self.data.attr_data)
  87. self:ShowReward( self.data.reward_data )
  88. self:ShowCloseClock( self.data.close_time )
  89. self:ShowSpecialAttr(self.data.special_attr)
  90. end
  91. function UpSuccessView:ShowCloseClock( time )
  92. if not time then
  93. if self.close_clock_id then
  94. GlobalTimerQuest:CancelQuest(self.close_clock_id)
  95. self.close_clock_id = nil
  96. end
  97. else
  98. self.time = 10--20201009策划说统一进阶成功界面关闭倒计时
  99. -- self.time = 10 or time
  100. local function clockFun()
  101. if self.time <= 0 then
  102. self.lb_close_tmp.text = ""
  103. self:Close()
  104. else
  105. self.lb_close_tmp.text = string.format( "<color=#2cf89a>%d</color> 秒后自动关闭" ,self.time)
  106. self.time = self.time - 1
  107. end
  108. end
  109. self.close_clock_id = self.close_clock_id or GlobalTimerQuest:AddPeriodQuest(clockFun, 1, -1)
  110. clockFun()
  111. end
  112. end
  113. function UpSuccessView:ShowModel( model_info )
  114. --[[
  115. model_info = {
  116. model_type = UpSuccessView.ModelType.Foster,
  117. model_id = 1101,
  118. name_des = "名字左边的文本",
  119. name = "坐骑名字",
  120. }
  121. --]]
  122. if not model_info then return end
  123. -------------------------
  124. self.lb_name_tmp.text = model_info.name or ""
  125. self.lb_name_des_tmp.text = model_info.name_des or ""
  126. if model_info.model_type == SceneBaseType.FWing or
  127. model_info.model_type == SceneBaseType.Horse or
  128. model_info.model_type == SceneBaseType.Pet or
  129. model_info.model_type == SceneBaseType.FCloud or
  130. model_info.model_type == SceneBaseType.FArmour or
  131. model_info.model_type == SceneBaseType.FPearl or
  132. model_info.model_type == SceneBaseType.FWeapon or
  133. model_info.model_type == SceneBaseType.FGun then
  134. self:ShowFosterModel(model_info.model_type,model_info.model_id)
  135. end
  136. end
  137. function UpSuccessView:SetBigBg( res_name )
  138. res_name = res_name or "up_success_bg"
  139. local function func( ... )
  140. -- self:MoveUIToBack(self.bg_0)
  141. end
  142. lua_resM:setOutsideRawImage(self,self.bg_0_raw,GameResPath.GetViewBigBg(res_name),false,func)
  143. end
  144. function UpSuccessView:SetBigTitle( res_name )
  145. if res_name then
  146. res_name = res_name or "upSuccess_title_1"
  147. lua_resM:setImageSprite(self, self.img_title_img, "upSuccess_asset", res_name,true)
  148. self.img_title_obj:SetActive(true)
  149. end
  150. end
  151. function UpSuccessView:SetBigTitleEffect( big_title_effect )
  152. if big_title_effect then
  153. if type(big_title_effect) == "table" then
  154. if #big_title_effect == 2 then
  155. if not self.con_title_effect then return end
  156. -------------------------
  157. local function end_call_func( ... )
  158. if not self.con_title_effect2 then return end
  159. self:AddUIEffect(big_title_effect[2].res,self.con_title_effect2, self.layer_name, Vector3(-37,-180,0), 1, true,nil)
  160. end
  161. self:AddUIEffect(big_title_effect[1].res,self.con_title_effect, self.layer_name, Vector3(-37,-180,0), 1, false,nil,nil,end_call_func)
  162. end
  163. end
  164. self.img_title_obj:SetActive(false)
  165. end
  166. end
  167. function UpSuccessView:ShowGrade( grade_change )
  168. --[[
  169. grade_change = {
  170. old_grade = "5阶",
  171. new_grade = "6阶",
  172. old_star = 1,
  173. new_star = 2,
  174. max_star_old = 6,
  175. max_star_new = 6,
  176. }
  177. --]]
  178. if not grade_change then
  179. self.con_change_obj:SetActive(false)
  180. else
  181. self.con_change_obj:SetActive(true)
  182. self.lb_change_1_tmp.text = grade_change.old_grade or ""
  183. self.lb_change_2_tmp.text = grade_change.new_grade or ""
  184. end
  185. for i=1,6 do
  186. lua_resM:setImageSprite(self,self["star_1_"..i.."_img"],'upSuccess_asset', grade_change.old_star >= i and "upSuccess_star_1" or "upSuccess_star_0",true)
  187. lua_resM:setImageSprite(self,self["star_2_"..i.."_img"],'upSuccess_asset', "upSuccess_star_0",true)
  188. if grade_change.max_star_old and grade_change.max_star_old < 6 then
  189. if grade_change.max_star_old < i then
  190. self["star_1_"..i.."_obj"]:SetActive(false)
  191. end
  192. end
  193. if grade_change.max_star_new and grade_change.max_star_new < 6 then
  194. if grade_change.max_star_new < i then
  195. self["star_2_"..i.."_obj"]:SetActive(false)
  196. end
  197. end
  198. end
  199. if grade_change.max_star_old and grade_change.max_star_old < 6 then
  200. SetAnchoredPositionX( self.con_star_old.transform, -296 + (6-grade_change.max_star_old)*28.2 )
  201. end
  202. end
  203. function UpSuccessView:ShowPower( power_data )
  204. --[[
  205. power_data = {
  206. new_power = 996
  207. change_power = 110
  208. }
  209. --]]
  210. if not power_data then
  211. self.con_fight_obj:SetActive(false)
  212. else
  213. self.con_fight_obj:SetActive(true)
  214. self.lb_fight_txt.text = "f" .. power_data.new_power
  215. if power_data.change_power and power_data.change_power > 0 then
  216. self.lb_fight_change_tmp.text = power_data.change_power
  217. self.icon_fight_up_obj:SetActive(true)
  218. else
  219. self.lb_fight_change_tmp.text = ""
  220. self.icon_fight_up_obj:SetActive(false)
  221. end
  222. end
  223. end
  224. function UpSuccessView:ShowAttr( attr_data )
  225. --[[
  226. attr_data = {
  227. title_name = "属性标替文本",
  228. pos_type = pos_tag,--位置
  229. attr_old = {
  230. [1] = {1,100},
  231. [2] = {2,200},
  232. },
  233. attr_new = {
  234. [1] = {1,110},
  235. [2] = {2,220},
  236. },
  237. }
  238. --]]
  239. if not attr_data then
  240. self.con_attr_obj:SetActive(false)
  241. else
  242. local attr_pos_tab = {
  243. ["default"] = {
  244. ["con_attr_pos"] = {222.46,23.21},
  245. ["scroll_attr_size"] = {355.99,201.49},
  246. ["scroll_attr_pos"] = {2.72,-55.68},
  247. },
  248. ["foster"] = {
  249. ["con_attr_pos"] = {222.46,-48.79},
  250. ["scroll_attr_size"] = {355.99,129.58},
  251. ["scroll_attr_pos"] = {14.42-12,8.33-30},
  252. }
  253. }
  254. local pos_info = false
  255. if attr_data.pos_type and attr_pos_tab[attr_data.pos_type] then
  256. pos_info = attr_pos_tab[attr_data.pos_type]
  257. else
  258. pos_info = attr_pos_tab["default"]
  259. end
  260. if pos_info then
  261. local temp = attr_pos_tab[attr_data.pos_type]
  262. SetAnchoredPosition( self.con_attr.transform, temp.con_attr_pos[1], temp.con_attr_pos[2] )
  263. -------------------------
  264. SetSizeDelta(self.scroll_attr.transform, temp.scroll_attr_size[1], temp.scroll_attr_size[2] )
  265. SetAnchoredPosition( self.scroll_attr.transform, temp.scroll_attr_pos[1], temp.scroll_attr_pos[2] )
  266. end
  267. -------------------------
  268. self.con_attr_obj:SetActive(true)
  269. self.title_attr_tmp.text = attr_data.title_name or "获得属性"
  270. -------------------------
  271. local old_attr = attr_data.attr_old or {}
  272. local new_attr = attr_data.attr_new or {}
  273. old_attr,new_attr = GetAttrMatch( old_attr,new_attr )
  274. old_attr = SortAttrList( old_attr )
  275. for k,v in pairs(self.attr_item_list) do
  276. v:SetVisible( false )
  277. end
  278. for i,v in ipairs(old_attr) do
  279. local next_one = false
  280. for a,b in pairs(new_attr) do
  281. if b[1] == v[1] then
  282. next_one = b
  283. end
  284. end
  285. self.attr_item_list[i] = self.attr_item_list[i] or self:CreateItem(UpSuccessAttrItem, self.Content_attr , self.layer_name)
  286. self.attr_item_list[i]:SetData( i, v, next_one )
  287. self.attr_item_list[i]:SetVisible( true )
  288. -- local x = i%2 == 1 and 28 or 380
  289. -- local y = math.ceil( i/2 ) * 45
  290. local x = 0
  291. local y = -32*(i-1)
  292. self.attr_item_list[i]:SetPosition( x, y )
  293. end
  294. SetSizeDeltaY(self.Content_attr.transform, #old_attr*36)
  295. end
  296. end
  297. --[[
  298. special_attr = {
  299. [1] = {1,100},
  300. [2] = {2,200},
  301. },
  302. --]]
  303. function UpSuccessView:ShowSpecialAttr( special_attr )
  304. if special_attr and special_attr[1] then
  305. local _, name1, _, val1 = WordManager:GetPropertyInfo(special_attr[1][1], special_attr[1][2])
  306. self.con_special_attr_obj:SetActive(true)
  307. self.lb_special_attr_value_tmp.text = val1
  308. self.lb_special_attr_name_tmp.text = name1
  309. else
  310. self.con_special_attr_obj:SetActive(false)
  311. end
  312. end
  313. function UpSuccessView:ShowReward( reward_data )
  314. --[[
  315. reward_data = {
  316. title_res = nil,
  317. show_list = {
  318. [1] = {1,100065,100},
  319. [2] = {1,100065,100},
  320. }
  321. show_name = "",
  322. }
  323. --]]
  324. if not reward_data then
  325. self.con_goods_obj:SetActive(false)
  326. else
  327. self.con_goods_obj:SetActive(true)
  328. local res_name = reward_data.title_res or "upSuccess_title_2"
  329. lua_resM:setImageSprite(self, self.img_goods_img, "upSuccess_asset", res_name,true)
  330. -------------------------
  331. self.tip_award_list = self.tip_award_list or {}
  332. for k,v in pairs(self.tip_award_list) do
  333. v:SetVisible( false )
  334. end
  335. local show_info = reward_data.show_list or {}
  336. for i,v in ipairs(show_info) do
  337. self.tip_award_list[i] = UIObjPool:PopItem(UIObjPool.UIType.AwardItem,self.Content_goods)
  338. self.tip_award_list[i]:SetItemSize(59,59)
  339. self.tip_award_list[i]:SetDataWithMapId(v[2], v[3], v[1])
  340. self.tip_award_list[i]:SetPosition( 70 * (i-1)+6,-15)
  341. end
  342. SetSizeDeltaX(self.Content_goods, #show_info * 108)
  343. if reward_data.show_name and reward_data.show_name ~= "" then
  344. self.lb_tips_tmp.text = string.format("您已成功激活:%s\n现已将等值材料返还给您", HtmlColorTxt(reward_data.show_name, "#2CF86F"))
  345. else
  346. self.lb_tips_tmp.text = ""
  347. end
  348. end
  349. end
  350. function UpSuccessView:ShowFosterModel( model_type,model_id )
  351. local res_data = {
  352. father_node = self,
  353. transform = self.con_model,
  354. fashion_type = self.data.extra_type_id + 1000,
  355. figure_id = model_id,
  356. -------------------------
  357. raycast_size = Vector2(500,530),
  358. ui_model_type = UIModelCommon.ModelType.Model,
  359. layer_name = self.layer_name,
  360. --这个翅膀,是半透明翅膀,使用特殊shader处理一下
  361. using_material = self.data.extra_type_id == FosterConst.ModuleId.FWing and "render_texture" or false,
  362. }
  363. FuncOpenModel:getInstance():SetModelRes(res_data)
  364. end
  365. function UpSuccessView:DestroySuccess( )
  366. if self.close_clock_id then
  367. GlobalTimerQuest:CancelQuest(self.close_clock_id)
  368. self.close_clock_id = nil
  369. end
  370. if self.tip_award_list then
  371. for k,v in pairs(self.tip_award_list) do
  372. UIObjPool:PushItem(UIObjPool.UIType.AwardItem, v)
  373. end
  374. self.tip_award_list = {}
  375. end
  376. self:ClearUIEffect(self.con_title_effect)
  377. self:ClearUIEffect(self.con_title_effect2)
  378. end