woso_javan преди 3 седмици
родител
ревизия
d6fd16ea08
променени са 1 файла, в които са добавени 15 реда и са изтрити 10 реда
  1. 15 10
      assets/module_aliens/Script/LevelAction.ts

+ 15 - 10
assets/module_aliens/Script/LevelAction.ts

@@ -28,7 +28,7 @@ export class LevelAction extends Component {
     public camera: Camera = null!;
 
     private _renderTex: RenderTexture | null = null;
-    private _isZooming = false;
+
     public targetNode: Node = null!;
 
     //关卡怪物总数
@@ -50,7 +50,7 @@ export class LevelAction extends Component {
     private _initialRotation: Vec3 = new Vec3(0, 0, 0); // 初始旋转角度
     private _initialPosition: Vec3 = new Vec3();
     private _isZoomed: boolean = false; // 记录是否处于拉近状态
-
+    private _isZooming = false;
     onLoad(): void {
         this.camera.node.rotation.getEulerAngles(this._initialRotation);
         this._initialPosition = this.camera.node.position.clone();
@@ -118,21 +118,24 @@ export class LevelAction extends Component {
         EventDispatcher.instance.off(GameEvent.EVENT_CAMERA_SCREENSHOT_RADAR_LOCK, this.onCameraToTarget, this);
     }
 
-    private onAimTarget() {
+    private async onAimTarget() {
         if (this._isZoomed) return;
 
+        this._isZooming = true;
+
         // 获取相机前方方向(世界坐标)
         let magnifyRate = UserManager.instance.userModel.magnifyRate;
-        if(GlobalConfig.isDebug){
-            magnifyRate = 20;
+        if (GlobalConfig.isDebug) {
+            magnifyRate = 0.1;
         }
-        console.log('magnifyRate:', magnifyRate);
+        // console.log('magnifyRate:', magnifyRate);
         const forward = new Vec3(0, 0, -magnifyRate);
         Vec3.transformQuat(forward, forward, this.camera.node.rotation);
         // 朝前方移动(拉近)
         Vec3.scaleAndAdd(this.camera.node.position, this._initialPosition, forward, this.zoomDistance);
         this.camera.node.setPosition(this.camera.node.position);
         this._isZoomed = true;
+        this._isZooming = false;
     }
 
     private onResetAimTarget() {
@@ -171,14 +174,14 @@ export class LevelAction extends Component {
         if (hasHit) {
             const results = PhysicsSystem.instance.raycastResults;
             let hitEnemy = false;
-            
+
             for (let i = 0; i < results.length; i++) {
                 const item = results[i];
                 const collider = item.collider.node;
 
-                const killMonster = (isHead:boolean) => {
+                const killMonster = (isHead: boolean) => {
                     if (hitEnemy) return; // 已经击中敌人则不再处理
-                    
+
                     LevelManager.instance.levelModel.hitCount++;
                     const levelNode = AliensGlobalInstance.instance.levels.children[0];
                     const remain = levelNode.getChildByName('Ets')!.children.length;
@@ -275,10 +278,12 @@ export class LevelAction extends Component {
     }
 
     private frameTouch(event: EventTouch) {
-       this._onTouchMove(event);
+        this._onTouchMove(event);
     }
 
     private async _onTouchMove(event: EventTouch) {
+        if(this._isZooming) return;
+
         const delta = event.getDelta();
         // console.log('_onTouchMove delta:', delta);
         // 获取当前相机旋转