mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
完美
This commit is contained in:
parent
e3781116dc
commit
e99fc3929c
@ -1,9 +1,10 @@
|
|||||||
import { _decorator, Component, director, instantiate, Node, Prefab } from 'cc';
|
import { _decorator, Component, director, instantiate, Node, Prefab } from 'cc';
|
||||||
import { app } from './App';
|
import { app } from './App';
|
||||||
import { Env, JNGame } from '../../extensions/ngame/assets/ngame/JNGame';
|
import { JNGame } from '../../extensions/ngame/assets/ngame/JNGame';
|
||||||
import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction';
|
import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction';
|
||||||
import { GOnHookPets } from '../../extensions/ngame/assets/ngame/message/proto';
|
import { GOnHookPets } from '../../extensions/ngame/assets/ngame/message/proto';
|
||||||
import { EnvCurrent } from './Env';
|
import { Env, EnvCurrent } from './Env';
|
||||||
|
import { GAction } from './consts/GAction';
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
window['GUser'] = "100000";
|
window['GUser'] = "100000";
|
||||||
@ -34,6 +35,11 @@ export class Main extends Component {
|
|||||||
// 创建世界
|
// 创建世界
|
||||||
director.getScene().addChild(instantiate(this.WorldPrefab));
|
director.getScene().addChild(instantiate(this.WorldPrefab));
|
||||||
|
|
||||||
|
if(EnvCurrent == Env.Server){
|
||||||
|
//发送就绪
|
||||||
|
app.socket.Send(GAction.CR_REFEREE_READY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ export enum GAction {
|
|||||||
|
|
||||||
|
|
||||||
/*************** 裁决 *********************/
|
/*************** 裁决 *********************/
|
||||||
|
CR_REFEREE_READY = 4000, //裁决就绪
|
||||||
CR_REFEREE_PVP_MODE = 4001, //裁决PVP模式
|
CR_REFEREE_PVP_MODE = 4001, //裁决PVP模式
|
||||||
CR_REFEREE_PVP_END = 4002, //裁决PVP结束
|
CR_REFEREE_PVP_END = 4002, //裁决PVP结束
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ export class MainView extends JNGLayerBase {
|
|||||||
|
|
||||||
//更新UI界面
|
//更新UI界面
|
||||||
onUpdateView(){
|
onUpdateView(){
|
||||||
this.playerNameLabel.string = PlayerData.getIns().getInfo().playerName;
|
this.playerNameLabel.string = `${PlayerData.getIns().getInfo().playerId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
//打开Demo页面
|
//打开Demo页面
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9e2487e3e4ab43fe9c1f4e736bc7f75244f2f21b
|
Subproject commit 0795f18e7e61b8f8f5bcef1b11fe388e290d031a
|
@ -20,6 +20,7 @@ public interface GActionEnum {
|
|||||||
|
|
||||||
|
|
||||||
/*************** 裁决 *********************/
|
/*************** 裁决 *********************/
|
||||||
|
int CR_REFEREE_READY = 4000; //裁决就绪
|
||||||
int CR_REFEREE_PVP_MODE = 4001; //裁决PVP模式
|
int CR_REFEREE_PVP_MODE = 4001; //裁决PVP模式
|
||||||
int CR_REFEREE_PVP_END = 4002; //裁决PVP结束
|
int CR_REFEREE_PVP_END = 4002; //裁决PVP结束
|
||||||
|
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package cn.jisol.game.actions;
|
||||||
|
|
||||||
|
public interface GActionEvent {
|
||||||
|
|
||||||
|
//裁决员空闲
|
||||||
|
static final String REFEREE_FREE = "GActionEvent_REFEREE_FREE";
|
||||||
|
|
||||||
|
}
|
@ -6,6 +6,7 @@ import cn.jisol.game.network.client.GRefereeClient;
|
|||||||
import cn.jisol.game.proto.GPVPMessage;
|
import cn.jisol.game.proto.GPVPMessage;
|
||||||
import cn.jisol.ngame.actions.core.NAction;
|
import cn.jisol.ngame.actions.core.NAction;
|
||||||
import cn.jisol.ngame.actions.core.NActionMethod;
|
import cn.jisol.ngame.actions.core.NActionMethod;
|
||||||
|
import cn.jisol.ngame.util.EventDispatcher;
|
||||||
import cn.jisol.ngame.util.JLoggerUtil;
|
import cn.jisol.ngame.util.JLoggerUtil;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -35,8 +36,8 @@ public class GRefereeAction {
|
|||||||
public static GRefereeClient getFreeReferee(){
|
public static GRefereeClient getFreeReferee(){
|
||||||
|
|
||||||
for (String key : REFEREES.keySet()) {
|
for (String key : REFEREES.keySet()) {
|
||||||
if (!(REFEREES.get(key).isReferee)) {
|
if (REFEREES.get(key).isReady) {
|
||||||
REFEREES.get(key).isReferee = true;
|
REFEREES.get(key).isReady = false;
|
||||||
return REFEREES.get(key);
|
return REFEREES.get(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,8 +50,10 @@ public class GRefereeAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//放回一个空闲裁决员
|
//放回一个空闲裁决员
|
||||||
|
@NActionMethod(GActionEnum.CR_REFEREE_READY)
|
||||||
public static void addFreeReferee(GRefereeClient referee){
|
public static void addFreeReferee(GRefereeClient referee){
|
||||||
referee.isReferee = false;
|
referee.isReady = true;
|
||||||
|
EventDispatcher.getInstance().dispatchEvent(GActionEvent.REFEREE_FREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//自动回收裁决
|
//自动回收裁决
|
||||||
|
@ -3,6 +3,7 @@ package cn.jisol.game.actions.onhook;
|
|||||||
import cn.hutool.json.JSON;
|
import cn.hutool.json.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.jisol.game.actions.GActionEnum;
|
import cn.jisol.game.actions.GActionEnum;
|
||||||
|
import cn.jisol.game.actions.GActionEvent;
|
||||||
import cn.jisol.game.actions.GRefereeAction;
|
import cn.jisol.game.actions.GRefereeAction;
|
||||||
import cn.jisol.game.controller.game.GPlayerPetController;
|
import cn.jisol.game.controller.game.GPlayerPetController;
|
||||||
import cn.jisol.game.controller.game.GPlayerTacticalController;
|
import cn.jisol.game.controller.game.GPlayerTacticalController;
|
||||||
@ -13,6 +14,7 @@ import cn.jisol.game.proto.GPVPMessage;
|
|||||||
import cn.jisol.game.service.PlayerTacticalService;
|
import cn.jisol.game.service.PlayerTacticalService;
|
||||||
import cn.jisol.ngame.actions.core.NAction;
|
import cn.jisol.ngame.actions.core.NAction;
|
||||||
import cn.jisol.ngame.actions.core.NActionMethod;
|
import cn.jisol.ngame.actions.core.NActionMethod;
|
||||||
|
import cn.jisol.ngame.util.EventDispatcher;
|
||||||
import cn.jisol.ngame.util.spring.SpringBeanUtils;
|
import cn.jisol.ngame.util.spring.SpringBeanUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -37,6 +39,10 @@ public class GPVPAction {
|
|||||||
}
|
}
|
||||||
},0,1000);
|
},0,1000);
|
||||||
|
|
||||||
|
EventDispatcher.getInstance().addListener(GActionEvent.REFEREE_FREE,(EventDispatcher.Event event) -> {
|
||||||
|
onUpdateMatchGame(); //刷新匹配
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//加入PVP
|
//加入PVP
|
||||||
@ -175,7 +181,7 @@ public class GPVPAction {
|
|||||||
|
|
||||||
System.out.println("获胜的玩家是:"+info.getWinnerId());
|
System.out.println("获胜的玩家是:"+info.getWinnerId());
|
||||||
//裁决结束 等待下次裁决
|
//裁决结束 等待下次裁决
|
||||||
referee.isReferee = false;
|
GRefereeAction.addFreeReferee(referee);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ import javax.websocket.Session;
|
|||||||
//裁决员客户端
|
//裁决员客户端
|
||||||
public class GRefereeClient extends GClient {
|
public class GRefereeClient extends GClient {
|
||||||
|
|
||||||
//是否正在裁决
|
//是否就绪
|
||||||
public boolean isReferee = false;
|
public boolean isReady = false;
|
||||||
|
|
||||||
public GRefereeClient(String token, Session session) {
|
public GRefereeClient(String token, Session session) {
|
||||||
super(token, session);
|
super(token, session);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user