52 lines
1.2 KiB
TypeScript
Raw Normal View History

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