地图行为类型
parent
9cdc8ff54c
commit
b06828e290
|
|
@ -478,13 +478,17 @@ public class MapLogic {
|
|||
MessageUtil.sendErrorResponse(session,0, messageType.getNumber(), "");
|
||||
return;
|
||||
}
|
||||
resetMapInfo(mapManager);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
}
|
||||
|
||||
public void resetMapInfo(MapManager mapManager) throws Exception {
|
||||
mapManager.setMapInfo(new HashMap<>());
|
||||
mapManager.setHeroes(new HashSet<>());
|
||||
mapManager.setTypeEight(new HashMap<>());
|
||||
mapManager.setWalkCells(new HashSet<>());
|
||||
mapManager.setCurXY(0);
|
||||
mapManager.setCurMapId(0);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
}
|
||||
|
||||
//在地图吃东西
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ public class BehaviorUtil {
|
|||
* @param user
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void distoryPoint(User user, int[][] behaviorTypeValues) throws Exception {
|
||||
public static void distoryPoint(User user, int needDistoryPointId) throws Exception {
|
||||
Map<Integer, Cell> mapInfo = user.getMapManager().getMapInfo();
|
||||
Set<Integer> needDelete = new HashSet<>();
|
||||
for (Map.Entry<Integer, Cell> entry : mapInfo.entrySet()) {
|
||||
if (entry.getValue().getPointId() == behaviorTypeValues[0][0]) {
|
||||
if (entry.getValue().getPointId() == needDistoryPointId) {
|
||||
needDelete.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
|
@ -86,9 +86,9 @@ public class BehaviorUtil {
|
|||
/**
|
||||
* 更新任务
|
||||
*/
|
||||
public static boolean updateMission(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception{
|
||||
public static boolean updateMission(User user, int missionId, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception{
|
||||
Map<Integer, Mission> doingMissions = user.getMissionManager().getDoingMissions();
|
||||
Mission mission = doingMissions.get(behaviorTypeValues[0][0]);
|
||||
Mission mission = doingMissions.get(missionId);
|
||||
if (mission == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class DestroyPointAndBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues);
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][1]);
|
||||
// TODO 监视地图
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public class DestroyPointBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues);
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class FightAndDestroyPointBehavior extends BaseBehavior {
|
|||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.getFightInfo(user, behaviorTypeValues, eventUpdateResponse);
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues);
|
||||
return false;
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][1]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ public class FinishMissionBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
return BehaviorUtil.updateMission(user, behaviorTypeValues, eventUpdateResponse);
|
||||
return BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ public class JumpBehavior extends BaseBehavior {
|
|||
user.getMapManager().setCurMapId(behaviorTypeValues[0][0]);
|
||||
MapLogic.getInstance().initMap(user.getMapManager(), user);
|
||||
return true;
|
||||
} else {
|
||||
MapLogic.getInstance().resetMapInfo(user.getMapManager());
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,21 @@ public class MonitorMissionAndDestroyPointBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.updateMission(user, behaviorTypeValues, eventUpdateResponse);
|
||||
// 1#101011|101#13#18#101012|101#12#13#101009
|
||||
BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
// 销毁事件点
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues);
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][1]);
|
||||
// 开新事件
|
||||
if (user.getMapManager().getCurMapId() == behaviorTypeValues[0][1]) {
|
||||
int x = behaviorTypeValues[1][0];
|
||||
int y = behaviorTypeValues[1][1];
|
||||
int xy = CellUtil.xy2Pos(x, y);
|
||||
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(behaviorTypeValues[1][2]);
|
||||
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
|
||||
user.getMapManager().addOrUpdateCell(xy, cellValue);
|
||||
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);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class MonitorMissionAndMoveBehavior extends BaseBehavior {
|
|||
|
||||
@Override
|
||||
public boolean process(User user, int[][] behaviorTypeValues, MapInfoProto.EventUpdateResponse.Builder eventUpdateResponse) throws Exception {
|
||||
BehaviorUtil.updateMission(user, behaviorTypeValues, eventUpdateResponse);
|
||||
BehaviorUtil.updateMission(user, behaviorTypeValues[0][0], eventUpdateResponse);
|
||||
// 0的时候回城
|
||||
if (behaviorTypeValues[0][1] == 0) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
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 com.ljsd.jieling.util.ItemUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class UseItemAndDestroyBehavior extends BaseBehavior {
|
||||
@Override
|
||||
|
|
@ -22,7 +19,7 @@ public class UseItemAndDestroyBehavior extends BaseBehavior {
|
|||
if (!isEnough) {
|
||||
return isEnough;
|
||||
}
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues);
|
||||
BehaviorUtil.distoryPoint(user, behaviorTypeValues[0][2]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue