game_run.ts 5.0 KB

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