地图修改
parent
6c70934842
commit
8d9b8e1ff8
|
@ -53,6 +53,7 @@ public class EventType {
|
|||
* 行为参数:任务id#地图id#坐标(不输入地图id和坐标而输入0代表回主城)
|
||||
* 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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue