地图修改

back_recharge
jiahuiwen 2019-03-23 17:14:18 +08:00
parent 6c70934842
commit 8d9b8e1ff8
6 changed files with 75 additions and 42 deletions

View File

@ -53,6 +53,7 @@ public class EventType {
* id#id#id0 * id#id#id0
* 20 * 20
* *
* 25 , id#id#id
* 26 * 26
* 27 * 27
*/ */
@ -75,6 +76,7 @@ public class EventType {
public static final int monitorMissionAndMove = 19; public static final int monitorMissionAndMove = 19;
public static final int destroyPointAnd = 20; public static final int destroyPointAnd = 20;
public static final int twentyFive = 25;
public static final int openAppointMission = 26; public static final int openAppointMission = 26;
public static final int openNotDoMission = 27; public static final int openNotDoMission = 27;

View File

@ -107,18 +107,18 @@ public class MapLogic {
if (mapId > mapManager.getCurMapId()) { if (mapId > mapManager.getCurMapId()) {
return; return;
} }
SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapId); // SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapId);
if (energy < scMapConfig.getEnergyConfused()) { // if (energy < scMapConfig.getEnergyConfused()) {
LOGGER.info("enterMap() uid=>{} energy=>{} need=>{} energy not enough ", uid, energy, scMapConfig.getEnergyConfused()); // LOGGER.info("enterMap() uid=>{} energy=>{} need=>{} energy not enough ", uid, energy, scMapConfig.getEnergyConfused());
MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), ""); // MessageUtil.sendErrorResponse(iSession, 0, messageType.getNumber(), "");
return; // return;
} // }
int leftEnergy = energy - scMapConfig.getEnergyConfused(); // int leftEnergy = energy - scMapConfig.getEnergyConfused();
user.getPlayerInfoManager().setEnergy(leftEnergy); // user.getPlayerInfoManager().setEnergy(leftEnergy);
if (mapId != mapManager.getCurMapId()) { // if (mapId != mapManager.getCurMapId()) {
initMap(mapManager, user); // initMap(mapManager, user);
user.setMapManager(mapManager); // user.setMapManager(mapManager);
} // }
} }
List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size()); List<CommonProto.Cell> cells = new ArrayList<>(mapManager.getMapInfo().size());
for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) { for (Map.Entry<Integer, Cell> entry : mapManager.getMapInfo().entrySet()) {
@ -230,6 +230,7 @@ public class MapLogic {
public void updateMap(ISession session, int curXY, int triggerXY, 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 {
LOGGER.info("updateMap() curXY=>{},triggerXY=>{}", curXY, triggerXY);
if (triggerXY != curXY) { if (triggerXY != curXY) {
boolean isConnect = CellUtil.checkIsNextCell(curXY, triggerXY); boolean isConnect = CellUtil.checkIsNextCell(curXY, triggerXY);
if (!isConnect) { if (!isConnect) {
@ -270,14 +271,11 @@ public class MapLogic {
} }
mapManager.setTotalStep(leftStep); mapManager.setTotalStep(leftStep);
} }
Cell cell = mapManager.getMapInfo().get(curXY); Cell cell = mapManager.getMapInfo().get(triggerXY);
if (cell == null) { if (cell == null) {
cell = mapManager.getMapInfo().get(triggerXY); LOGGER.info("xy is wrong =>{} triggerXY=>{}", curXY, triggerXY);
if (cell == null) { MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
LOGGER.info("xy is wrong =>{} triggerXY=>{}", curXY, triggerXY); return;
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
} }
mapManager.setTriggerXY(triggerXY); mapManager.setTriggerXY(triggerXY);
mapManager.addWalkCells(new HashSet<>(cells)); mapManager.addWalkCells(new HashSet<>(cells));
@ -305,14 +303,11 @@ public class MapLogic {
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), ""); MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return; return;
} }
Cell cell = mapManager.getMapInfo().get(mapManager.getCurXY()); Cell cell = mapManager.getMapInfo().get(mapManager.getTriggerXY());
if (cell == null) { if (cell == null) {
cell = mapManager.getMapInfo().get(mapManager.getTriggerXY()); LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY());
if (cell == null) { MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
LOGGER.info("cell == null xy is wrong =>{} triggerXY=>{}", mapManager.getCurXY(), mapManager.getTriggerXY()); return;
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
return;
}
} }
int bigEventId = cell.getEventId(); int bigEventId = cell.getEventId();
if (eventId != bigEventId) { if (eventId != bigEventId) {
@ -464,8 +459,8 @@ public class MapLogic {
if (dropBuilder != null) { if (dropBuilder != null) {
eventUpdateResponse.setDrop(dropBuilder); eventUpdateResponse.setDrop(dropBuilder);
} }
// LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(), LOGGER.info("updateEvent =====>success<====== xy=>{}, getPointId=>{} eventId={}, mission=>{}, nextEventId=>{}, eventBehaviorCommon=>{}", mapManager.getCurXY(), cell == null ? 0 : cell.getPointId(),
// cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon); cell == null ? 0 : cell.getEventId(), eventUpdateResponse.getMissionList(), nextEventId, eventBehaviorCommon);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true); MessageUtil.sendMessage(session, 1, messageType.getNumber(), eventUpdateResponse.build(), true);
} }

View File

@ -167,4 +167,28 @@ public class BehaviorUtil {
} }
return true; return true;
} }
/**
*
* @param user
*/
public static void destoryCurPoint(User user) {
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
mapInfo.remove(user.getMapManager().getCurXY());
}
/**
* eventId
* @param user
* @throws Exception
*/
public static void changeOtherPoint(User user, int pointId, int eventId) throws Exception {
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
for (Cell cell : mapInfo.values()) {
if (cell.getPointId() == pointId) {
cell.setEventId(eventId);
}
}
}
} }

View File

@ -1,13 +1,10 @@
package com.ljsd.jieling.handler.map.behavior; package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.handler.map.Cell;
import com.ljsd.jieling.handler.map.EventType; import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.MapInfoProto; import com.ljsd.jieling.protocols.MapInfoProto;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map;
@Component @Component
public class DestroyPointBehavior extends BaseBehavior { public class DestroyPointBehavior extends BaseBehavior {
@Override @Override

View File

@ -21,16 +21,6 @@ public class MonitorMissionBehavior extends BaseBehavior {
@Override @Override
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception { public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions(); return BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
if (mission == null || !mission.isOpen()) {
return false;
}
CheckMissionReturn checkMissionReturn = MissionLogic.getInstance().checkMission(mission, user);
for (Mission cmission : checkMissionReturn.missions){
CommonProto.Mission missionProto = MapLogic.getInstance().getMission(cmission);
eventUpdateResponse.addMission(missionProto);
}
return true;
} }
} }

View File

@ -0,0 +1,25 @@
package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.MapInfoProto;
import org.springframework.stereotype.Component;
@Component
public class TwentyFiveBehavior extends BaseBehavior {
@Override
public int getBehaviorType() {
return EventType.twentyFive;
}
@Override
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
boolean flag = BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
if (!flag) {
return flag;
}
BehaviorUtil.destoryCurPoint(user);
BehaviorUtil.changeOtherPoint(user, behaviorTypeValues[0][1], behaviorTypeValues[0][2]);
return true;
}
}