122 lines
3.0 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-20 18:25:50 +08:00
import { GAction } from '../../consts/GAction';
2023-12-23 19:00:53 +08:00
import { GAPI } from '../../consts/GAPI';
2023-12-28 02:56:34 +08:00
import GOnHookManager, { GOnHookManagerEvent } from '../../manager/battle/mode/GOnHookManager';
2024-01-03 15:51:16 +08:00
import { Button } from 'cc';
import GOnHookData, { GOnHookDataEnum } from '../../data/GOnHookData';
import { Sprite } from 'cc';
2023-11-13 02:37:29 +08:00
const { ccclass, property } = _decorator;
@ccclass('MainView')
export class MainView extends JNGLayerBase {
2023-12-28 02:56:34 +08:00
@property(Label)
onHookLabel:Label; //挂机文本
2024-01-03 15:51:16 +08:00
@property(Button)
nextLevelBtn:Button; //下一关按钮
2023-11-13 02:37:29 +08:00
onJNLoad(data?: any): void {
2023-11-14 18:52:25 +08:00
2023-12-28 02:56:34 +08:00
super.onJNLoad(data);
2023-11-14 18:52:25 +08:00
//发送消息
ChatData.getIns().onSend({
2024-01-05 02:15:38 +08:00
message:`加入游戏`
2023-11-14 18:52:25 +08:00
});
2023-11-15 02:32:00 +08:00
this.onUpdateView();
2023-12-28 02:56:34 +08:00
//监听
app.event.on(GOnHookManagerEvent.UPDATE_ON_HOOK_STATE,this.onUpdateOnHook,this);
2024-01-03 15:51:16 +08:00
app.event.on(GOnHookDataEnum.UPDATE,this.onUpdateOnHookInfo,this);
2023-12-28 02:56:34 +08:00
}
onJNClose(): void {
super.onJNClose();
//取消监听
2024-01-03 15:51:16 +08:00
app.event.off(GOnHookManagerEvent.UPDATE_ON_HOOK_STATE,this.onUpdateOnHook,this);
app.event.off(GOnHookDataEnum.UPDATE,this.onUpdateOnHookInfo,this);
2023-12-28 02:56:34 +08:00
}
onUpdateOnHook(){
this.onHookLabel.string = (GOnHookManager.getIns().isOnHook) ? "挂机中" : "挂机";
2023-11-15 02:32:00 +08:00
}
2024-01-03 15:51:16 +08:00
onUpdateOnHookInfo(){
this.nextLevelBtn.node.active = GOnHookData.getIns().isNextLevel;
}
2023-11-15 02:32:00 +08:00
//更新UI界面
onUpdateView(){
2024-01-03 15:51:16 +08:00
this.onUpdateOnHookInfo();
this.onUpdateOnHook();
2023-11-15 02:32:00 +08:00
}
//打开Demo页面
onOpenDemo(){
2023-12-10 00:58:43 +08:00
app.layer.Open(GUI.CampGuardianView);
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(){
2023-12-10 00:58:43 +08:00
GBattleModeManager.getIns().Open(BattleMode.CampGuardian,true);
2023-11-15 02:32:00 +08:00
}
2023-11-20 18:25:50 +08:00
//点击PVP模式
onOpenPVP(){
app.socket.Send(GAction.S_MODE_PVP_JOIN);
}
//点击挂机按钮
onOpenOnHookView(){
app.layer.Open(GUI.MainOnHookView);
}
//点击地图
onOpenMap(){
app.layer.Open(GUI.MapSelectView);
}
2024-01-04 18:58:21 +08:00
//点击排行榜
onOpenOnHookRinking(){
2024-01-05 17:45:57 +08:00
app.layer.Open(GUI.OnHookRinkingView,GOnHookData.getIns().info.onHookMap);
}
//敬请期待
onClickNotOpen(){
app.layer.Open(GUI.Tips,{text:"敬请期待"})
2024-01-04 18:58:21 +08:00
}
2024-01-09 11:52:44 +08:00
//打开Debugger
onClickDebugger(){
app.layer.Open(GUI.Debugger);
}
2024-01-09 18:32:21 +08:00
//打开宠物装备
onClickPetEquip(){
app.layer.Open(GUI.PetEquipView);
}
2023-12-23 19:00:53 +08:00
//点击下一关
async onClickNextLevel(){
2023-12-25 02:06:56 +08:00
GOnHookManager.getIns().onNextLevel();
2023-12-23 19:00:53 +08:00
}
2023-11-13 02:37:29 +08:00
}