|
@@ -882,17 +882,17 @@ 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,
|
|
|
- );
|
|
|
+ // 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,
|
|
|
- );
|
|
|
+ // console.log(
|
|
|
+ // 'handlejoystick-angle->:叠加后move_angle(也是user.angle)' + move_angle,
|
|
|
+ // );
|
|
|
//TODO 临时增加断言
|
|
|
const playerPosition: Point = { x: 0, y: 0, z: 0 };
|
|
|
playerPosition.x =
|
|
@@ -902,9 +902,9 @@ export class MoveService implements OnModuleInit {
|
|
|
user.player.position.y +
|
|
|
distance * Math.sin((move_angle / 360) * 2 * Math.PI);
|
|
|
|
|
|
- const offsetX = playerPosition.x - user.player.position.x;
|
|
|
- const offsetY = playerPosition.y - user.player.position.y;
|
|
|
-
|
|
|
+ // const offsetX = playerPosition.x - user.player.position.x;
|
|
|
+ // const offsetY = playerPosition.y - user.player.position.y;
|
|
|
+ console.log('handlejoysticktesttest:actionRequest-playerPosition'+JSON.stringify(playerPosition));
|
|
|
//找到邻居点,判断user.player.position与邻居点的距离,如果距离小于closestDis,就要更新camera的position
|
|
|
let chooseBreakPointId = null;
|
|
|
const breakPoint = this.breakPointInfo[breakPointId];
|
|
@@ -956,10 +956,10 @@ export class MoveService implements OnModuleInit {
|
|
|
playerPosition,
|
|
|
);
|
|
|
|
|
|
- const offsetBreakPosition = {
|
|
|
- x: breakPoint.position.x + offsetX,
|
|
|
- y: breakPoint.position.y + offsetY,
|
|
|
- };
|
|
|
+ // const offsetBreakPosition = {
|
|
|
+ // x: breakPoint.position.x + offsetX,
|
|
|
+ // y: breakPoint.position.y + offsetY,
|
|
|
+ // };
|
|
|
let closestNeighorId = null;
|
|
|
let neighDis = null;
|
|
|
|
|
@@ -967,12 +967,12 @@ export class MoveService implements OnModuleInit {
|
|
|
for (let i = 0; i < surroundPointIds.length; ++i) {
|
|
|
const neighPoint = this.breakPointInfo[surroundPointIds[i]];
|
|
|
if (closestNeighorId == null) {
|
|
|
- neighDis = this.getDistance(offsetBreakPosition, neighPoint.position);
|
|
|
+ neighDis = this.getDistance(playerPosition, neighPoint.position);
|
|
|
closestNeighorId = surroundPointIds[i];
|
|
|
} else if (
|
|
|
- neighDis > this.getDistance(offsetBreakPosition, neighPoint.position)
|
|
|
+ neighDis > this.getDistance(playerPosition, neighPoint.position)
|
|
|
) {
|
|
|
- neighDis = this.getDistance(offsetBreakPosition, neighPoint.position);
|
|
|
+ neighDis = this.getDistance(playerPosition, neighPoint.position);
|
|
|
closestNeighorId = surroundPointIds[i];
|
|
|
}
|
|
|
|
|
@@ -1066,6 +1066,7 @@ export class MoveService implements OnModuleInit {
|
|
|
|
|
|
//count == 2
|
|
|
//超出范围了
|
|
|
+ console.log('handlejoysticktesttest:距离:'+JSON.stringify(playerPosition)+'->'+JSON.stringify(breakPoint.position)+':'+this.getDistance(playerPosition, breakPoint.position));
|
|
|
if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
|
|
|
// let offsetAngle1 = Math.abs(_angle - neighPoints[0].angle);
|
|
|
// if (neighPoints[0].angle == 0) {
|
|
@@ -1095,7 +1096,6 @@ export class MoveService implements OnModuleInit {
|
|
|
actionType,
|
|
|
);
|
|
|
} else {
|
|
|
- user.player.position = JSON.parse(JSON.stringify(playerPosition));
|
|
|
this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
JSON.stringify(user.player.position),
|
|
|
);
|
|
@@ -1116,17 +1116,18 @@ 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,
|
|
|
- );
|
|
|
+ // 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('joystick自由--->不合并');
|
|
|
}
|
|
|
//console.log('handlejoysticktesttest:actionRequest-自由'+new Date().getTime());
|
|
|
+ console.log('handlejoysticktesttest:自由:'+this.reply.mediaSrc+'->'+JSON.stringify(user.player.position));
|
|
|
return this.reply;
|
|
|
}
|
|
|
} catch (error) {
|
|
@@ -1214,10 +1215,10 @@ export class MoveService implements OnModuleInit {
|
|
|
actionType,
|
|
|
) {
|
|
|
const user = this.users[userId];
|
|
|
+ this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
+ JSON.stringify(user.player.position),
|
|
|
+ );
|
|
|
if (chooseBreakPointId == null) {
|
|
|
- this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
- JSON.stringify(user.player.position),
|
|
|
- );
|
|
|
this.reply.actionResponses[0].actionType = actionType;
|
|
|
return this.reply;
|
|
|
}
|
|
@@ -1225,9 +1226,6 @@ export class MoveService implements OnModuleInit {
|
|
|
//相机纠正加过渡
|
|
|
else {
|
|
|
if (chooseBreakPointId == user.breakPointId) {
|
|
|
- this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
|
|
|
- JSON.stringify(user.player.position),
|
|
|
- );
|
|
|
return this.reply;
|
|
|
}
|
|
|
|
|
@@ -1289,10 +1287,10 @@ 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,
|
|
|
- );
|
|
|
+ // console.log(
|
|
|
+ // 'handlejoystick-angle->:刚刚过渡更新user.angle' +
|
|
|
+ // cameraInfo.camera_angle.yaw,
|
|
|
+ // );
|
|
|
user.camera.angle.yaw = cameraInfo.camera_angle.yaw;
|
|
|
|
|
|
if (cameraInfo.mediaSrc) {
|
|
@@ -1302,6 +1300,7 @@ export class MoveService implements OnModuleInit {
|
|
|
this.sendingFrameForJoystick = true;
|
|
|
}
|
|
|
//console.log('handlejoysticktesttest:actionRequest-镜头过渡'+new Date().getTime());
|
|
|
+ console.log('handlejoysticktesttest:actionRequest-镜头过渡:从'+breakPointId+'到'+chooseBreakPointId+','+JSON.stringify(user.player.position));
|
|
|
return this.reply;
|
|
|
}
|
|
|
}
|