game_run.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { _decorator, Component, Node, Tween } 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 { control } from '../edit/control';
  9. import { loading_view } from './loading_view/loading_view';
  10. import { login_view } from './login_view/login_view';
  11. import { game_list } from './game_list_view/game_list';
  12. import { check_open } from './check_open';
  13. import { scene_page } from './scene_page';
  14. const { ccclass, property } = _decorator;
  15. @ccclass('game_run')
  16. export class game_run extends Component {
  17. @property(Node) scene_layer:Node = null;
  18. @property(Node) ui_layer:Node = null;
  19. @property(Node) top_layer:Node = null;
  20. @property(Node) btn_close:Node = null;
  21. @property(Node) launch:Node = null;
  22. @property(Node) game_list:Node = null;
  23. @property(Node) login_view:Node = null;
  24. @property(Node) loading_view:Node = null;
  25. @property(Node) loading_level:Node = null;
  26. @property(Node) check_open:Node = null;
  27. @property(gameManager) mGameManger:gameManager = null;
  28. protected start(): void {
  29. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  30. this.unInit()
  31. this.close()
  32. })
  33. }
  34. public unInit(){
  35. Tween.stopAll()
  36. this.ui_layer.getComponent(ui_layer).unInit()
  37. this.top_layer.getComponent(top_layer).unInit()
  38. this.scene_layer.getComponent(scene_layer).unInit()
  39. }
  40. public close(){
  41. this.node.removeFromParent()
  42. }
  43. public run(callback=null){
  44. this.mGameManger.init(this,control.Singleton.get_bag_data().content,callback)
  45. }
  46. public runAll(){
  47. this.loading_view.active = true;
  48. this.login_view.active = false;
  49. this.game_list.active = false;
  50. this.mGameManger.initGR(this)
  51. this.loading_view.getComponent(loading_view).startLoading(()=>{
  52. this.loading_view.active = false;
  53. this.showLogin()
  54. })
  55. }
  56. public showLogin(){
  57. this.login_view.active = true;
  58. this.login_view.getComponent(login_view).initView(()=>{
  59. this.showGameList(()=>{ //加载完成关闭登录界面
  60. this.login_view.active = false;
  61. })
  62. })
  63. }
  64. public isCurScenePageCheckWidgetFinish(widget_id:number):boolean{
  65. return this.scene_layer.getComponent(scene_layer).isCurScenePageCheckWidgetFinish(widget_id)
  66. }
  67. public isCurScenePageCheckWidgetShow(widget_id:number):boolean{
  68. return this.scene_layer.getComponent(scene_layer).isCurScenePageCheckWidgetShow(widget_id)
  69. }
  70. public showGameList(call){
  71. this.game_list.active = true;
  72. this.game_list.getComponent(game_list).initView(call,()=>{
  73. this.game_list.active = false;
  74. this.showLogin()
  75. })
  76. }
  77. public loadSceneTask(data:task_data) {
  78. this.scene_layer.getComponent(scene_layer).initSceneTask(data)
  79. }
  80. public loadSceneLayer(pages:scene_item_data[],type:number){
  81. this.scene_layer.getComponent(scene_layer).initScene(pages,type)
  82. }
  83. public getCurSceneLayerPage():scene_page{
  84. return this.scene_layer.getComponent(scene_layer).getCurScenePage()
  85. }
  86. public loadUILayer(ui_widge_list:widget_item_data[]){
  87. this.ui_layer.getComponent(ui_layer).initUi(ui_widge_list)
  88. this.initTop()
  89. }
  90. public initTop(){
  91. this.top_layer.getComponent(top_layer).initTop()
  92. }
  93. public loadTextSound(ui_widge_list:widget_item_data[]){
  94. this.top_layer.getComponent(top_layer).initTextSoundLlist(ui_widge_list)
  95. }
  96. public initQuestionList(ui_widge_list:widget_item_data[]){
  97. this.top_layer.getComponent(top_layer).initQuestionList(ui_widge_list)
  98. }
  99. public initCountDownList(count_down_list:widget_item_data[]){
  100. this.ui_layer.getComponent(ui_layer).initCountDownList(count_down_list)
  101. }
  102. public initTaskUi(data:task_data){
  103. this.ui_layer.getComponent(ui_layer).initTaskUi(data)
  104. // if(data.type===config.task_type.guo_ju_qing){
  105. // }
  106. this.top_layer.getComponent(top_layer).initRuleAndTips()
  107. }
  108. public showFindRuleTips(){
  109. this.top_layer.getComponent(top_layer).showFindRuleTips()
  110. }
  111. public showTips(){
  112. this.top_layer.getComponent(top_layer).showTips()
  113. }
  114. public showRule(){
  115. this.top_layer.getComponent(top_layer).showRule()
  116. }
  117. public showCheck(call){
  118. this.check_open.getComponent(check_open).show(call)
  119. }
  120. public backGameList(){
  121. this.unInit()
  122. this.onlaunch(()=>{
  123. this.showGameList(()=>{
  124. })
  125. })
  126. }
  127. public showLoadingLevel(){
  128. this.loading_level.active = true;
  129. }
  130. public hideLoadingLevel(){
  131. this.loading_level.active = false;
  132. }
  133. public loadTopLayer(){
  134. }
  135. public onlaunch(call,delay:number=0.7){
  136. this.launch.active = true;
  137. call()
  138. this.scheduleOnce(()=>{
  139. this.launch.active = false;
  140. },delay)
  141. }
  142. }