地图 边缘触发
parent
061e0f43c0
commit
6d89769a68
|
|
@ -204,7 +204,15 @@ public class MapLogic {
|
|||
}
|
||||
|
||||
|
||||
public void updateMap(ISession session, int curXY, List<Integer> cells, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
public void updateMap(ISession session, int curXY, int triggerXY, List<Integer> cells, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
if (triggerXY != curXY) {
|
||||
boolean isConnect = CellUtil.checkIsNextCell(curXY, triggerXY);
|
||||
if (!isConnect) {
|
||||
LOGGER.info("updateMap() curXY=>{},triggerXY=>{} is not connect", curXY, triggerXY);
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cells.isEmpty()) {
|
||||
LOGGER.info("cells.isEmpty()");
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
|
|
@ -220,10 +228,14 @@ public class MapLogic {
|
|||
}
|
||||
Cell cell = mapManager.getMapInfo().get(curXY);
|
||||
if (cell == null) {
|
||||
LOGGER.info("xy is wrong =>{}", curXY);
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
cell = mapManager.getMapInfo().get(triggerXY);
|
||||
if (cell == null) {
|
||||
LOGGER.info("xy is wrong =>{} triggerXY=>{}", curXY, triggerXY);
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
mapManager.setTriggerXY(triggerXY);
|
||||
mapManager.addWalkCells(new HashSet<>(cells));
|
||||
mapManager.setCurXY(curXY);
|
||||
MapInfoProto.MapUpdateResponse mapUpdateResponse = MapInfoProto.MapUpdateResponse.newBuilder()
|
||||
|
|
@ -250,9 +262,12 @@ public class MapLogic {
|
|||
}
|
||||
Cell cell = mapManager.getMapInfo().get(mapManager.getCurXY());
|
||||
if (cell == null) {
|
||||
LOGGER.info("cell == null xy is wrong =>{}", mapManager.getCurXY());
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
|
||||
if (cell == null) {
|
||||
LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY());
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
int bigEventId = cell.getEventId();
|
||||
if (eventId != bigEventId) {
|
||||
|
|
@ -284,9 +299,9 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
int schedule = cell.getPointId();
|
||||
if (schedule == -1) {
|
||||
LOGGER.info("event is finished,bigEventId=>{} smallEventId=>{}", bigEventId, -1);
|
||||
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(cell.getPointId());
|
||||
if (mapPointConfig == null) {
|
||||
LOGGER.info("event is finished,bigEventId=>{} smallEventId=>{}", bigEventId, cell.getPointId());
|
||||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
|
|
@ -354,7 +369,12 @@ public class MapLogic {
|
|||
break;
|
||||
}
|
||||
}
|
||||
cell = mapManager.getMapInfo().get(mapManager.getCurXY());
|
||||
if (mapPointConfig.getTriggerRules() == 1) {
|
||||
cell = mapManager.getMapInfo().get(mapManager.getCurXY());
|
||||
} else {
|
||||
cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
|
||||
}
|
||||
|
||||
// 检测该事件点是否已被销毁
|
||||
if (cell != null) {
|
||||
cell.setEventId(nextPoint);
|
||||
|
|
@ -388,8 +408,8 @@ public class MapLogic {
|
|||
if (dropBuilder != null) {
|
||||
eventUpdateResponse.setDrop(dropBuilder);
|
||||
}
|
||||
LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextPoint=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
|
||||
cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextPoint);
|
||||
// LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextPoint=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
|
||||
// cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextPoint, eventBehaviorCommon);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ public class MapManager extends MongoBase {
|
|||
|
||||
private int curXY;
|
||||
|
||||
private int triggerXY;
|
||||
|
||||
private int maxMapId;
|
||||
|
||||
private Set<String> heroes;
|
||||
|
|
@ -135,4 +137,12 @@ public class MapManager extends MongoBase {
|
|||
this.totalStep = totalStep;
|
||||
}
|
||||
|
||||
public int getTriggerXY() {
|
||||
return triggerXY;
|
||||
}
|
||||
|
||||
public void setTriggerXY(int triggerXY) {
|
||||
updateString( "triggerXY", triggerXY);
|
||||
this.triggerXY = triggerXY;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ public class MapUpdateRequestHandler extends BaseHandler{
|
|||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] message = netData.parseClientProtoNetData();
|
||||
MapInfoProto.MapUpdateRequest mapEnterRequest = MapInfoProto.MapUpdateRequest.parseFrom(message);
|
||||
MapLogic.getInstance().updateMap(iSession, mapEnterRequest.getCurXY(), mapEnterRequest.getCellsList(), MessageTypeProto.MessageType.MAP_UDPATE_RESPONSE);
|
||||
MapLogic.getInstance().updateMap(iSession, mapEnterRequest.getCurXY(), mapEnterRequest.getTriggerXY(), mapEnterRequest.getCellsList(), MessageTypeProto.MessageType.MAP_UDPATE_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ public class BehaviorUtil {
|
|||
mapInfo.remove(xy);
|
||||
}
|
||||
user.getMapManager().setMapInfo(mapInfo);
|
||||
LOGGER.info("distoryPoint=========>{}", user.getMapManager().getCurXY());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,23 +1,10 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.map.EventType;
|
||||
import com.ljsd.jieling.handler.map.MapManager;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MapInfoProto;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import com.ljsd.jieling.util.MonsterUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class FightBehavior extends BaseBehavior {
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue