PC-20230316NUNE\Administrator 516d520c5e 提交地图
2023-12-23 19:00:53 +08:00

73 lines
1.7 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';
import { GAPI } from '../../consts/GAPI';
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);
}
//点击下一关
async onClickNextLevel(){
await GAPI.GOnHookNextLevel();
app.layer.Open(GUI.Tips,{text:"下一关"});
}
}