game_run.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import { _decorator, Component, Node, sys, Tween, Animation } from 'cc';
  2. import { gameManager } from './gameManager';
  3. import { scene_item_data, task_data, widget_item_data } from '../../data/data';
  4. import { scene_layer } from './scene_layer';
  5. import { ui_layer } from './ui_layer';
  6. import { top_layer } from './top_layer';
  7. import { config } from '../config';
  8. import { loading_view } from './loading_view/loading_view';
  9. import { login_view } from './login_view/login_view';
  10. import { game_list } from './game_list_view/game_list';
  11. import { check_open } from './check_open';
  12. import { unLock_view } from './unLock_view/unLock_view';
  13. import { game_health_view } from './game_health_view/game_health_view';
  14. import { zb_login_view } from './zb_login_view/zb_login_view';
  15. import { scene_page } from './scene_page';
  16. const { ccclass, property } = _decorator;
  17. @ccclass('game_run')
  18. export class game_run extends Component {
  19. @property(Node) scene_layer:Node = null;
  20. @property(Node) ui_layer:Node = null;
  21. @property(Node) top_layer:Node = null;
  22. @property(Node) btn_close:Node = null;
  23. @property(Node) launch:Node = null;
  24. @property(Node) game_list:Node = null;
  25. @property(Node) login_view:Node = null;
  26. @property(Node) loading_view:Node = null;
  27. @property(Node) game_health_view:Node = null;
  28. @property(Node) loading_level:Node = null;
  29. @property(Node) check_open:Node = null;
  30. @property(Node) unLock_view:Node = null;
  31. @property(Node) zb_login_view:Node = null;
  32. @property(Node) top_floor_layer:Node = null;
  33. @property(gameManager) mGameManger:gameManager = null;
  34. protected start(): void {
  35. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  36. this.close()
  37. })
  38. }
  39. public unInit(){
  40. Tween.stopAll()
  41. this.ui_layer.getComponent(ui_layer).unInit()
  42. this.top_layer.getComponent(top_layer).unInit()
  43. this.scene_layer.getComponent(scene_layer).unInit()
  44. }
  45. public close(){
  46. this.node.removeFromParent()
  47. }
  48. public run(){
  49. }
  50. public showUnLockView(lock_one_call,lock_all_one_day){
  51. this.unLock_view.getComponent(unLock_view).show(lock_one_call,lock_all_one_day)
  52. }
  53. public runAll(){
  54. this.zb_login_view.active = false;
  55. this.game_health_view.active = false;
  56. this.loading_view.active = false;
  57. this.login_view.active = false;
  58. this.game_list.active = false;
  59. this.mGameManger.initGR(this)
  60. if(config.is_zb) {
  61. this.showZbLoginView()
  62. } else {
  63. if(sys.platform==sys.Platform.MOBILE_BROWSER) {
  64. this.showLoading()
  65. } else {
  66. this.showHealthView()
  67. }
  68. }
  69. }
  70. public showZbLoginView() {
  71. this.zb_login_view.active = true;
  72. this.zb_login_view.getComponent(zb_login_view).initView(()=> {
  73. this.showHealthView()
  74. })
  75. }
  76. public showHealthView() {
  77. this.game_health_view.active = true;
  78. this.game_health_view.getComponent(game_health_view).startShow(()=> {
  79. this.game_health_view.active = false;
  80. this.showLoading()
  81. })
  82. }
  83. public showLoading() {
  84. this.loading_view.active = true;
  85. this.loading_view.getComponent(loading_view).startLoading(()=>{
  86. this.loading_view.active = false;
  87. this.showLogin()
  88. this.login_view.getComponent(login_view).checkSidebar()
  89. })
  90. }
  91. public showLogin(){
  92. this.login_view.active = true;
  93. this.login_view.getComponent(login_view).show()
  94. this.login_view.getComponent(login_view).initView(()=>{
  95. this.showGameList(()=>{ //加载完成关闭登录界面
  96. this.login_view.active = false;
  97. this.login_view.getComponent(login_view).hide()
  98. })
  99. })
  100. }
  101. public showGameList(call){
  102. this.game_list.active = true;
  103. this.game_list.getComponent(game_list).initView(call,()=>{
  104. this.game_list.active = false;
  105. this.showLogin()
  106. })
  107. }
  108. public loadSceneTask(data:task_data) {
  109. this.scene_layer.getComponent(scene_layer).initSceneTask(data)
  110. }
  111. public loadSceneLayer(pages:scene_item_data[],type:number){
  112. this.scene_layer.getComponent(scene_layer).initScene(pages,type)
  113. }
  114. public getCurSceneLayerPage():scene_page{
  115. return this.scene_layer.getComponent(scene_layer).getCurScenePage()
  116. }
  117. public loadUILayer(ui_widge_list:widget_item_data[]){
  118. this.ui_layer.getComponent(ui_layer).initUi(ui_widge_list)
  119. this.initTop()
  120. }
  121. public initTop(){
  122. this.top_layer.getComponent(top_layer).initTop()
  123. }
  124. public loadTextSound(ui_widge_list:widget_item_data[]){
  125. this.top_layer.getComponent(top_layer).initTextSoundLlist(ui_widge_list)
  126. }
  127. public initQuestionList(ui_widge_list:widget_item_data[]){
  128. this.top_layer.getComponent(top_layer).initQuestionList(ui_widge_list)
  129. }
  130. public initCountDownList(count_down_list:widget_item_data[]){
  131. this.ui_layer.getComponent(ui_layer).initCountDownList(count_down_list)
  132. }
  133. public initTaskUi(data:task_data){
  134. this.ui_layer.getComponent(ui_layer).initTaskUi(data)
  135. // if(data.type===config.task_type.guo_ju_qing){
  136. // }
  137. this.top_layer.getComponent(top_layer).initRuleAndTips()
  138. }
  139. public showFindRuleTips(){
  140. this.top_layer.getComponent(top_layer).showFindRuleTips()
  141. }
  142. public showTips(){
  143. this.top_layer.getComponent(top_layer).showTips()
  144. }
  145. public showRule(){
  146. this.top_layer.getComponent(top_layer).showRule()
  147. }
  148. public showCheck(call){
  149. this.check_open.getComponent(check_open).show(call)
  150. }
  151. public backGameList(){
  152. this.unInit()
  153. this.onlaunch(()=>{
  154. this.showGameList(()=>{
  155. })
  156. })
  157. }
  158. public showLoadingLevel(){
  159. this.loading_level.active = true;
  160. this.loading_level.getComponent(Animation).play()
  161. }
  162. public hideLoadingLevel(){
  163. this.loading_level.active = false;
  164. this.loading_level.getComponent(Animation).stop()
  165. }
  166. public loadTopLayer(){
  167. }
  168. public onlaunch(call,delay:number=0.7){
  169. this.launch.active = true;
  170. call()
  171. this.scheduleOnce(()=>{
  172. this.launch.active = false;
  173. },delay)
  174. }
  175. public isCurScenePageCheckWidgetFinish(widget_id:number):boolean{
  176. return this.scene_layer.getComponent(scene_layer).isCurScenePageCheckWidgetFinish(widget_id)
  177. }
  178. public isCurScenePageCheckWidgetShow(widget_id:number):boolean{
  179. return this.scene_layer.getComponent(scene_layer).isCurScenePageCheckWidgetShow(widget_id)
  180. }
  181. }