|
@@ -213,7 +213,7 @@ export class MoveService implements OnModuleInit {
|
|
|
end_break_point_id,
|
|
|
angleIndex,
|
|
|
) {
|
|
|
-
|
|
|
+ console.log('handlejoystick-angle->相机过渡angleIndex-------------------------:'+angleIndex);
|
|
|
let moveFramesRes, moveFrames;
|
|
|
let key =
|
|
|
'moveframe:app_id:' +
|
|
@@ -521,7 +521,6 @@ export class MoveService implements OnModuleInit {
|
|
|
updateUser(userId, breakPointId, lastReply) {
|
|
|
const user = this.users[userId];
|
|
|
user.breakPointId = breakPointId;
|
|
|
- console.log('handlejoystick:updateUser');
|
|
|
if (lastReply.actionResponses[0].actionType != 15) {
|
|
|
user.player.position =
|
|
|
lastReply['newUserStates'][0].playerState.player.position;
|
|
@@ -881,12 +880,13 @@ export class MoveService implements OnModuleInit {
|
|
|
const closestDis = 80; //小于这个距离就跳到邻居呼吸点
|
|
|
const distance = step * dir_action.speed_level;
|
|
|
let angle = null;
|
|
|
+ console.log('handlejoystick-angle->:dir_action.move_angle'+dir_action.move_angle)
|
|
|
if(user.camera.angle.yaw<0){
|
|
|
user.camera.angle.yaw = 360 + user.camera.angle.yaw;
|
|
|
}
|
|
|
let move_angle = dir_action.move_angle + user.camera.angle.yaw;
|
|
|
move_angle = move_angle % 360;
|
|
|
-
|
|
|
+ console.log('handlejoystick-angle->:叠加后move_angle(也是user.angle)'+move_angle)
|
|
|
//TODO 临时增加断言
|
|
|
const playerPosition: Point = { x: 0, y: 0, z: 0 };
|
|
|
playerPosition.x =
|
|
@@ -896,6 +896,9 @@ export class MoveService implements OnModuleInit {
|
|
|
user.player.position.y +
|
|
|
distance * Math.sin((move_angle / 360) * 2 * Math.PI);
|
|
|
|
|
|
+ let offsetX = playerPosition.x - user.player.position.x;
|
|
|
+ let offsetY = playerPosition.y - user.player.position.y;
|
|
|
+
|
|
|
//找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
|
let chooseBreakPointId = null;
|
|
|
const breakPoint = this.breakPointInfo[breakPointId];
|
|
@@ -925,10 +928,7 @@ export class MoveService implements OnModuleInit {
|
|
|
console.log('joystickjoystick:' + this.cameraInfos.length);
|
|
|
|
|
|
if (surroundPointIds.length == 1) {
|
|
|
- // console.log(
|
|
|
- // 'joystick校验--->' + breakPointId + '-' + surroundPointIds[0],
|
|
|
- // );
|
|
|
- console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
+ //console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
return await this.moveDirect(
|
|
|
playerPosition,
|
|
|
closestDis,
|
|
@@ -950,9 +950,25 @@ export class MoveService implements OnModuleInit {
|
|
|
playerPosition,
|
|
|
);
|
|
|
|
|
|
+ let offsetBreakPosition = {
|
|
|
+ x:breakPoint.position.x + offsetX,
|
|
|
+ y:breakPoint.position.y + offsetY
|
|
|
+ }
|
|
|
+ let closestNeighorId = null;
|
|
|
+ let neighDis = null;
|
|
|
+
|
|
|
let singleInfo = null;
|
|
|
for (let i = 0; i < surroundPointIds.length; ++i) {
|
|
|
const neighPoint = this.breakPointInfo[surroundPointIds[i]];
|
|
|
+ if(closestNeighorId == null){
|
|
|
+ neighDis = this.getDistance(offsetBreakPosition,neighPoint.position);
|
|
|
+ closestNeighorId = surroundPointIds[i];
|
|
|
+ }
|
|
|
+ else if(neighDis>this.getDistance(offsetBreakPosition,neighPoint.position)){
|
|
|
+ neighDis = this.getDistance(offsetBreakPosition,neighPoint.position);
|
|
|
+ closestNeighorId = surroundPointIds[i];
|
|
|
+ }
|
|
|
+
|
|
|
neighPoint.breakPointId = surroundPointIds[i];
|
|
|
angle = this.getAngle(
|
|
|
breakPoint.position,
|
|
@@ -974,23 +990,7 @@ export class MoveService implements OnModuleInit {
|
|
|
neighPoint.angle = angle;
|
|
|
neighPoints.push(neighPoint);
|
|
|
++count;
|
|
|
- //console.log('handlejoysticktesttest:45°的倍数');
|
|
|
- //debugger;
|
|
|
break;
|
|
|
-
|
|
|
- // console.log(
|
|
|
- // 'joystick直走--->' + breakPointId + '-' + surroundPointIds[i],
|
|
|
- // );
|
|
|
- // return await this.moveDirect(
|
|
|
- // playerPosition,
|
|
|
- // closestDis,
|
|
|
- // breakPointId,
|
|
|
- // surroundPointIds[i],
|
|
|
- // appId,
|
|
|
- // userId,
|
|
|
- // traceId,
|
|
|
- // actionType,
|
|
|
- // );
|
|
|
}
|
|
|
|
|
|
//if (angle == 0 && Math.abs(360 - move_angle) < 45) {
|
|
@@ -1025,7 +1025,7 @@ export class MoveService implements OnModuleInit {
|
|
|
// 'joystick校验--->' + breakPointId + '-' + singleInfo.breakPointId,
|
|
|
// );
|
|
|
//console.log('handlejoysticktesttest校验0角度:'+_angle+','+move_angle) //这个没办法,得换方案
|
|
|
- console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
+ //console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
return await this.moveDirect(
|
|
|
playerPosition,
|
|
|
closestDis,
|
|
@@ -1037,10 +1037,7 @@ export class MoveService implements OnModuleInit {
|
|
|
actionType,
|
|
|
);
|
|
|
} else if (count == 1) {
|
|
|
- // console.log(
|
|
|
- // 'joystick校验--->' + breakPointId + '-' + neighPoints[0].breakPointId,
|
|
|
- // );
|
|
|
- console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
+ //console.log('handlejoysticktesttest:actionRequest-笔直'+new Date().getTime());
|
|
|
return await this.moveDirect(
|
|
|
playerPosition,
|
|
|
closestDis,
|
|
@@ -1056,7 +1053,7 @@ export class MoveService implements OnModuleInit {
|
|
|
JSON.stringify(user.player.position),
|
|
|
);
|
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
|
- console.log('handlejoysticktesttest:actionRequest-停止'+new Date().getTime());
|
|
|
+ //console.log('handlejoysticktesttest:actionRequest-停止'+new Date().getTime());
|
|
|
return this.reply;
|
|
|
}
|
|
|
}
|
|
@@ -1064,25 +1061,25 @@ export class MoveService implements OnModuleInit {
|
|
|
//count == 2
|
|
|
//超出范围了
|
|
|
if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
|
- let offsetAngle1 = Math.abs(_angle - neighPoints[0].angle);
|
|
|
- if (neighPoints[0].angle == 0) {
|
|
|
- offsetAngle1 = Math.min(offsetAngle1, Math.abs(_angle - 360));
|
|
|
- }
|
|
|
-
|
|
|
- let offsetAngle2 = Math.abs(_angle - neighPoints[1].angle);
|
|
|
- if (neighPoints[1].angle == 0) {
|
|
|
- offsetAngle2 = Math.min(offsetAngle2, Math.abs(_angle - 360));
|
|
|
+ // let offsetAngle1 = Math.abs(_angle - neighPoints[0].angle);
|
|
|
+ // if (neighPoints[0].angle == 0) {
|
|
|
+ // offsetAngle1 = Math.min(offsetAngle1, Math.abs(_angle - 360));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let offsetAngle2 = Math.abs(_angle - neighPoints[1].angle);
|
|
|
+ // if (neighPoints[1].angle == 0) {
|
|
|
+ // offsetAngle2 = Math.min(offsetAngle2, Math.abs(_angle - 360));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (offsetAngle1 > offsetAngle2) {
|
|
|
+ // chooseBreakPointId = neighPoints[1].breakPointId;
|
|
|
+ // } else {
|
|
|
+ // chooseBreakPointId = neighPoints[0].breakPointId;
|
|
|
+ // }
|
|
|
+ if(closestNeighorId == null){
|
|
|
+ debugger;
|
|
|
}
|
|
|
-
|
|
|
- if (offsetAngle1 > offsetAngle2) {
|
|
|
- chooseBreakPointId = neighPoints[1].breakPointId;
|
|
|
- } else {
|
|
|
- chooseBreakPointId = neighPoints[0].breakPointId;
|
|
|
- }
|
|
|
- // console.log(
|
|
|
- // 'joystick镜头过渡--->' + breakPointId + '-' + chooseBreakPointId,
|
|
|
- // );
|
|
|
- //this.reply.moveOver = true;
|
|
|
+ chooseBreakPointId = closestNeighorId;
|
|
|
return await this.moveCamera(
|
|
|
breakPointId,
|
|
|
chooseBreakPointId,
|
|
@@ -1113,13 +1110,14 @@ export class MoveService implements OnModuleInit {
|
|
|
user.camera.position = JSON.parse(
|
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
|
);
|
|
|
+ console.log('handlejoystick-angle->:自由并过渡更新user.angle'+cameraInfo.camera_angle.yaw)
|
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
this.sendingFrameForJoystick = true;
|
|
|
} else {
|
|
|
console.log('joystick自由--->不合并');
|
|
|
}
|
|
|
- console.log('handlejoysticktesttest:actionRequest-自由'+new Date().getTime());
|
|
|
+ //console.log('handlejoysticktesttest:actionRequest-自由'+new Date().getTime());
|
|
|
return this.reply;
|
|
|
}
|
|
|
}
|
|
@@ -1187,6 +1185,7 @@ export class MoveService implements OnModuleInit {
|
|
|
user.camera.position = JSON.parse(
|
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
|
);
|
|
|
+ console.log('handlejoystick-angle->:moveDirect更新user.angle'+cameraInfo.camera_angle.yaw)
|
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
this.sendingFrameForJoystick = true;
|
|
@@ -1279,6 +1278,7 @@ export class MoveService implements OnModuleInit {
|
|
|
user.camera.position = JSON.parse(
|
|
|
JSON.stringify(cameraInfo.camera_position),
|
|
|
);
|
|
|
+ console.log('handlejoystick-angle->:刚刚过渡更新user.angle'+cameraInfo.camera_angle.yaw)
|
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
if (cameraInfo.mediaSrc) {
|
|
@@ -1287,7 +1287,7 @@ export class MoveService implements OnModuleInit {
|
|
|
}
|
|
|
this.sendingFrameForJoystick = true;
|
|
|
}
|
|
|
- console.log('handlejoysticktesttest:actionRequest-镜头过渡'+new Date().getTime());
|
|
|
+ //console.log('handlejoysticktesttest:actionRequest-镜头过渡'+new Date().getTime());
|
|
|
return this.reply;
|
|
|
}
|
|
|
}
|
|
@@ -1359,7 +1359,7 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
complementFrame(userId) {
|
|
|
if (this.cameraInfos.length > 0) {
|
|
|
- console.log('handlejoysticktesttest:complementFrame-1 继续'+userId+','+new Date().getTime())
|
|
|
+ //console.log('handlejoysticktesttest:complementFrame-1 继续'+userId+','+new Date().getTime())
|
|
|
const user = this.users[userId];
|
|
|
const cameraInfo = this.cameraInfos.shift();
|
|
|
this.reply.traceIds = [];
|
|
@@ -1398,17 +1398,17 @@ export class MoveService implements OnModuleInit {
|
|
|
return this.reply;
|
|
|
} else if (this.cameraInfos.length == 0) {
|
|
|
if (this.reply['newUserStates'][0].renderInfo.isMoving == 1) {
|
|
|
- console.log('handlejoysticktesttest:complementFrame-2 停止1'+new Date().getTime())
|
|
|
+ //console.log('handlejoysticktesttest:complementFrame-2 停止1'+new Date().getTime())
|
|
|
return this.stopJoystick(userId);
|
|
|
} else {
|
|
|
- console.log('handlejoysticktesttest:complementFrame-2 停止2'+new Date().getTime())
|
|
|
+ //console.log('handlejoysticktesttest:complementFrame-2 停止2'+new Date().getTime())
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
stopJoystick(userId) {
|
|
|
- console.log('handlejoysticktesttest:stopJoystick');
|
|
|
+ //console.log('handlejoysticktesttest:stopJoystick');
|
|
|
this.reply.traceIds = [];
|
|
|
const user = this.users[userId];
|
|
|
this.reply['newUserStates'][0].userId = userId;
|