mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
56 lines
1.3 KiB
TypeScript
56 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';
|
|
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().playerName;
|
|
}
|
|
|
|
//打开Demo页面
|
|
onOpenDemo(){
|
|
app.layer.Open(GUI.Home);
|
|
}
|
|
|
|
//打开聊天页面
|
|
onOpenChat(){
|
|
app.layer.Open(GUI.MainChat);
|
|
}
|
|
|
|
//点击打开无限模式
|
|
onOpenOnHook(){
|
|
GBattleModeManager.getIns().Open(BattleMode.OnHook,true);
|
|
}
|
|
|
|
//点击PVP模式
|
|
onOpenPVP(){
|
|
app.socket.Send(GAction.S_MODE_PVP_JOIN);
|
|
}
|
|
|
|
}
|
|
|
|
|