|
@@ -74,6 +74,7 @@ export class LevelAction extends Component {
|
|
EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_AIM,this.onAimTarget,this);
|
|
EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_AIM,this.onAimTarget,this);
|
|
EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_RESET_AIM,this.onResetAimTarget,this);
|
|
EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_RESET_AIM,this.onResetAimTarget,this);
|
|
EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_SHOOT,this.onShoot,this);
|
|
EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_SHOOT,this.onShoot,this);
|
|
|
|
+ EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_SCREENSHOT_RADAR_LOCK,this.onCameraToTarget,this);
|
|
}
|
|
}
|
|
|
|
|
|
private unRegisterEvent(){
|
|
private unRegisterEvent(){
|
|
@@ -87,6 +88,7 @@ export class LevelAction extends Component {
|
|
EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_AIM,this.onAimTarget,this);
|
|
EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_AIM,this.onAimTarget,this);
|
|
EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_RESET_AIM,this.onResetAimTarget,this);
|
|
EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_RESET_AIM,this.onResetAimTarget,this);
|
|
EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_SHOOT,this.onShoot,this);
|
|
EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_SHOOT,this.onShoot,this);
|
|
|
|
+ EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_SCREENSHOT_RADAR_LOCK,this.onCameraToTarget,this);
|
|
}
|
|
}
|
|
|
|
|
|
private onAimTarget(){
|
|
private onAimTarget(){
|
|
@@ -151,6 +153,33 @@ export class LevelAction extends Component {
|
|
.start();
|
|
.start();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //相机转向目标
|
|
|
|
+ private async onCameraToTarget(targetNode: Node){
|
|
|
|
+ const camera = this.camera.node;
|
|
|
|
+ const targetPos = targetNode.worldPosition.clone();
|
|
|
|
+
|
|
|
|
+ // 保存初始旋转状态
|
|
|
|
+ const initialRotation = this._originalRotation.clone();
|
|
|
|
+
|
|
|
|
+ // 计算目标相对于相机的方向
|
|
|
|
+ const direction = new Vec3();
|
|
|
|
+ Vec3.subtract(direction, targetPos, camera.worldPosition);
|
|
|
|
+ direction.normalize();
|
|
|
|
+
|
|
|
|
+ // 基于初始旋转状态计算新角度
|
|
|
|
+ const newRotation = new Vec3();
|
|
|
|
+ newRotation.y = initialRotation.y - direction.x * 10; // 调整系数
|
|
|
|
+ newRotation.x = initialRotation.x + direction.y * 10;
|
|
|
|
+
|
|
|
|
+ // 应用旋转限制
|
|
|
|
+ newRotation.x = Math.max(this.minXRotation, Math.min(this.maxXRotation, newRotation.x));
|
|
|
|
+ newRotation.y = Math.max(this.minYRotation, Math.min(this.maxYRotation, newRotation.y));
|
|
|
|
+
|
|
|
|
+ // 设置相机旋转
|
|
|
|
+ camera.setRotationFromEuler(newRotation);
|
|
|
|
+ await this.saveCameraState();
|
|
|
|
+ }
|
|
|
|
+
|
|
private adjustRotationLimits() {
|
|
private adjustRotationLimits() {
|
|
// 计算当前镜头距离比例 (0-1范围)
|
|
// 计算当前镜头距离比例 (0-1范围)
|
|
const distanceRatio = Math.min(1, Math.max(0, (this.camera.node.position.z - this._cameraOriginalPos.z) / -30));
|
|
const distanceRatio = Math.min(1, Math.max(0, (this.camera.node.position.z - this._cameraOriginalPos.z) / -30));
|