lawless/client/assets/scripts/scenes/LobbyScene.ts

48 行
1.7 KiB
TypeScript

import { _decorator, Component, Button } from 'cc';
import { GameManager } from '../core/GameManager';
const { ccclass, property } = _decorator;
/**
* LobbyScene 主大厅:显示洪荒近况、入口导航。
*/
@ccclass('LobbyScene')
export class LobbyScene extends Component {
@property({ type: Button })
public mapButton: Button | null = null;
@property({ type: Button })
public bagButton: Button | null = null;
@property({ type: Button })
public socialButton: Button | null = null;
@property({ type: Button })
public settingButton: Button | null = null;
onLoad() {
this.mapButton?.node.on(Button.EventType.CLICK, () => this.goTo('MapScene'), this);
this.bagButton?.node.on(Button.EventType.CLICK, () => this.goTo('BagScene'), this);
this.socialButton?.node.on(Button.EventType.CLICK, () => this.goTo('SocialScene'), this);
this.settingButton?.node.on(Button.EventType.CLICK, () => this.goTo('SettingScene'), this);
// TODO: 登录后拉取角色状态与信息流
this.refreshCharacter();
}
private goTo(sceneName: string) {
GameManager.getInstance().switchScene(sceneName);
}
private async refreshCharacter() {
// TODO: CharacterService/GetCharacter
}
onDestroy() {
this.mapButton?.node.off(Button.EventType.CLICK, () => this.goTo('MapScene'), this);
this.bagButton?.node.off(Button.EventType.CLICK, () => this.goTo('BagScene'), this);
this.socialButton?.node.off(Button.EventType.CLICK, () => this.goTo('SocialScene'), this);
this.settingButton?.node.off(Button.EventType.CLICK, () => this.goTo('SettingScene'), this);
}
}