login_view.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { _decorator, Component, Label, Node, sys, Animation, resources, Prefab, instantiate, Tween, SpriteFrame, Sprite, UIOpacity } from 'cc';
  2. import { yinyue } from './yinyue';
  3. import { yinxiao } from './yinxiao';
  4. import { peiyin } from './peiyin';
  5. import { gameManager } from '../gameManager';
  6. import { config } from '../../config';
  7. import { sidebar_page } from '../sidebar/sidebar_page';
  8. import { SdkUtil } from '../../sdkUtil';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('login_view')
  11. export class login_view extends Component {
  12. @property(Node) btn_start:Node = null;
  13. @property(Node) yinyue:Node = null;
  14. @property(Node) yinxiao:Node = null;
  15. @property(Node) peiyin:Node = null;
  16. @property(Node) clock_node:Node = null;
  17. @property(Node) book_img:Node = null;
  18. @property(Node) btn_clear_data:Node = null;
  19. @property(Node) btn_check_debug:Node = null;
  20. @property(Node) lab_check_debug:Node = null;
  21. @property(Node) btn_sidebar_box:Node = null;
  22. private m_start_game_call = null;
  23. private book_img_original_sf:SpriteFrame = null;
  24. private is_start_game:boolean = false;
  25. protected start(): void {
  26. this.book_img_original_sf = this.book_img.getComponent(Sprite).spriteFrame
  27. }
  28. public initView(start_game_call){
  29. if(config.debug){
  30. if(sys.platform==sys.Platform.MOBILE_BROWSER){
  31. this.btn_clear_data.active = true;
  32. this.btn_clear_data.off(Node.EventType.TOUCH_END)
  33. this.btn_clear_data.on(Node.EventType.TOUCH_END,()=>{
  34. sys.localStorage.clear()
  35. })
  36. }else{
  37. this.btn_clear_data.active = false;
  38. }
  39. }else{
  40. this.btn_clear_data.active = false;
  41. }
  42. this.btn_check_debug.on(Node.EventType.TOUCH_END,()=>{
  43. this.lab_check_debug.getComponent(Label).string = `id:${gameManager.getStaticUserData().id}`
  44. })
  45. this.m_start_game_call = start_game_call;
  46. this.btn_start.off(Node.EventType.TOUCH_END)
  47. this.btn_start.on(Node.EventType.TOUCH_END,()=>{
  48. if(this.is_start_game) { return }
  49. this.is_start_game = true
  50. if(this.m_start_game_call!=null){
  51. this.startGame()
  52. } else {
  53. this.is_start_game = false
  54. }
  55. gameManager.Singleton.sys_click_button_music()
  56. })
  57. gameManager.Singleton.mSceneManager.play_music()
  58. this.yinyue.getComponent(yinyue).initView()
  59. this.yinxiao.getComponent(yinxiao).initView()
  60. this.peiyin.getComponent(peiyin).initView()
  61. }
  62. private startGame() {
  63. this.node.getComponent(Animation).play()
  64. setTimeout(()=>{
  65. this.is_start_game = false
  66. this.m_start_game_call()
  67. },920)
  68. }
  69. public show() {
  70. this.clock_node.getComponent(Animation).play()
  71. if(this.btn_sidebar_box.active) {
  72. this.btn_sidebar_box.getComponent(Animation).play()
  73. }
  74. }
  75. public hide() {
  76. this.book_img.getComponent(Sprite).spriteFrame = this.book_img_original_sf
  77. this.clock_node.getComponent(Animation).stop()
  78. if(this.btn_sidebar_box.active) {
  79. this.btn_sidebar_box.getComponent(Animation).stop()
  80. }
  81. }
  82. public checkSidebar() {
  83. let userUnlockLevesData = gameManager.getUserUnlockLevesData()
  84. if(SdkUtil.ttCheckSceneShowRewards()==false || userUnlockLevesData.status==1) {
  85. return
  86. }
  87. this.btn_sidebar_box.active = true
  88. this.btn_sidebar_box.getComponent(Animation).play()
  89. this.btn_sidebar_box.off(Node.EventType.TOUCH_END)
  90. this.btn_sidebar_box.on(Node.EventType.TOUCH_END, ()=> {
  91. gameManager.Singleton.sys_click_button_music()
  92. resources.load("prefab/run/sidebar_page", Prefab, (err, prefab)=> {
  93. if(!err) {
  94. let node = instantiate(prefab)
  95. node.parent = this.node
  96. let isToEnterFromSidebar = SdkUtil.ttCheckToEnterFromSidebar()
  97. node.getComponent(sidebar_page).show(isToEnterFromSidebar, (view:sidebar_page)=> {
  98. gameManager.request_user_unlock_number_status(config.User_unlock_levels_number_status.RECEIVE,(data)=> {
  99. view.close()
  100. this.btn_sidebar_box.getComponent(Animation).stop()
  101. this.btn_sidebar_box.active = false
  102. },null)
  103. })
  104. }
  105. })
  106. })
  107. }
  108. }