源战役客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

140 linhas
3.9 KiB

4 semanas atrás
  1. CSGWarInstructionView = CSGWarInstructionView or BaseClass(BaseView)
  2. local CSGWarInstructionView = CSGWarInstructionView
  3. --[[
  4. CSGWarInstructionView.TabData = {
  5. [1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
  6. }
  7. --]]
  8. function CSGWarInstructionView:__init()
  9. self.base_file = "CSGWar"
  10. self.layout_file = "CSGWarInstructionView"
  11. self.layer_name = "Activity"
  12. self.destroy_imm = true
  13. self.use_background = true --全屏界面默认使用这个参数
  14. --self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  15. self.change_scene_close = true
  16. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  17. self.need_show_money = false --是否要显示顶部的金钱栏
  18. self.ignore_use_anim = true
  19. self.hide_time = 15
  20. self.model = CSGWarModel:getInstance()
  21. self.load_callback = function ()
  22. self:LoadSuccess()
  23. end
  24. self.open_callback = function ( )
  25. self:OpenSuccess()
  26. end
  27. self.switch_callback = function(index)
  28. self:SwitchTab(index)
  29. end
  30. self.destroy_callback = function ( )
  31. self:DestroySuccess()
  32. end
  33. end
  34. function CSGWarInstructionView:Open(need_auto_close)
  35. self.need_auto_close = need_auto_close
  36. BaseView.Open(self)
  37. end
  38. function CSGWarInstructionView:LoadSuccess()
  39. local nodes = {
  40. "text2:tmp", "text4:tmp", "text1:tmp", "text3:tmp", "close_text:tmp",
  41. }
  42. self:GetChildren(nodes)
  43. self:AddEvent()
  44. local closeWin_callback = function()
  45. self:CloseAnimation()
  46. -- self:Close()
  47. end
  48. self.tabWindowComponent = UITabWindow.New(self.transform,nil,self.switch_callback,closeWin_callback,self.background_wnd,self.container, UITabWindow.SizeSmallNoTab, false,nil,false)
  49. self.tabWindowComponent:SetBackgroundRes("csgwar_instruction_bg")
  50. self.tabWindowComponent:SetTitleText("玩法教学")
  51. -- lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("csgwar_instruction_bg"),false)
  52. end
  53. function CSGWarInstructionView:AddEvent()
  54. end
  55. function CSGWarInstructionView:CloseAnimation( )
  56. self.background_wnd:SetActive(false)
  57. if self.pos_id then
  58. TweenLite.Stop(self.pos_id)
  59. self.pos_id = nil
  60. end
  61. local function callback1( )
  62. self:Close()
  63. end
  64. self.pos_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POS, Vector2(360,320), 0.3, callback1)
  65. if self.scale_id then
  66. TweenLite.Stop(self.scale_id)
  67. self.scale_id = nil
  68. end
  69. local function callback2( )
  70. self:Close()
  71. end
  72. self.scale_id = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, Vector3(0.1,0.1,0.1), 0.3, callback1)
  73. end
  74. function CSGWarInstructionView:StopCloseAnimation( )
  75. if self.scale_id then
  76. TweenLite.Stop(self.scale_id)
  77. self.scale_id = nil
  78. end
  79. if self.pos_id then
  80. TweenLite.Stop(self.pos_id)
  81. self.pos_id = nil
  82. end
  83. end
  84. function CSGWarInstructionView:StartCloseTimer( )
  85. local end_time = self.hide_time + TimeUtil:getServerTime()
  86. local function close_timer()
  87. local left_time = end_time - TimeUtil:getServerTime()
  88. self.close_text_tmp.text = left_time >= 0 and string.format("(%s秒后自动关闭)", HtmlColorTxt(math.ceil(left_time+1), ColorUtil.GREEN_DARK)) or ""
  89. if left_time < 0 then
  90. self:StopCloseTimer()
  91. self:CloseAnimation()
  92. end
  93. end
  94. close_timer()
  95. self.close_timer_id = GlobalTimerQuest:AddPeriodQuest(close_timer, 0.1, -1)
  96. end
  97. function CSGWarInstructionView:StopCloseTimer( )
  98. if self.close_timer_id then
  99. GlobalTimerQuest:CancelQuest(self.close_timer_id)
  100. self.close_timer_id = nil
  101. end
  102. end
  103. function CSGWarInstructionView:OpenSuccess()
  104. self:UpdateView()
  105. end
  106. function CSGWarInstructionView:UpdateView()
  107. local cfg = CSGWarConst.INSTRUCTION_VIEW_DESC
  108. for i=1,4 do
  109. self["text"..i.."_tmp"].text = cfg[i]
  110. end
  111. if self.need_auto_close then
  112. self:StartCloseTimer()
  113. end
  114. end
  115. function CSGWarInstructionView:SwitchTab( index )
  116. end
  117. function CSGWarInstructionView:DestroySuccess( )
  118. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  119. if self.tabWindowComponent then
  120. self.tabWindowComponent:DeleteMe()
  121. self.tabWindowComponent = nil
  122. end
  123. self:StopCloseTimer()
  124. self:StopCloseAnimation()
  125. end