room
parent
97241f0f5b
commit
32480ab936
|
@ -9,7 +9,7 @@ public class HeroLevelUpManager implements BaseDataManager{
|
|||
@Override
|
||||
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
|
||||
if(missionType == MissionType.HERO_LEVLE_COUNT){
|
||||
int oldLevle = (int)parm[0];
|
||||
int oldLevle = (int)parm[0]+1;
|
||||
int newLevle = (int)parm[1];
|
||||
Map<Integer, Integer> heroLevleCountMap = data.getHeroLevleCountMap();
|
||||
for(;oldLevle<=newLevle;oldLevle++){
|
||||
|
|
|
@ -24,7 +24,7 @@ public class RoomManager {
|
|||
private static final List<Integer> matchingPlayerList = new ArrayList();
|
||||
private static Object lock; //线程安全锁
|
||||
|
||||
private static int PLAYER_NUMBER_IN_ROOM = 2; //单个房间的最大数量
|
||||
private static int PLAYER_NUMBER_IN_ROOM = 3; //单个房间的最大数量
|
||||
|
||||
public static int SIMPLEST_MATCH_RULE = 0;
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class RoomManager {
|
|||
user.getRoomInfo().setMatching(false);
|
||||
user.getRoomInfo().setRoomId(roomId);
|
||||
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
||||
int curXY = CellUtil.xy2Pos(4 + i, 4 + i);
|
||||
int curXY = CellUtil.xy2Pos( i*10+1, i*10+1);
|
||||
agentInfoBuilder.setPlayerUid(user.getId())
|
||||
.setCurHp(1000)
|
||||
.setMaxHp(1000)
|
||||
|
@ -154,12 +154,16 @@ public class RoomManager {
|
|||
Map<Integer, RoomPlayerInfo> roomPlayers = room.getRoomPlayers();
|
||||
List<RoomProto.AgentInfo> agentInfoList = new ArrayList<>();
|
||||
for(RoomPlayerInfo roomPlayerInfo:roomPlayers.values()) {
|
||||
if(!roomPlayerInfo.getPath().isEmpty()){
|
||||
roomPlayerInfo.move(System.currentTimeMillis());
|
||||
}
|
||||
RoomProto.AgentInfo.Builder agentInfoBuilder = RoomProto.AgentInfo.newBuilder();
|
||||
agentInfoBuilder.setPlayerUid(roomPlayerInfo.getUid())
|
||||
.setCurHp(1000)
|
||||
.setMaxHp(1000)
|
||||
.setCamp(roomPlayerInfo.getCamp())
|
||||
.setCurXY(roomPlayerInfo.getCurPos());
|
||||
.setCurXY(roomPlayerInfo.getCurPos())
|
||||
.addAllPath(roomPlayerInfo.getPath());
|
||||
agentInfoList.add(agentInfoBuilder.build());
|
||||
}
|
||||
MessageUtil.sendRoomInfoToPerson(iSession, room.getType(), roomId, 1, cells, agentInfoList);
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package com.ljsd.jieling.logic.room;
|
||||
|
||||
import com.ljsd.jieling.protocols.RoomFightProto;
|
||||
import com.ljsd.jieling.thread.task.MinuteTask;
|
||||
import com.ljsd.jieling.util.CellUtil;
|
||||
import com.ljsd.jieling.util.MapPoint;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RoomPlayerInfo {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RoomPlayerInfo.class);
|
||||
private int uid;
|
||||
|
||||
public static final int UNREADY_STATE = 0; //还未准备
|
||||
|
@ -28,12 +32,17 @@ public class RoomPlayerInfo {
|
|||
|
||||
//用户移动到新位置, 返回下一个点的坐标,用户展示客户端的转向,及模拟移动
|
||||
public boolean move(List<Integer> path){
|
||||
long timestamp = System.currentTimeMillis();
|
||||
if(!this.path.isEmpty()){
|
||||
move(System.currentTimeMillis());
|
||||
move(timestamp);
|
||||
}
|
||||
boolean continuous = CellUtil.isContinuous(curPos, path);
|
||||
if(continuous){
|
||||
this.path = path;
|
||||
this.path.clear();
|
||||
this.path.addAll(path);
|
||||
this.path.remove(0);
|
||||
preMoveTimestamp = timestamp;
|
||||
LOGGER.info("the uid={},the preMoveTimestamp={}",uid,preMoveTimestamp);
|
||||
}
|
||||
return continuous;
|
||||
}
|
||||
|
@ -44,15 +53,18 @@ public class RoomPlayerInfo {
|
|||
if(path.size() <= 0){
|
||||
return -1;
|
||||
}
|
||||
int nextPoint = path.get(0);
|
||||
int moveDistance = (int)((timestamp - preMoveTimestamp)*speed);
|
||||
int moveDistance = (int)((timestamp - preMoveTimestamp)/speed);
|
||||
if(moveDistance < 1){
|
||||
//格子没有发生变化
|
||||
return -1;
|
||||
}
|
||||
for(int i=0; i<moveDistance && i<path.size(); i++){
|
||||
int oldXY=curPos;
|
||||
int pathSize = path.size();
|
||||
for(int i=0; i<moveDistance && i<pathSize; i++){
|
||||
curPos = path.remove(0);
|
||||
}
|
||||
LOGGER.info("the uid={},the preMoveTimestamp={},the time ={},move={},the oldXy={},the curXy={}",uid,preMoveTimestamp,timestamp,moveDistance,oldXY,curPos);
|
||||
|
||||
preMoveTimestamp = timestamp;
|
||||
return curPos;
|
||||
}
|
||||
|
@ -88,6 +100,10 @@ public class RoomPlayerInfo {
|
|||
this.camp = camp;
|
||||
}
|
||||
|
||||
public List<Integer> getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
//todo ……
|
||||
|
||||
}
|
||||
|
|
|
@ -22,12 +22,16 @@ import com.ljsd.jieling.logic.dao.PlayerManager;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.room.Room;
|
||||
import com.ljsd.jieling.logic.room.RoomManager;
|
||||
import com.ljsd.jieling.logic.room.RoomPlayerInfo;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.netty.handler.GameMessageHandler;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocol.ProtocolsAbstract;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.RoomFightProto;
|
||||
import com.ljsd.jieling.session.GameSession;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
@ -280,6 +284,18 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
User user = UserManager.getUserInMem(session.getUid());
|
||||
int roomId = user.getRoomInfo().getRoomId();
|
||||
if(roomId!=-1){
|
||||
Room room = RoomManager.getRoomById(roomId);
|
||||
if(room!=null){
|
||||
RoomPlayerInfo roomPlayerInfo = room.getRoomPlayers().get(session.getUid());
|
||||
roomPlayerInfo.move(System.currentTimeMillis());
|
||||
roomPlayerInfo.getPath().clear();
|
||||
RoomFightProto.RoomMapPointIndication build = RoomFightProto.RoomMapPointIndication.newBuilder().setEventType(10).setPlayer(session.getUid()).setTriggerXY(roomPlayerInfo.getCurPos()).build();
|
||||
RoomManager.sendRoomMapPointIndication(room.getRoomPlayers().keySet(),build,MessageTypeProto.MessageType.ROOM_MAP_POINT_INDICATION_VALUE);
|
||||
}
|
||||
}
|
||||
if(session.getOfflineType() == ErrorCode.reloginCode){
|
||||
return;
|
||||
}
|
||||
|
@ -296,7 +312,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
|
||||
try {
|
||||
OnlineUserManager.userOffline(session.getUid());
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
playerInfoManager.setOffLineTime(TimeUtils.now());
|
||||
long onlineTime = playerInfoManager.getOffLineTime() - playerInfoManager.getLoginTime();
|
||||
|
|
|
@ -36,6 +36,9 @@ public class CellUtil {
|
|||
int[] new_xy = pos2XY(i);
|
||||
System.out.println("=======> nX : "+new_xy[0]+" , nY : "+new_xy[1]);
|
||||
}
|
||||
|
||||
System.out.println(pos2XY(520)[0]);
|
||||
System.out.println(pos2XY(520)[1]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,15 +114,32 @@ public class CellUtil {
|
|||
return false ;
|
||||
}
|
||||
|
||||
public static boolean checkIsNextOrMineCell(int pos1 , int pos2){
|
||||
int[] xy1 = pos2XY(pos1);
|
||||
int[] xy2 = pos2XY(pos2);
|
||||
if(pos1 == pos2){
|
||||
return true;
|
||||
}
|
||||
if ((xy1[0]==xy2[0] && Math.abs(xy1[1]-xy2[1])==1) || (xy1[1]==xy2[1] && Math.abs(xy1[0]-xy2[0])==1)){
|
||||
return true;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean isContinuous(int lastXY, List<Integer> cells){
|
||||
boolean first = false;
|
||||
if (cells.size() > 0) {
|
||||
first = checkIsNextCell(lastXY, cells.get(0));
|
||||
first = checkIsNextOrMineCell(lastXY, cells.get(0));
|
||||
if(!first){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < cells.size() - 1; i++) {
|
||||
boolean other = checkIsNextCell(cells.get(i), cells.get(i + 1));
|
||||
if (!first && !other) {
|
||||
boolean other = checkIsNextOrMineCell(cells.get(i), cells.get(i + 1));
|
||||
if (!other) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue