game_run.ts 7.3 KB

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