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

155 lines
4.6 KiB

  1. ExitConView = ExitConView or BaseClass(BaseView)
  2. local ExitConView = ExitConView
  3. function ExitConView:__init()
  4. self.base_file = "common"
  5. self.layout_file = "ExitConView"
  6. self.layer_name = "Main"
  7. self.destroy_imm = true
  8. self.change_scene_close = false
  9. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  10. self.need_show_money = false --是否要显示顶部的金钱栏
  11. ------------------------
  12. -- 一级全屏界面:
  13. self.hide_maincancas = false --隐藏主界面
  14. self.use_background = false --不一定显示遮罩
  15. self.load_callback = function ()
  16. self:LoadSuccess()
  17. end
  18. self.open_callback = function ( )
  19. self:OpenSuccess()
  20. end
  21. self.close_win_callback = function ( )
  22. self:Close()
  23. end
  24. self.destroy_callback = function ( )
  25. self:DestroySuccess()
  26. end
  27. self.wait_add_list = {}
  28. self.cur_node_list = {}
  29. end
  30. function ExitConView:Open( )
  31. BaseView.Open(self)
  32. end
  33. function ExitConView:LoadSuccess()
  34. self:AddEvent()
  35. SetAnchoredPosition( self.transform, -ClientConfig.iphone_x_offset_right, 0 )
  36. self.wait_add_list = StartToEnd(self.wait_add_list)
  37. for i=#self.wait_add_list ,1 ,-1 do
  38. local temp = table.remove(self.wait_add_list,i)
  39. self:AddNode( temp.node,temp.parent_node,temp.tag_str,temp.off_x, temp.off_y )
  40. end
  41. self:LittleMove(false)
  42. end
  43. function ExitConView:AddEvent()
  44. local function onOrientationChange()
  45. SetAnchoredPosition( self.transform, -ClientConfig.iphone_x_offset_right, 0 )
  46. end
  47. self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  48. local function activity_icon_changeFunc(is_hide)
  49. if self.gameObject then
  50. self.gameObject:SetActive(is_hide)
  51. end
  52. end
  53. self:BindEvent(GlobalEventSystem, EventName.NOTIFY_ACTIVITY_ICON_HIDE_STATE, activity_icon_changeFunc)
  54. local function onSceneStartHandler( )
  55. --场景加载完之后,没内容就关界面吧
  56. if (TableSize(self.wait_add_list) == 0) and (TableSize(self.cur_node_list) == 0) then
  57. self:Close()
  58. end
  59. end
  60. self:BindEvent(GlobalEventSystem, EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
  61. local function onLittleMove(is_out)
  62. self:LittleMove(is_out)
  63. end
  64. self:BindEvent(GlobalEventSystem, EventName.PLAY_MAINUI_MOVIE_EVENT, onLittleMove)
  65. end
  66. function ExitConView:LittleMove( is_out)
  67. if self.tween_lite_id_1 then
  68. TweenLite.Stop(self.tween_lite_id_1)
  69. self.tween_lite_id_1 = nil
  70. end
  71. if is_out then
  72. self.transform.anchoredPosition = Vector2(-ClientConfig.iphone_x_offset_right, 0)
  73. self.tween_lite_id_1 = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSY, MainUIModel.LITTLE_MOVE_OUT_DIST, MainUIModel.LITTLE_MOVE_OUT_TIME)
  74. else
  75. self.transform.anchoredPosition = Vector2( -ClientConfig.iphone_x_offset_right, MainUIModel.LITTLE_MOVE_DIST)
  76. self.tween_lite_id_1 = TweenLite.to(self, self.transform, TweenLite.UiAnimationType.ANCHORED_POSY, 0, MainUIModel.LITTLE_MOVE_TIME)
  77. end
  78. end
  79. function ExitConView:OpenSuccess()
  80. self:UpdateView()
  81. end
  82. function ExitConView:UpdatePosition( )
  83. for i,v in ipairs(self.cur_node_list) do
  84. SetAnchoredPosition( v.node.transform, - 67 * (i-1) -249.5 + v.off_x,-31.5 + v.off_y )
  85. end
  86. end
  87. function ExitConView:AddNode( node,parent_node,tag_str,off_x,off_y )
  88. local data = {tag_str = tag_str,node = node,parent_node = parent_node,off_x = off_x or 0,off_y = off_y or 0}
  89. if not self.is_loaded then
  90. for k,v in pairs(self.wait_add_list) do
  91. if v.tag_str == tag_str then
  92. print('---- ExitConView.lua -- 预备队列重复添加节点,请检查')
  93. return
  94. end
  95. end
  96. table.insert( self.wait_add_list, data )
  97. else
  98. for k,v in pairs(self.cur_node_list) do
  99. if v.tag_str == tag_str then
  100. print('---- ExitConView.lua -- 重复添加节点,请检查')
  101. return
  102. end
  103. end
  104. node.transform:SetParent(self.transform)
  105. table.insert( self.cur_node_list, data )
  106. self:UpdatePosition()
  107. end
  108. end
  109. function ExitConView:RemoveNode( node,tag_str )
  110. if not self.is_loaded then
  111. self.wait_add_list[tag_str] = nil
  112. for k,v in pairs(self.wait_add_list) do
  113. if v.tag_str == tag_str then
  114. table.remove(self.wait_add_list,k)
  115. break
  116. end
  117. end
  118. else
  119. --节点不见了??
  120. for k,v in pairs(self.cur_node_list) do
  121. if v.tag_str == tag_str then
  122. --送回父节点去
  123. local data = table.remove(self.cur_node_list,k)
  124. data.node.transform:SetParent(data.parent_node.transform)
  125. return
  126. end
  127. end
  128. self:UpdatePosition()
  129. end
  130. end
  131. function ExitConView:UpdateView()
  132. end
  133. function ExitConView:DestroySuccess( )
  134. if self.tween_lite_id_1 then
  135. TweenLite.Stop(self.tween_lite_id_1)
  136. self.tween_lite_id_1 = nil
  137. end
  138. end