地图修改

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
* 20
*
* 25 , id#id#id
* 26
* 27
*/
@ -75,6 +76,7 @@ public class EventType {
public static final int monitorMissionAndMove = 19;
public static final int destroyPointAnd = 20;
public static final int twentyFive = 25;
public static final int openAppointMission = 26;
public static final int openNotDoMission = 27;

View File

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

View File

@ -167,4 +167,28 @@ public class BehaviorUtil {
}
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;
import com.ljsd.jieling.handler.map.Cell;
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;
import java.util.Map;
@Component
public class DestroyPointBehavior extends BaseBehavior {
@Override

View File

@ -21,16 +21,6 @@ public class MonitorMissionBehavior extends BaseBehavior {
@Override
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
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;
return BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
}
}

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;
}
}