Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
c1c3b15fc9
|
@ -23,7 +23,7 @@ public class SRingFireMaterialConfig implements BaseConfig {
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
Map<Integer, SRingFireMaterialConfig> configTmp = STableManager.getConfig(SRingFireMaterialConfig.class);
|
Map<Integer, SRingFireMaterialConfig> configTmp = STableManager.getConfig(SRingFireMaterialConfig.class);
|
||||||
Map<Integer, SRingFireMaterialConfig> configMap = new HashMap<>();
|
Map<Integer, SRingFireMaterialConfig> configMap = new HashMap<>();
|
||||||
for(SRingFireMaterialConfig sRingFireMaterialConfig : configMap.values()){
|
for(SRingFireMaterialConfig sRingFireMaterialConfig : configTmp.values()){
|
||||||
configMap.put(sRingFireMaterialConfig.getFireId(),sRingFireMaterialConfig);
|
configMap.put(sRingFireMaterialConfig.getFireId(),sRingFireMaterialConfig);
|
||||||
}
|
}
|
||||||
config = configMap;
|
config = configMap;
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class FunctionOfTimeHandler extends BaseHandler{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
iSession.setFiveReady(1);
|
||||||
GlobalDataManaager.getInstance().getTimeOfControl(iSession);
|
GlobalDataManaager.getInstance().getTimeOfControl(iSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,7 +437,8 @@ public class MapLogic {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mapManager.getStartExporeTime() == 0) {
|
if (mapManager.getStartExporeTime() == 0) {
|
||||||
LOGGER.info("mapManager.getStartExporeTime() == 0");
|
LOGGER.info("mapMana" +
|
||||||
|
"ger.getStartExporeTime() == 0");
|
||||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "未开始探索");
|
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "未开始探索");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.ljsd.jieling.handler.room;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.handler.BaseHandler;
|
||||||
|
import com.ljsd.jieling.logic.room.RoomManager;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import com.ljsd.jieling.protocols.RoomFightProto;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RoomMapUpdateEventHandler extends BaseHandler {
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.ROOM_MAP_UPDATE_EVENT_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
RoomFightProto.RoomMapUpdateEventRequest roomMapUpdateEventRequest = RoomFightProto.RoomMapUpdateEventRequest.parseFrom(netData.parseClientProtoNetData());
|
||||||
|
int triggerXY = roomMapUpdateEventRequest.getTriggerXY();
|
||||||
|
int eventType = roomMapUpdateEventRequest.getEventType();
|
||||||
|
RoomManager.updateRoomMapEvent(iSession,triggerXY,eventType);
|
||||||
|
}
|
||||||
|
}
|
|
@ -239,10 +239,10 @@ public class GlobalDataManaager {
|
||||||
fBuilder.addUserMissionInfo(CommonProto.UserMissionInfo.newBuilder().setMissionId(sDailyTasksConfig.getId()).setState(0).setType(dailymissionType).setProgress(0));
|
fBuilder.addUserMissionInfo(CommonProto.UserMissionInfo.newBuilder().setMissionId(sDailyTasksConfig.getId()).setState(0).setType(dailymissionType).setProgress(0));
|
||||||
}
|
}
|
||||||
if(session.getFiveReady() == 1){ //客户端准备好接受五点刷新请求
|
if(session.getFiveReady() == 1){ //客户端准备好接受五点刷新请求
|
||||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FIVE_PLAYER_REFLUSH_INDICATION_VALUE,null,true);
|
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FIVE_PLAYER_REFLUSH_INDICATION_VALUE,fBuilder.build(),true);
|
||||||
}else{
|
}else{
|
||||||
int indicationIndex = session.getIndicationIndex();
|
int indicationIndex = session.getIndicationIndex();
|
||||||
byte[] byteBuf = MessageUtil.wrappedBuffer(session.getUid(), session.getToken(), indicationIndex,1, MessageTypeProto.MessageType.FIVE_PLAYER_REFLUSH_INDICATION_VALUE, null);
|
byte[] byteBuf = MessageUtil.wrappedBuffer(session.getUid(), session.getToken(), indicationIndex,1, MessageTypeProto.MessageType.FIVE_PLAYER_REFLUSH_INDICATION_VALUE, fBuilder.build());
|
||||||
session.setFiveByteBuf(byteBuf);
|
session.setFiveByteBuf(byteBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,9 +267,7 @@ public class GlobalDataManaager {
|
||||||
Tea.intToByte(packetData, 4, session.getToken()); //token
|
Tea.intToByte(packetData, 4, session.getToken()); //token
|
||||||
Tea.intToByte(packetData, 8,msgNum); //msgId
|
Tea.intToByte(packetData, 8,msgNum); //msgId
|
||||||
Tea.intToByte(packetData, 12, 0); // msgIndex
|
Tea.intToByte(packetData, 12, 0); // msgIndex
|
||||||
int[] secretKey = Tea.KEY;
|
return packetData;
|
||||||
byte[] finalData = Tea.encrypt2(packetData, secretKey);
|
|
||||||
return finalData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class PokemonManager extends MongoBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRingFirePokemon(Pokemon pokemon) throws Exception {
|
public void addRingFirePokemon(Pokemon pokemon) throws Exception {
|
||||||
pokemon.init(this.getRootId(),getMongoKey() + ".pokemonMap." + pokemon.getId());
|
pokemon.init(this.getRootId(),getMongoKey() + ".ringFireMap." + pokemon.getId());
|
||||||
updateString("ringFireMap." + pokemon.getId(), pokemon);
|
updateString("ringFireMap." + pokemon.getId(), pokemon);
|
||||||
ringFireMap.put(pokemon.getId(),pokemon);
|
ringFireMap.put(pokemon.getId(),pokemon);
|
||||||
}
|
}
|
||||||
|
|
|
@ -870,11 +870,14 @@ public class HeroLogic {
|
||||||
Pokemon pokemon = item.getValue();
|
Pokemon pokemon = item.getValue();
|
||||||
int allStage = pokemon.getAllStage();
|
int allStage = pokemon.getAllStage();
|
||||||
SRingFireConfig sRingFireConfig = SRingFireConfig.getsRingFireByRingIdAndLevel(pokemon.getId(), allStage);
|
SRingFireConfig sRingFireConfig = SRingFireConfig.getsRingFireByRingIdAndLevel(pokemon.getId(), allStage);
|
||||||
int[][] property = sRingFireConfig.getProperty();
|
if(sRingFireConfig == null){
|
||||||
if(property == null){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
int[][] property = sRingFireConfig.getProperty();
|
||||||
|
if(property != null){
|
||||||
combinedAttribute(property,heroAllAttribute);
|
combinedAttribute(property,heroAllAttribute);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=1;i<allStage;i++){
|
for(int i=1;i<allStage;i++){
|
||||||
SRingFireConfig sRingFireConfigTmp = SRingFireConfig.getsRingFireByRingIdAndLevel(pokemon.getId(), i);
|
SRingFireConfig sRingFireConfigTmp = SRingFireConfig.getsRingFireByRingIdAndLevel(pokemon.getId(), i);
|
||||||
int[] fireIds = sRingFireConfigTmp.getFireId();
|
int[] fireIds = sRingFireConfigTmp.getFireId();
|
||||||
|
|
|
@ -10,12 +10,11 @@ import com.ljsd.jieling.protocols.RoomFightProto;
|
||||||
import com.ljsd.jieling.protocols.RoomProto;
|
import com.ljsd.jieling.protocols.RoomProto;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Room {
|
public class Room {
|
||||||
private int roomId;
|
private int roomId;
|
||||||
private RoomPlayerInfo[] roomPlayerInfos;
|
private Map<Integer,RoomPlayerInfo> roomPlayerInfoMap;
|
||||||
private long gameStartTimestamp; //游戏开始时间戳
|
private long gameStartTimestamp; //游戏开始时间戳
|
||||||
//private static long MAX_GAME_LENGTH = 2*60*1000; //2分钟
|
//private static long MAX_GAME_LENGTH = 2*60*1000; //2分钟
|
||||||
private static int MAX_GAME_LENGTH = 15*1000; //15秒测试使用
|
private static int MAX_GAME_LENGTH = 15*1000; //15秒测试使用
|
||||||
|
@ -27,29 +26,25 @@ public class Room {
|
||||||
{
|
{
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
roomPlayerInfos = new RoomPlayerInfo[playerArray.length];
|
roomPlayerInfoMap = new HashMap<>(2);
|
||||||
for(int i=0; i<playerArray.length; i++){
|
for(int uid:playerArray){
|
||||||
roomPlayerInfos[i] = new RoomPlayerInfo(playerArray[i]);
|
roomPlayerInfoMap.put(uid,new RoomPlayerInfo(uid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RoomPlayerInfo getPlayer(int uid){
|
private RoomPlayerInfo getPlayer(int uid){
|
||||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
return roomPlayerInfoMap.get(uid);
|
||||||
if(roomPlayerInfos[i] != null && roomPlayerInfos[i].getUid() == uid){
|
|
||||||
return roomPlayerInfos[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
public boolean removeUserIsEndGame(RoomProto.RoomCancelMatchRequest request, User user)
|
public boolean removeUserIsEndGame(RoomProto.RoomCancelMatchRequest request, User user)
|
||||||
{
|
{
|
||||||
int curUserNumber = 0;
|
int curUserNumber = 0;
|
||||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
Iterator<Integer> iterator = roomPlayerInfoMap.keySet().iterator();
|
||||||
if(user.getId() == roomPlayerInfos[i].getUid()){
|
while (iterator.hasNext()){
|
||||||
|
Integer uid = iterator.next();
|
||||||
|
if(user.getId() == uid){
|
||||||
//将该用户从房间中移除
|
//将该用户从房间中移除
|
||||||
roomPlayerInfos[i] = null;
|
iterator.remove();
|
||||||
}
|
}else{
|
||||||
if(roomPlayerInfos[i] != null){
|
|
||||||
curUserNumber++;
|
curUserNumber++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,14 +62,10 @@ public class Room {
|
||||||
if(user != null){
|
if(user != null){
|
||||||
MessageUtil.sendRoomGameEndIndication(user.getId(), roomId);
|
MessageUtil.sendRoomGameEndIndication(user.getId(), roomId);
|
||||||
}
|
}
|
||||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
Set<Integer> uids = roomPlayerInfoMap.keySet();
|
||||||
if(roomPlayerInfos[i] == null) {
|
for(int uid :uids){
|
||||||
continue;
|
user = UserManager.getUserInMem(uid);
|
||||||
}
|
|
||||||
//发送游戏结束消息
|
|
||||||
user = UserManager.getUserInMem(roomPlayerInfos[i].getUid());
|
|
||||||
user.getRoomInfo().setRoomId(-1);
|
user.getRoomInfo().setRoomId(-1);
|
||||||
|
|
||||||
MessageUtil.sendRoomGameEndIndication(user.getId(), roomId);
|
MessageUtil.sendRoomGameEndIndication(user.getId(), roomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,28 +90,22 @@ public class Room {
|
||||||
|
|
||||||
public void startGame(){
|
public void startGame(){
|
||||||
gameStartTimestamp = System.currentTimeMillis();
|
gameStartTimestamp = System.currentTimeMillis();
|
||||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
for(RoomPlayerInfo roomPlayerInfo : roomPlayerInfoMap.values()){
|
||||||
if(roomPlayerInfos[i] == null) {
|
roomPlayerInfo.setState(RoomPlayerInfo.GAMING_STATE);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
roomPlayerInfos[i].setState(RoomPlayerInfo.GAMING_STATE);
|
|
||||||
//发送游戏开始消息
|
//发送游戏开始消息
|
||||||
MessageUtil.sendRoomStartGameIndication(roomPlayerInfos[i].getUid(), roomId, type);
|
MessageUtil.sendRoomStartGameIndication(roomPlayerInfo.getUid(), roomId, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ready(int uid){
|
public void ready(int uid){
|
||||||
int activeNumber = 0;
|
int activeNumber = 0;
|
||||||
int readyNumber = 0;
|
int readyNumber = 0;
|
||||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
for(RoomPlayerInfo roomPlayerInfo : roomPlayerInfoMap.values()){
|
||||||
if(roomPlayerInfos[i] != null){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
activeNumber++;
|
activeNumber++;
|
||||||
if(roomPlayerInfos[i].getUid() == uid){
|
if(roomPlayerInfo.getUid() == uid){
|
||||||
roomPlayerInfos[i].setState(RoomPlayerInfo.READYED_STATE);
|
roomPlayerInfo.setState(RoomPlayerInfo.READYED_STATE);
|
||||||
}
|
}
|
||||||
if(roomPlayerInfos[i].getState() != RoomPlayerInfo.UNREADY_STATE){
|
if(roomPlayerInfo.getState() == RoomPlayerInfo.READYED_STATE){
|
||||||
readyNumber++;
|
readyNumber++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,21 +134,17 @@ public class Room {
|
||||||
if(!result){
|
if(!result){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Set<Integer> uids = roomPlayerInfoMap.keySet();
|
||||||
for(int i=0; i<roomPlayerInfos.length; i++){
|
for(int uid : uids){
|
||||||
if(roomPlayerInfos[i] == null){
|
MessageUtil.sendRoomSyncOtherMoveIndiction(uid,iSession.getUid(),request.getTartXYsList());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MessageUtil.sendRoomSyncOtherMoveIndiction(roomPlayerInfos[i].getUid(), request.getTartXYsList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//测试使用
|
public Map<Integer,RoomPlayerInfo> getRoomPlayers(){
|
||||||
public RoomPlayerInfo[] getPlayerArray()
|
return roomPlayerInfoMap;
|
||||||
{
|
|
||||||
return roomPlayerInfos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getType(){
|
public int getType(){
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ljsd.jieling.logic.room;
|
package com.ljsd.jieling.logic.room;
|
||||||
|
|
||||||
|
import com.google.protobuf.GeneratedMessage;
|
||||||
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.network.session.ISession;
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
@ -7,12 +9,16 @@ import com.ljsd.jieling.protocols.CommonProto;
|
||||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
import com.ljsd.jieling.protocols.RoomFightProto;
|
import com.ljsd.jieling.protocols.RoomFightProto;
|
||||||
import com.ljsd.jieling.protocols.RoomProto;
|
import com.ljsd.jieling.protocols.RoomProto;
|
||||||
|
import com.ljsd.jieling.thread.task.MinuteTask;
|
||||||
import com.ljsd.jieling.util.CellUtil;
|
import com.ljsd.jieling.util.CellUtil;
|
||||||
import com.ljsd.jieling.util.MessageUtil;
|
import com.ljsd.jieling.util.MessageUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class RoomManager {
|
public class RoomManager {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MinuteTask.class);
|
||||||
//先加入的玩家,在符合规则的情况下,要先匹配上
|
//先加入的玩家,在符合规则的情况下,要先匹配上
|
||||||
//value uid
|
//value uid
|
||||||
private static final List<Integer> matchingPlayerList = new ArrayList();
|
private static final List<Integer> matchingPlayerList = new ArrayList();
|
||||||
|
@ -107,18 +113,22 @@ public class RoomManager {
|
||||||
List<CommonProto.Cell> cells = new ArrayList<>();
|
List<CommonProto.Cell> cells = new ArrayList<>();
|
||||||
|
|
||||||
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
||||||
|
Map<Integer, RoomPlayerInfo> roomPlayers = room.getRoomPlayers();
|
||||||
for(int i=0; i<playerArray.length; i++)
|
for(int i=0; i<playerArray.length; i++)
|
||||||
{
|
{
|
||||||
User user = UserManager.getUserInMem(playerArray[i]);
|
User user = UserManager.getUserInMem(playerArray[i]);
|
||||||
user.getRoomInfo().setMatching(false);
|
user.getRoomInfo().setMatching(false);
|
||||||
user.getRoomInfo().setRoomId(roomId);
|
user.getRoomInfo().setRoomId(roomId);
|
||||||
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
||||||
|
int curXY = CellUtil.xy2Pos(4 + i, 4 + i);
|
||||||
agentInfoBuilder.setPlayerUid(user.getId())
|
agentInfoBuilder.setPlayerUid(user.getId())
|
||||||
.setCurHp(1000)
|
.setCurHp(1000)
|
||||||
.setMaxHp(1000)
|
.setMaxHp(1000)
|
||||||
.setCamp(i)
|
.setCamp(i)
|
||||||
.setCurXY(CellUtil.xy2Pos(4+i,4+i));
|
.setCurXY(curXY);
|
||||||
|
RoomPlayerInfo roomPlayerInfo = roomPlayers.get(playerArray[i]);
|
||||||
|
roomPlayerInfo.setCurPos(curXY);
|
||||||
|
roomPlayerInfo.setCamp(i);
|
||||||
agentInfoList.add(agentInfoBuilder.build());
|
agentInfoList.add(agentInfoBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,16 +151,15 @@ public class RoomManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<CommonProto.Cell> cells = new ArrayList<>();
|
List<CommonProto.Cell> cells = new ArrayList<>();
|
||||||
RoomPlayerInfo[] playerArray = room.getPlayerArray();
|
Map<Integer, RoomPlayerInfo> roomPlayers = room.getRoomPlayers();
|
||||||
int i=0;
|
|
||||||
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
||||||
for(RoomPlayerInfo roomPlayerInfo:playerArray) {
|
for(RoomPlayerInfo roomPlayerInfo:roomPlayers.values()) {
|
||||||
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
||||||
agentInfoBuilder.setPlayerUid(roomPlayerInfo.getUid())
|
agentInfoBuilder.setPlayerUid(roomPlayerInfo.getUid())
|
||||||
.setCurHp(1000)
|
.setCurHp(1000)
|
||||||
.setMaxHp(1000)
|
.setMaxHp(1000)
|
||||||
.setCamp(i++)
|
.setCamp(roomPlayerInfo.getCamp())
|
||||||
.setCurXY(CellUtil.xy2Pos(4+i,4+i));
|
.setCurXY(roomPlayerInfo.getCurPos());
|
||||||
agentInfoList.add(agentInfoBuilder.build());
|
agentInfoList.add(agentInfoBuilder.build());
|
||||||
}
|
}
|
||||||
MessageUtil.sendRoomInfoToPerson(iSession, room.getType(), roomId, 1, cells, agentInfoList);
|
MessageUtil.sendRoomInfoToPerson(iSession, room.getType(), roomId, 1, cells, agentInfoList);
|
||||||
|
@ -191,11 +200,6 @@ public class RoomManager {
|
||||||
MessageUtil.sendRoomStartGameReadyResponse(iSession, responseMsgId, room.getType());
|
MessageUtil.sendRoomStartGameReadyResponse(iSession, responseMsgId, room.getType());
|
||||||
room.ready(user.getId());
|
room.ready(user.getId());
|
||||||
}
|
}
|
||||||
//测试使用
|
|
||||||
public static List getMatchingPlayerList()
|
|
||||||
{
|
|
||||||
return matchingPlayerList;
|
|
||||||
}
|
|
||||||
|
|
||||||
//客户端发起请求,获取开始游戏时的初始数据
|
//客户端发起请求,获取开始游戏时的初始数据
|
||||||
public static synchronized void startGameRequset(ISession iSession, RoomFightProto.RoomGameStartRequest request, int responseMsgId) throws Exception {
|
public static synchronized void startGameRequset(ISession iSession, RoomFightProto.RoomGameStartRequest request, int responseMsgId) throws Exception {
|
||||||
|
@ -243,5 +247,67 @@ public class RoomManager {
|
||||||
{
|
{
|
||||||
return roomMap;
|
return roomMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateRoomMapEvent(ISession iSession, int triggerXY, int eventType) throws Exception {
|
||||||
|
User user = UserManager.getUserInMem(iSession.getUid());
|
||||||
|
int roomId = user.getRoomInfo().getRoomId();
|
||||||
|
int responseMsgId = MessageTypeProto.MessageType.ROOM_MAP_UPDATE_EVENT_RESPONSE_VALUE;
|
||||||
|
if(roomId == -1){
|
||||||
|
//没有在房间中
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0, responseMsgId, "没有在房间中");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Room room = getRoomById(user.getRoomInfo().getRoomId());
|
||||||
|
if(room == null){
|
||||||
|
//房间已经销毁,如果走到这一步,说明其他地方有错了
|
||||||
|
MessageUtil.sendErrorResponse(iSession, 0, responseMsgId, "房间已经销毁");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RoomPlayerInfo mine = room.getRoomPlayers().get(iSession.getUid());
|
||||||
|
mine.move(System.currentTimeMillis());
|
||||||
|
if(mine.getCurPos() != triggerXY){
|
||||||
|
LOGGER.info("the uid={},the server pos={},the client pos ={}",iSession.getUid(),mine.getCurPos(),triggerXY);
|
||||||
|
mine.setCurPos(triggerXY);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageUtil.sendMessage(iSession, 1, responseMsgId, null,true);
|
||||||
|
int targetUid = -1;
|
||||||
|
for(RoomPlayerInfo roomPlayerInfo : room.getRoomPlayers().values()){
|
||||||
|
int uid = roomPlayerInfo.getUid();
|
||||||
|
int curPos = roomPlayerInfo.getCurPos();
|
||||||
|
if(uid != iSession.getUid() && CellUtil.checkIsNextCell(curPos,triggerXY)){
|
||||||
|
RoomFightProto.RoomMapPointIndication build = RoomFightProto.RoomMapPointIndication.newBuilder().setEventType(eventType).setPlayer(uid).setTriggerXY(triggerXY).build();
|
||||||
|
sendRoomMapPointIndication(room.getRoomPlayers().keySet(),build,MessageTypeProto.MessageType.ROOM_MAP_POINT_INDICATION_VALUE);
|
||||||
|
build = RoomFightProto.RoomMapPointIndication.newBuilder().setEventType(eventType).setPlayer(iSession.getUid()).setTriggerXY(triggerXY).build();
|
||||||
|
sendRoomMapPointIndication(room.getRoomPlayers().keySet(),build,MessageTypeProto.MessageType.ROOM_MAP_POINT_INDICATION_VALUE);
|
||||||
|
targetUid = uid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(targetUid!=-1){
|
||||||
|
//更新血量
|
||||||
|
RoomFightProto.RoomTriggerFightIndication build = RoomFightProto.RoomTriggerFightIndication.newBuilder().setFightResult(1)
|
||||||
|
.setBluecurHp(150)
|
||||||
|
.setBluePlayer(iSession.getUid())
|
||||||
|
.setRedcurHp(100)
|
||||||
|
.setRedPlayer(targetUid)
|
||||||
|
.build();
|
||||||
|
sendRoomMapPointIndication(room.getRoomPlayers().keySet(),build,MessageTypeProto.MessageType.ROOM_PLAY_HP_UPDATE_INDICATION_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendRoomMapPointIndication( Set<Integer> notifyUids,GeneratedMessage generatedMessage,int msgId){
|
||||||
|
for(int uid : notifyUids){
|
||||||
|
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||||
|
if(sessionByUid == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MessageUtil.sendIndicationMessage(sessionByUid,1, msgId,generatedMessage,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.ljsd.jieling.logic.room;
|
package com.ljsd.jieling.logic.room;
|
||||||
|
|
||||||
import com.ljsd.jieling.protocols.RoomFightProto;
|
import com.ljsd.jieling.protocols.RoomFightProto;
|
||||||
|
import com.ljsd.jieling.util.CellUtil;
|
||||||
import com.ljsd.jieling.util.MapPoint;
|
import com.ljsd.jieling.util.MapPoint;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -17,8 +18,8 @@ public class RoomPlayerInfo {
|
||||||
private int curPos;
|
private int curPos;
|
||||||
private int camp;
|
private int camp;
|
||||||
private long preMoveTimestamp; //上次移动时间
|
private long preMoveTimestamp; //上次移动时间
|
||||||
private int speed; //移动速度
|
private int speed=500; //移动速度
|
||||||
private List<Integer> path; //根据目标点计算出来的移动路径
|
private List<Integer> path=new ArrayList<>(0); //根据目标点计算出来的移动路径
|
||||||
|
|
||||||
public RoomPlayerInfo(int uid) {
|
public RoomPlayerInfo(int uid) {
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
|
@ -27,22 +28,14 @@ public class RoomPlayerInfo {
|
||||||
|
|
||||||
//用户移动到新位置, 返回下一个点的坐标,用户展示客户端的转向,及模拟移动
|
//用户移动到新位置, 返回下一个点的坐标,用户展示客户端的转向,及模拟移动
|
||||||
public boolean move(List<Integer> path){
|
public boolean move(List<Integer> path){
|
||||||
int nextXY = path.get(0); //移动时的下一个点
|
if(!this.path.isEmpty()){
|
||||||
if(MapPoint.getX(curPos) == MapPoint.getX(nextXY)){
|
move(System.currentTimeMillis());
|
||||||
if(MapPoint.getY(curPos) != MapPoint.getY(nextXY) + 1 || MapPoint.getY(curPos) != MapPoint.getY(nextXY) -1){
|
|
||||||
//下一个点不是相邻的格子,作弊了
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
boolean continuous = CellUtil.isContinuous(curPos, path);
|
||||||
if(MapPoint.getY(curPos) == MapPoint.getY(nextXY)){
|
if(continuous){
|
||||||
if(MapPoint.getX(curPos) != MapPoint.getX(nextXY) + 1 || MapPoint.getX(curPos) != MapPoint.getX(nextXY) -1){
|
|
||||||
//下一个点不是相邻的格子,作弊了
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.path = path;
|
this.path = path;
|
||||||
return true;
|
}
|
||||||
|
return continuous;
|
||||||
}
|
}
|
||||||
|
|
||||||
//服务器模拟移动,如果前端模拟,则不需要服务气端调用这个函数,服务器端在事件触发的时候做校验即可
|
//服务器模拟移动,如果前端模拟,则不需要服务气端调用这个函数,服务器端在事件触发的时候做校验即可
|
||||||
|
@ -60,6 +53,7 @@ public class RoomPlayerInfo {
|
||||||
for(int i=0; i<moveDistance && i<path.size(); i++){
|
for(int i=0; i<moveDistance && i<path.size(); i++){
|
||||||
curPos = path.remove(0);
|
curPos = path.remove(0);
|
||||||
}
|
}
|
||||||
|
preMoveTimestamp = timestamp;
|
||||||
return curPos;
|
return curPos;
|
||||||
}
|
}
|
||||||
public int getUid() {
|
public int getUid() {
|
||||||
|
|
|
@ -142,6 +142,10 @@ public class ISession extends NettyGameSession {
|
||||||
return fiveReady;
|
return fiveReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFiveReady(int fiveReady) {
|
||||||
|
this.fiveReady = fiveReady;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getFiveByteBuf() {
|
public byte[] getFiveByteBuf() {
|
||||||
return fiveByteBuf;
|
return fiveByteBuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.io.IOException;
|
||||||
public class PlatConfigureTask implements Runnable {
|
public class PlatConfigureTask implements Runnable {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
||||||
public static int SLEEP_INTEVAL_TIME = 60 * 1000; //每1分钟检查一次
|
public static int SLEEP_INTEVAL_TIME = 60; //每1分钟检查一次
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -279,9 +279,9 @@ public class MessageUtil {
|
||||||
builder.setServerTimestamp(System.currentTimeMillis());
|
builder.setServerTimestamp(System.currentTimeMillis());
|
||||||
sendMessage(session, 1, responseMsgId, builder.build(), true);
|
sendMessage(session, 1, responseMsgId, builder.build(), true);
|
||||||
}
|
}
|
||||||
public static void sendRoomSyncOtherMoveIndiction(int uid, List<Integer> path) {
|
public static void sendRoomSyncOtherMoveIndiction(int uid, int targetUid,List<Integer> path) {
|
||||||
RoomFightProto.RoomSyncOtherMoveIndiction.Builder builder = RoomFightProto.RoomSyncOtherMoveIndiction.newBuilder();
|
RoomFightProto.RoomSyncOtherMoveIndiction.Builder builder = RoomFightProto.RoomSyncOtherMoveIndiction.newBuilder();
|
||||||
builder.setUid(uid);
|
builder.setUid(targetUid);
|
||||||
builder.addAllTartXYs(path);
|
builder.addAllTartXYs(path);
|
||||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||||
if(sessionByUid!=null){
|
if(sessionByUid!=null){
|
||||||
|
|
Loading…
Reference in New Issue