1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { _decorator, Component, Node } from 'cc';
- import { uiManager } from '../../manager/uiManager';
- import { home_car } from './home_car';
- import { home_top } from './home_top';
- import { home_bottom } from './home_bottom';
- import { tools } from '../../tools';
- import { ClientEvent } from '../../lib/clientEvent';
- import { config } from '../../config';
- import { userDataManager } from '../../manager/userDataManager';
- import { user_results } from '../../data';
- const { ccclass, property } = _decorator;
- @ccclass('home')
- export class home extends Component {
- @property(Node) home_car:Node = null
- @property(Node) top:Node = null
- @property(Node) bottom:Node = null
- @property(Node) btn_start_game:Node = null
- protected start(): void {
- uiManager.Instance().onButtonListen(this.btn_start_game,()=>{
- tools.playGame(()=>{
- this.node.parent.active = true
- })
- this.node.parent.active = false
- })
- ClientEvent.on(config.UI_EVENT.GET_NEW_CAR,this.onGetNewCar.bind(this),this)
- ClientEvent.on(config.UI_EVENT.UPDATE_USER_DEFAULT_CAR,this.onUpdateUserDefaultCar.bind(this),this)
- ClientEvent.on(config.UI_EVENT.GAME_OVER_SETTLE_ACCOUNT,this.onGameOverSettleAccount.bind(this),this)
- }
- onGameOverSettleAccount(res:user_results){
- // 更新本周分数
- tools.mine_rank_data.score = res.max_integral
- this.bottom.getComponent(home_bottom).reloadWeekScore()
- }
- onGetNewCar(res:user_results){
- // 更新默认车
- userDataManager.user_car_list.default_car_id = res.default_car_id
- // console.log("获取新车:",dataManager.getCarInfoById(userDataManager.user_car_list.default_car_id))
- // 更新用户解锁车列表
- userDataManager.user_car_list.car_list = res.unlock_car_list
- // 更新首页车
- this.home_car.getComponent(home_car).updateCar()
- }
- onUpdateUserDefaultCar() {
- this.home_car.getComponent(home_car).updateCar()
- }
- public init(){
- this.top.getComponent(home_top).init()
- this.home_car.getComponent(home_car).updateCar()
- this.bottom.getComponent(home_bottom).init()
- this.everyTenMinutesUpdate()
- }
- private everyTenMinutesUpdate() {
- this.unscheduleAllCallbacks()
- this.schedule(()=>{
- this.bottom.getComponent(home_bottom).requestCountryRankData()
- this.top.getComponent(home_top).requestGuangboData()
- },600)
- }
- }
|