PC-20230316NUNE\Administrator 24a498a712 提交
2023-12-10 00:58:43 +08:00

66 lines
1.5 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';
import { GAction } from '../../consts/GAction';
const { ccclass, property } = _decorator;
@ccclass('MainView')
export class MainView extends JNGLayerBase {
@property(Label)
playerNameLabel:Label; //玩家名称
onJNLoad(data?: any): void {
//发送消息
ChatData.getIns().onSend({
message:`${PlayerData.getIns().data.playerId} 加入游戏`
});
this.onUpdateView();
}
//更新UI界面
onUpdateView(){
this.playerNameLabel.string = `${PlayerData.getIns().getInfo().playerId}`;
}
//打开Demo页面
onOpenDemo(){
app.layer.Open(GUI.CampGuardianView);
}
//打开聊天页面
onOpenChat(){
app.layer.Open(GUI.MainChat);
}
//点击打开无限模式
onOpenOnHook(){
GBattleModeManager.getIns().Open(BattleMode.CampGuardian,true);
}
//点击PVP模式
onOpenPVP(){
app.socket.Send(GAction.S_MODE_PVP_JOIN);
}
//点击挂机按钮
onOpenOnHookView(){
app.layer.Open(GUI.MainOnHookView);
}
//点击地图
onOpenMap(){
app.layer.Open(GUI.MapSelectView);
}
}