PC-20230316NUNE\Administrator cb64a6c25f 提交捕捉
2023-11-17 18:29:39 +08:00

53 lines
1.3 KiB
TypeScript

import { _decorator, Component, Label, Node } from 'cc';
import { GUI } from '../UIConfig';
import ChatData from '../../data/ChatData';
import PlayerData from '../../data/PlayerData';
import GBattleModeManager, { BattleMode } from '../../battle/GBattleModeManager';
import { JNGLayerBase } from '../../components/JNComponent';
import { app } from '../../App';
const { ccclass, property } = _decorator;
@ccclass('MainView')
export class MainView extends JNGLayerBase {
@property(Label)
playerNameLabel:Label; //玩家名称
onJNLoad(data?: any): void {
//默认无限模式
GBattleModeManager.getIns().Open(BattleMode.OnHook,true);
//发送消息
ChatData.getIns().onSend({
message:`${PlayerData.getIns().data.playerId} 加入游戏`
});
this.onUpdateView();
}
//更新UI界面
onUpdateView(){
this.playerNameLabel.string = PlayerData.getIns().getInfo().playerName;
}
//打开Demo页面
onOpenDemo(){
app.layer.Open(GUI.Home);
}
//打开聊天页面
onOpenChat(){
app.layer.Open(GUI.MainChat);
}
//点击打开无限模式
onOpenOnHook(){
GBattleModeManager.getIns().Open(BattleMode.OnHook,true);
}
}