添加行为,可以开启其他地图点

back_recharge
jiahuiwen 2019-04-08 14:51:12 +08:00
parent c2f03f171c
commit 6bd50b34de
4 changed files with 29 additions and 44 deletions

View File

@ -56,10 +56,10 @@ public class BehaviorUtil {
}
mapManager.setMapInfo(mapInfo);
addRefreshInfo(needDistoryPointId, mapManager);
addRefreshInfo(needDistoryPointId, mapManager, mapManager.getCurMapId());
}
private static void addRefreshInfo(int needDistoryPointId, MapManager mapManager) throws Exception {
public static void addRefreshInfo(int needDistoryPointId, MapManager mapManager, int mapId) throws Exception {
MapPointConfig mapPointConfig = MapPointConfig.getScMapEventMap().get(needDistoryPointId);
/**
*
@ -68,7 +68,7 @@ public class BehaviorUtil {
* 3
*/
if (mapPointConfig.getRefresh() == 1 || mapPointConfig.getRefresh() == 3) {
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapManager.getCurMapId());
CrossMapCell crossMapCell = mapManager.getCrossMapInfos().get(mapId);
if (crossMapCell == null) {
crossMapCell = new CrossMapCell();
}
@ -78,7 +78,7 @@ public class BehaviorUtil {
if (mapPointConfig.getRefresh() == 3) {
crossMapCell.getPermanents().put(needDistoryPointId, -1);
}
mapManager.updateCrossMapInfos(mapManager.getCurMapId(), crossMapCell);
mapManager.updateCrossMapInfos(mapId, crossMapCell);
}
}
@ -95,7 +95,7 @@ public class BehaviorUtil {
if (cell != null) {
cell.setEventId(-1);
mapManager.addOrUpdateCell(destoryXY, cell);
addRefreshInfo(cell.getPointId(), mapManager);
addRefreshInfo(cell.getPointId(), mapManager, mapManager.getCurMapId());
}
}
@ -216,7 +216,7 @@ public class BehaviorUtil {
if (cell != null) {
cell.setEventId(-1);
mapManager.addOrUpdateCell(cell.getCellId(), cell);
addRefreshInfo(cell.getPointId(), mapManager);
addRefreshInfo(cell.getPointId(), mapManager, mapManager.getCurMapId());
}
}

View File

@ -28,23 +28,27 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior {
// 开新事件 新事件需要和任务绑定
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
if (user.getMapManager().getCurMapId() == behaviorTypeValues[1][0]) {
for (int i = 1; i < behaviorTypeValues.length; i++) {
int x = behaviorTypeValues[i][1];
int y = behaviorTypeValues[i][2];
int xy = CellUtil.xy2Pos(x, y);
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[i][3]);
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
user.getMapManager().addOrUpdateCell(xy, cellValue);
if (mission != null) {
mission.updateMissionInfos(xy, cellValue);
mission.updateMapPoints(cellValue.getPointId(), cellValue.getEventId());
CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(user.getMapManager().getCurMapId());
if (crossMapCell == null) {
crossMapCell = new CrossMapCell();
for (int j = 1; j < behaviorTypeValues.length; j++) {
if (user.getMapManager().getCurMapId() == behaviorTypeValues[j][0]) {
for (int i = 1; i < behaviorTypeValues.length; i++) {
int x = behaviorTypeValues[i][1];
int y = behaviorTypeValues[i][2];
int xy = CellUtil.xy2Pos(x, y);
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[i][3]);
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
user.getMapManager().addOrUpdateCell(xy, cellValue);
if (mission != null) {
mission.updateMissionInfos(xy, cellValue);
mission.updateMapPoints(cellValue.getPointId(), cellValue.getEventId());
CrossMapCell crossMapCell = user.getMapManager().getCrossMapInfos().get(user.getMapManager().getCurMapId());
if (crossMapCell == null) {
crossMapCell = new CrossMapCell();
}
crossMapCell.getMissionIds().add(behaviorTypeValues[0][0]);
}
crossMapCell.getMissionIds().add(behaviorTypeValues[0][0]);
}
} else {
BehaviorUtil.addRefreshInfo(behaviorTypeValues[j][3], user.getMapManager(), behaviorTypeValues[j][0]);
}
}
return true;

View File

@ -3,18 +3,11 @@ package com.ljsd.jieling.handler.map.behavior;
import com.ljsd.jieling.config.MapPointConfig;
import com.ljsd.jieling.handler.map.Cell;
import com.ljsd.jieling.handler.map.EventType;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.handler.mission.CheckMissionReturn;
import com.ljsd.jieling.handler.mission.Mission;
import com.ljsd.jieling.handler.mission.MissionLogic;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MapInfoProto;
import com.ljsd.jieling.util.CellUtil;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
public class OpenMissionBehavior extends BaseBehavior {
@Override
@ -24,16 +17,7 @@ public class OpenMissionBehavior 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);
}
BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
// 开新事件
if (user.getMapManager().getCurMapId() == behaviorTypeValues[1][0]) {
int x = behaviorTypeValues[1][1];
@ -42,6 +26,8 @@ public class OpenMissionBehavior extends BaseBehavior {
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[1][3]);
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
user.getMapManager().addOrUpdateCell(xy, cellValue);
} else {
BehaviorUtil.addRefreshInfo(behaviorTypeValues[1][3], user.getMapManager(), behaviorTypeValues[1][0]);
}
return true;
}

View File

@ -30,12 +30,7 @@ public class ThirtyBehavior extends BaseBehavior {
}
return true;
} else {
// Map<Integer, CrossMapCell> crossMapInfos = mapManager.getCrossMapInfos();
// CrossMapCell crossMapCell = crossMapInfos.get(behaviorTypeValues[0][0]);
// if (crossMapCell == null) {
// crossMapCell = new CrossMapCell();
// }
// crossMapCell.getPermanents().put()
BehaviorUtil.addRefreshInfo(behaviorTypeValues[0][3], user.getMapManager(), behaviorTypeValues[0][0]);
}
return false;
}