mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
127 lines
3.1 KiB
TypeScript
127 lines
3.1 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';
|
|
import GOnHookManager, { GOnHookManagerEvent } from '../../manager/battle/mode/GOnHookManager';
|
|
import { Button } from 'cc';
|
|
import GOnHookData, { GOnHookDataEnum } from '../../data/GOnHookData';
|
|
import { Sprite } from 'cc';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('MainView')
|
|
export class MainView extends JNGLayerBase {
|
|
|
|
@property(Label)
|
|
onHookLabel:Label; //挂机文本
|
|
|
|
@property(Button)
|
|
nextLevelBtn:Button; //下一关按钮
|
|
|
|
onJNLoad(data?: any): void {
|
|
|
|
super.onJNLoad(data);
|
|
|
|
//发送消息
|
|
ChatData.getIns().onSend({
|
|
message:`加入游戏`
|
|
});
|
|
|
|
this.onUpdateView();
|
|
|
|
//监听
|
|
app.event.on(GOnHookManagerEvent.UPDATE_ON_HOOK_STATE,this.onUpdateOnHook,this);
|
|
app.event.on(GOnHookDataEnum.UPDATE,this.onUpdateOnHookInfo,this);
|
|
|
|
}
|
|
|
|
|
|
onJNClose(): void {
|
|
super.onJNClose();
|
|
//取消监听
|
|
app.event.off(GOnHookManagerEvent.UPDATE_ON_HOOK_STATE,this.onUpdateOnHook,this);
|
|
app.event.off(GOnHookDataEnum.UPDATE,this.onUpdateOnHookInfo,this);
|
|
}
|
|
|
|
onUpdateOnHook(){
|
|
this.onHookLabel.string = (GOnHookManager.getIns().isOnHook) ? "挂机中" : "挂机";
|
|
}
|
|
|
|
onUpdateOnHookInfo(){
|
|
this.nextLevelBtn.node.active = GOnHookData.getIns().isNextLevel;
|
|
}
|
|
|
|
//更新UI界面
|
|
onUpdateView(){
|
|
this.onUpdateOnHookInfo();
|
|
this.onUpdateOnHook();
|
|
}
|
|
|
|
//打开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);
|
|
}
|
|
|
|
//点击排行榜
|
|
onOpenOnHookRinking(){
|
|
app.layer.Open(GUI.OnHookRinkingView,GOnHookData.getIns().info.onHookMap);
|
|
}
|
|
|
|
//敬请期待
|
|
onClickNotOpen(){
|
|
app.layer.Open(GUI.Tips,{text:"敬请期待"})
|
|
}
|
|
|
|
//打开Debugger
|
|
onClickDebugger(){
|
|
app.layer.Open(GUI.Debugger);
|
|
}
|
|
|
|
//打开宠物装备
|
|
onClickPetEquip(){
|
|
app.layer.Open(GUI.PetEquipView);
|
|
}
|
|
|
|
//点击下一关
|
|
async onClickNextLevel(){
|
|
GOnHookManager.getIns().onNextLevel();
|
|
}
|
|
|
|
//点击进入副本
|
|
onClickDungeon(){
|
|
app.layer.Open(GUI.DungeonView);
|
|
}
|
|
|
|
}
|
|
|
|
|