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

121 line
3.7 KiB

  1. PsionicTitleTipView = PsionicTitleTipView or BaseClass(BaseView)
  2. local PsionicTitleTipView = PsionicTitleTipView
  3. function PsionicTitleTipView:__init()
  4. self.base_file = "psionic"
  5. self.layout_file = "PsionicTitleTipView"
  6. self.layer_name = "Top"
  7. self.destroy_imm = true
  8. self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
  9. self.hide_time = 3 -- n秒后播放界面隐藏动画
  10. self.model = PsionicModel:getInstance()
  11. self.load_callback = function ()
  12. self:LoadSuccess()
  13. self:AddEvent()
  14. end
  15. self.open_callback = function ( )
  16. self:OpenSuccess()
  17. end
  18. self.destroy_callback = function ( )
  19. self:DestroySuccess()
  20. end
  21. end
  22. function PsionicTitleTipView:Open(title_lv)
  23. self.title_lv = title_lv
  24. BaseView.Open(self)
  25. end
  26. function PsionicTitleTipView:LoadSuccess()
  27. local nodes = {
  28. "title_icon:img",
  29. "tip_lb:tmp",
  30. "stage_name:img",
  31. }
  32. self:GetChildren(nodes)
  33. self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
  34. self.transform.anchoredPosition = Vector2(-3.5, 61.5)
  35. end
  36. function PsionicTitleTipView:AddEvent()
  37. end
  38. function PsionicTitleTipView:OpenSuccess()
  39. self:UpdateView()
  40. self:StartCloseTimer()
  41. self:OpenAnimation() -- 播放打开界面的动画
  42. end
  43. function PsionicTitleTipView:UpdateView()
  44. lua_resM:setImageSprite(self, self.stage_name_img, "psionic_asset", "ps_stage_name" .. self.title_lv, true)
  45. lua_resM:setImageSprite(self, self.title_icon_img, "psionicExtra_asset", "ps_stage_icon" .. self.title_lv, true)
  46. self.tip_lb_tmp.text = string.format("<color=#fdffc2>激活</color> %s圣阶", Trim(Config.Nucleontitle[self.title_lv].name))
  47. end
  48. -- 开始界面关闭的倒计时
  49. function PsionicTitleTipView:StartCloseTimer()
  50. self:ClearHideTimer()
  51. local end_time = self.hide_time + TimeUtil:getServerTime()
  52. local function hide_timer()
  53. local left_time = end_time - TimeUtil:getServerTime()
  54. if left_time < 0 then
  55. self:ClearHideTimer()
  56. self:CloseAnimation()
  57. end
  58. end
  59. hide_timer()
  60. self.hide_timer_id = GlobalTimerQuest:AddPeriodQuest(hide_timer, 0.1, -1)
  61. -- 设置动画标志量
  62. self.is_animating = true
  63. end
  64. function PsionicTitleTipView:ClearHideTimer( )
  65. if self.hide_timer_id then
  66. GlobalTimerQuest:CancelQuest(self.hide_timer_id)
  67. self.hide_timer_id = nil
  68. end
  69. end
  70. -- 播放打开界面的动画
  71. function PsionicTitleTipView:OpenAnimation()
  72. self.canvasGroup.alpha = 0
  73. if self.alpha_anim_id then
  74. TweenLite.Stop(self.alpha_anim_id)
  75. self.alpha_anim_id = nil
  76. end
  77. self.alpha_anim_id = TweenLite.to(self, self.canvasGroup, TweenLite.UiAnimationType.ALPHA, 1, 0.2)
  78. end
  79. -- 关闭(隐藏)界面的动画
  80. function PsionicTitleTipView:CloseAnimation()
  81. self.canvasGroup.alpha = 1
  82. if self.alpha_anim_id then
  83. TweenLite.Stop(self.alpha_anim_id)
  84. self.alpha_anim_id = nil
  85. end
  86. self.alpha_anim_id = TweenLite.to(self, self.canvasGroup,TweenLite.UiAnimationType.ALPHA, 0, 0.5)
  87. local pos_y = self.transform.anchoredPosition.y + 100
  88. if self.pos_id then
  89. TweenLite.Stop(self.pos_id)
  90. self.pos_id = nil
  91. end
  92. local function callback()
  93. self:Close()
  94. end
  95. self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSY, pos_y, 0.5, callback)
  96. end
  97. function PsionicTitleTipView:DestroySuccess( )
  98. self:ClearHideTimer()
  99. if self.alpha_anim_id then
  100. TweenLite.Stop(self.alpha_anim_id)
  101. self.alpha_anim_id = nil
  102. end
  103. if self.pos_id then
  104. TweenLite.Stop(self.pos_id)
  105. self.pos_id = nil
  106. end
  107. end