地图提交

back_recharge
lvxinran 2019-11-01 15:22:26 +08:00
parent 44f726aaa7
commit 21059efe4a
7 changed files with 171 additions and 116 deletions

View File

@ -681,11 +681,11 @@ public class MapLogic {
int type = SChallengeConfig.sChallengeConfigs.get(mapId).getType();
return type;
}
public static AbstractMap getAbstractMap(User user){
public static AbstractMap getAbstractMap(User user) throws Exception {
MapManager mapManager = user.getMapManager();
return MapEnum.getToAbstractMap(getMapTypeByMapId(mapManager.getCurMapId()));
}
public static AbstractMap getAbstractMap(int mapId){
public static AbstractMap getAbstractMap(int mapId) throws Exception {
return MapEnum.getToAbstractMap(getMapTypeByMapId(mapId));
}

View File

@ -54,16 +54,19 @@ import java.util.*;
* @discribe
*/
public abstract class AbstractMap implements IMap {
abstract int getType();
static final Logger LOGGER = LoggerFactory.getLogger(AbstractMap.class);
private Map<Integer, BaseBehavior> baseBehaviorMap = new HashMap<>();
int endlessSeason;
int type;
public void init(ConfigurableApplicationContext configurableApplicationContext) {
Map<String, BaseBehavior> beansOfType = configurableApplicationContext.getBeansOfType(BaseBehavior.class);
for (BaseBehavior baseBehavior : beansOfType.values()) {
baseBehaviorMap.put(baseBehavior.getBehaviorType(), baseBehavior);
}
}
int endlessSeason;
public AbstractMap(int type) {
this.type = type ;
}
@Override
public AbstractMap getInstence(int mapType) {
Map<Integer,AbstractMap> mapInstence = new HashMap<>();
@ -557,14 +560,10 @@ public abstract class AbstractMap implements IMap {
Map<Integer, SCMap> scMap =SCMap.sCMap.get(mapManager.getCurMapId());
Map<Integer, Cell> newMap = new HashMap<>();
Random random = new Random();
StoreManager storeManager = user.getStoreManager();
boolean alreadHadYunShop = StoreLogic.checkContainsStore(user, StoreType.CLOUD_STORE,true);
mapManager.checkSuddenlyBoss();
int suddenlyBoss = mapManager.getSuddenlyBoss();
boolean canFindsuddenlyBoss = System.currentTimeMillis()> (mapManager.getSuddenlyBossStartTime() + STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getIncidentalBossCd())*1000;
Map<Integer, Map<Integer, Integer>> initRandomPointMap = SEndlessMapConfig.initRandomPointMap;
Map<Integer,List<Integer>> endlessRandomPoint = new HashMap<>();
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
SCMap scMap1 = entry.getValue();
// 必出现的事件点
@ -595,66 +594,12 @@ public abstract class AbstractMap implements IMap {
if (mapPointConfig.getStyle() == EventType.suddenlyBoss && (suddenlyBoss != 0 || !canFindsuddenlyBoss) ){
continue;
}
Cell cellValue = new Cell(xy, mapPointConfig.getInitialEventId(), mapPointConfig.getId());
//如果是无尽本
if(initRandomPointMap.get(mapManager.getCurMapId())!=null){
if(initRandomPointMap.get(mapManager.getCurMapId()).get(mapPointConfig.getId())!=null){
if(endlessRandomPoint.get( mapPointConfig.getId())!=null){
endlessRandomPoint.get(mapPointConfig.getId()).add(xy);
}else{
List<Integer> points = new ArrayList<>();
points.add(xy);
endlessRandomPoint.put(mapPointConfig.getId(),points);
}
}
}else{
newMap.put(xy, cellValue);
}
newMap.put(xy, cellValue);
}
//无尽本随机点处理
if(endlessRandomPoint.size()>0){
for(Map.Entry<Integer,List<Integer>> entry:endlessRandomPoint.entrySet()){
int count = initRandomPointMap.get(mapManager.getCurMapId()).get(entry.getKey());
List<Integer> points = entry.getValue();
Collections.shuffle(points);
for(int i = 0 ; i <count;i++){
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(entry.getKey());
Cell cellValue = new Cell(points.get(i), mapPointConfig.getInitialEventId(),entry.getKey());
LOGGER.info("无尽生成{}的随机点为{},{}",entry.getKey(),CellUtil.pos2XY(points.get(i))[0],CellUtil.pos2XY(points.get(i))[1]);
newMap.put(points.get(i), cellValue);
}
initMapMission(user,newMap);
}
}
if (user.getPlayerInfoManager().getMapId() == 100) {
SGameSetting sGameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting();
int xy = CellUtil.xy2Pos(sGameSetting.getBornPosition()[0], sGameSetting.getBornPosition()[1]);
mapManager.setCurXY(xy);
}
SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapManager.getCurMapId());
Mission mission = new Mission();
mission.setMissionId(challengeMapConfig.getMissionId());
mission.setMissionStep(0);
mission.setTime(0);
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId());
int xy = CellUtil.xy2Pos(challengeMapConfig.getPosition()[0], challengeMapConfig.getPosition()[1]);
int type = sChallengeConfig.getType();
if(type==4){
if(mapManager.getEndlessMapInfo().getSeason()!=endlessSeason) {
for(Map.Entry<String,Integer> entry:mapManager.getEndlessMapInfo().getEndlessHeroInfo().entrySet()){
mapManager.updateEndlessHeroHp(entry.getKey(),10000);
}
mapManager.updateEndlessLocation(0);
}
if(mapManager.getEndlessMapInfo().getCurCell()!=0){
xy = mapManager.getEndlessMapInfo().getCurCell();
}
}
mapManager.setCurXY(xy);
mapManager.setMission(mission);
mapManager.setMapInfo(newMap);
MapLogic.getInstance().initMapMission(mapManager);
}
public void mustAppear(SCMap scMap,Map<Integer, Cell> newMap){
for (int i = 0; i < scMap.getGroups().length; i++) {
@ -666,5 +611,26 @@ public abstract class AbstractMap implements IMap {
newMap.put(xy, cellValue);
}
}
public int getXY(MapManager mapManager){
SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapManager.getCurMapId());
return CellUtil.xy2Pos(challengeMapConfig.getPosition()[0], challengeMapConfig.getPosition()[1]);
}
public void initMapMission(User user,Map<Integer, Cell> newMap) throws Exception {
MapManager mapManager = user.getMapManager();
if (user.getPlayerInfoManager().getMapId() == 100) {
SGameSetting sGameSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting();
int xy = CellUtil.xy2Pos(sGameSetting.getBornPosition()[0], sGameSetting.getBornPosition()[1]);
mapManager.setCurXY(xy);
}
SChallengeMapConfig challengeMapConfig = STableManager.getConfig(SChallengeMapConfig.class).get(mapManager.getCurMapId());
Mission mission = new Mission();
mission.setMissionId(challengeMapConfig.getMissionId());
mission.setMissionStep(0);
mission.setTime(0);
mapManager.setCurXY(getXY(mapManager));
mapManager.setMission(mission);
mapManager.setMapInfo(newMap);
MapLogic.getInstance().initMapMission(mapManager);
}
}

View File

@ -27,6 +27,10 @@ import java.util.Map;
* @discribe
*/
public class DifficultMap extends AbstractMap {
public DifficultMap(int type){
super(type);
}
@Override
public void outMap(int uid,int outType, int curXY,MapInfoProto.MapOutResponse.Builder builder) throws Exception{
super.outMap(uid,outType,curXY,builder);
@ -48,11 +52,6 @@ public class DifficultMap extends AbstractMap {
}
}
@Override
int getType() {
return 3;
}
@Override
public void enterMap(int uid, int mapId, int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
super.enterMap(uid, mapId, teamId, mapEnterResponse);
@ -70,6 +69,6 @@ public class DifficultMap extends AbstractMap {
throw new ErrorCodeException(ErrorCode.newDefineCode("no ticket"));
}
initMap(user.getMapManager(), user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,getType(),mapId);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,mapId);
}
}

View File

@ -1,25 +1,22 @@
package com.ljsd.jieling.handler.map.mapType;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.MapStaticConfig;
import com.ljsd.jieling.core.FunctionIdEnum;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.map.Cell;
import com.ljsd.jieling.handler.map.EndlessMapInfo;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.*;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.handler.mission.Mission;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.store.StoreLogic;
import com.ljsd.jieling.logic.store.StoreType;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MapInfoProto;
@ -41,9 +38,9 @@ import java.util.*;
*/
public class EndlessMap extends AbstractMap{
@Override
int getType() {
return 4;
public EndlessMap(int type){
super(type);
}
int endlessMapId = 4001;
@ -123,7 +120,7 @@ public class EndlessMap extends AbstractMap{
public void enterNewMap(User user, int mapId,int teamId, MapInfoProto.MapEnterResponse.Builder mapEnterResponse) throws Exception {
super.enterNewMap(user, mapId,teamId, mapEnterResponse);
initMap(user.getMapManager(), user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,getType(),mapId);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,mapId);
}
@Override
@ -240,4 +237,93 @@ public class EndlessMap extends AbstractMap{
}
return groupId;
}
@Override
public void initMap(MapManager mapManager, User user) throws Exception {
Map<Integer, SCMap> scMap =SCMap.sCMap.get(mapManager.getCurMapId());
Map<Integer, Cell> newMap = new HashMap<>();
Random random = new Random();
boolean alreadHadYunShop = StoreLogic.checkContainsStore(user, StoreType.CLOUD_STORE,true);
mapManager.checkSuddenlyBoss();
int suddenlyBoss = mapManager.getSuddenlyBoss();
boolean canFindsuddenlyBoss = System.currentTimeMillis()> (mapManager.getSuddenlyBossStartTime() + STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getIncidentalBossCd())*1000;
Map<Integer, Map<Integer, Integer>> initRandomPointMap = SEndlessMapConfig.initRandomPointMap;
Map<Integer,List<Integer>> endlessRandomPoint = new HashMap<>();
for (Map.Entry<Integer, SCMap> entry : scMap.entrySet()) {
SCMap scMap1 = entry.getValue();
// 必出现的事件点
if (scMap1.getIsMustAppear() == 1) {
mustAppear(scMap1,newMap);
continue;
}
// 随机出现的事件点
int randomIndex = random.nextInt(scMap1.getGroups().length);
int x = scMap1.getGroups()[randomIndex][0];
int y = scMap1.getGroups()[randomIndex][1];
int xy = CellUtil.xy2Pos(x, y);
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(scMap1.getEvent());
if (mapPointConfig == null) {
LOGGER.info("====initMap()====mapPointConfig == null======>{}", scMap1.getEvent());
continue;
}
if (!MapLogic.getInstance().mapPointCanAAppear(mapPointConfig)) {
continue;
}
if (mapPointConfig.getStyle() == EventType.businessman) {
if (alreadHadYunShop) {
continue;
}
}
if (mapPointConfig.getStyle() == EventType.suddenlyBoss && (suddenlyBoss != 0 || !canFindsuddenlyBoss) ){
continue;
}
if(initRandomPointMap.get(mapManager.getCurMapId())==null){
continue;
}
if(initRandomPointMap.get(mapManager.getCurMapId()).get(mapPointConfig.getId())!=null){
continue;
}
if(endlessRandomPoint.get( mapPointConfig.getId())!=null){
endlessRandomPoint.get(mapPointConfig.getId()).add(xy);
}else{
List<Integer> points = new ArrayList<>();
points.add(xy);
endlessRandomPoint.put(mapPointConfig.getId(),points);
}
}
//无尽本随机点处理
if(endlessRandomPoint.size()>0){
for(Map.Entry<Integer,List<Integer>> entry:endlessRandomPoint.entrySet()){
int count = initRandomPointMap.get(mapManager.getCurMapId()).get(entry.getKey());
List<Integer> points = entry.getValue();
Collections.shuffle(points);
for(int i = 0 ; i <count;i++){
MapPointConfig mapPointConfig = MapPointConfig.scMapEventMap.get(entry.getKey());
Cell cellValue = new Cell(points.get(i), mapPointConfig.getInitialEventId(),entry.getKey());
LOGGER.info("无尽生成{}的随机点为{},{}",entry.getKey(),CellUtil.pos2XY(points.get(i))[0],CellUtil.pos2XY(points.get(i))[1]);
newMap.put(points.get(i), cellValue);
}
}
}
initMapMission(user,newMap);
}
@Override
public int getXY(MapManager mapManager) {
int xy = super.getXY(mapManager);
if(mapManager.getEndlessMapInfo().getSeason()!=endlessSeason) {
for(Map.Entry<String,Integer> entry:mapManager.getEndlessMapInfo().getEndlessHeroInfo().entrySet()){
mapManager.updateEndlessHeroHp(entry.getKey(),10000);
}
mapManager.updateEndlessLocation(0);
}
if(mapManager.getEndlessMapInfo().getCurCell()!=0){
xy = mapManager.getEndlessMapInfo().getCurCell();
}
return xy;
}
}

View File

@ -1,46 +1,51 @@
package com.ljsd.jieling.handler.map.mapType;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import config.SChallengeConfig;
import java.util.HashMap;
import java.util.function.Function;
public enum MapEnum {
STORY_MAP(1, new StoryMap()),
TOWER_MAP(2, new TowerMap()),
DIFFICULTY_MAP(3, new DifficultMap()),
ENDLESS_MAP(4, new EndlessMap()),
STORY_MAP(1, StoryMap::new),
TOWER_MAP(2, TowerMap::new),
DIFFICULTY_MAP(3,DifficultMap::new),
ENDLESS_MAP(4, EndlessMap::new),
;
private int type;
private AbstractMap toAbstractMap;
private static final HashMap<Integer,MapEnum> MapEnumMap = new HashMap<>();
private Function<Integer, AbstractMap> toMapFunction;
private static final HashMap<Integer,AbstractMap> mapAbstractMap = new HashMap<>();
private static final HashMap<Integer,MapEnum> mapEnumMap = new HashMap<>();
static {
for (MapEnum map:MapEnum.values()) {
MapEnumMap.put(map.getType(),map);
mapEnumMap.put(map.getType(),map);
}
}
MapEnum(int type, AbstractMap toAbstractMap) {
MapEnum(int type, Function<Integer, AbstractMap> toMapFunction) {
this.type = type;
this.toAbstractMap = toAbstractMap;
this.toMapFunction = toMapFunction;
}
public int getType() {
return type;
}
private AbstractMap getToAbstractMap() {
return toAbstractMap;
public Function<Integer, AbstractMap> getToMapFunction() {
return toMapFunction;
}
public static AbstractMap getToAbstractMap(int type) {
return MapEnumMap.get(type).getToAbstractMap();
private static AbstractMap getAbstractMap(int type) {
if(!mapAbstractMap.containsKey(type)){
AbstractMap abstractMap= mapEnumMap.get(type).getToMapFunction().apply(type);
mapAbstractMap.put(type,abstractMap);
}
return mapAbstractMap.get(type);
}
public static AbstractMap getToAbstractMap(int type) throws Exception {
if(mapEnumMap.containsKey(type)){
return getAbstractMap(type);
}else{
throw new Exception();
}
}
}

View File

@ -20,9 +20,9 @@ import com.ljsd.jieling.util.ItemUtil;
*/
public class StoryMap extends AbstractMap{
@Override
int getType() {
return 1;
public StoryMap(int type){
super(type);
}
@Override
@ -48,7 +48,7 @@ public class StoryMap extends AbstractMap{
mapManager.updatePlayGenMaps(mapId);
}
initMap(mapManager, user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,getType(),mapId);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,mapId);
}

View File

@ -34,9 +34,8 @@ import java.util.*;
*/
public class TowerMap extends AbstractMap {
@Override
int getType() {
return 2;
public TowerMap(int type){
super(type);
}
@Override
@ -88,8 +87,8 @@ public class TowerMap extends AbstractMap {
}
user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_TIMES,1);
initTrialMap(user.getMapManager(), user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,getType(),user.getMapManager().getTower());
initMap(user.getMapManager(), user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserGameType,type,user.getMapManager().getTower());
}
@ -111,7 +110,7 @@ public class TowerMap extends AbstractMap {
}
}
}
public void initTrialMap(MapManager mapManager, User user) throws Exception {
public void initMap(MapManager mapManager, User user) throws Exception {
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
if(mapManager.getTower()>1&&mapManager.getMapIntoFlag()==0){