home.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { _decorator, Component, Node } from 'cc';
  2. import { uiManager } from '../../manager/uiManager';
  3. import { home_car } from './home_car';
  4. import { home_top } from './home_top';
  5. import { home_bottom } from './home_bottom';
  6. import { tools } from '../../tools';
  7. import { ClientEvent } from '../../lib/clientEvent';
  8. import { config } from '../../config';
  9. import { userDataManager } from '../../manager/userDataManager';
  10. import { dataManager } from '../../manager/dataManager';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('home')
  13. export class home extends Component {
  14. @property(Node) home_car:Node = null
  15. @property(Node) top:Node = null
  16. @property(Node) bottom:Node = null
  17. @property(Node) btn_start_game:Node = null
  18. protected start(): void {
  19. uiManager.Instance().onButtonListen(this.btn_start_game,()=>{
  20. tools.playGame(()=>{
  21. this.node.parent.active = true
  22. })
  23. this.node.parent.active = false
  24. })
  25. ClientEvent.on(config.UI_EVENT.GET_NEW_CAR,this.onGetNewCar.bind(this),this)
  26. }
  27. onGetNewCar(){
  28. console.log("获取新车:",dataManager.getCarInfoById(userDataManager.user_car_list.default_car_id))
  29. }
  30. public init(){
  31. this.home_car.getComponent(home_car).updateCar()
  32. this.top.getComponent(home_top).init()
  33. this.bottom.getComponent(home_bottom).init()
  34. }
  35. }