woso_javan преди 2 месеца
родител
ревизия
e2034eb0a4

+ 45 - 2
assets/module_storm_sunder/Script/Component/PropComponent.ts

@@ -1,6 +1,7 @@
-import { _decorator, CCBoolean, CCFloat, Collider, Component, ITriggerEvent, Node, PhysicsSystem, tween, Tween, Vec3 } from 'cc';
+import { _decorator, CCBoolean, CCFloat, Collider, Component, isValid, ITriggerEvent, Node, PhysicsSystem, tween, Tween, Vec3 } from 'cc';
 import { Effect2DUIMgr } from '../Manager/Effect2DUIMgr';
 import { StormSunderAudioMgr } from '../Manager/StormSunderAudioMgr';
+import { GameMgr, GameStatus } from '../Manager/GameMgr';
 const { ccclass, property } = _decorator;
 
 export enum PropStatus {
@@ -27,6 +28,8 @@ export class PropComponent extends Component {
     @property({ type: CCBoolean, displayName: "是否可移动" })
     isMove: boolean = false;
 
+    private isShaking: boolean = false;
+
     currentHp: number = 0;
     status: PropStatus = PropStatus.LIFE;
     speed: number = 50;
@@ -40,6 +43,7 @@ export class PropComponent extends Component {
 
         this.tigger = this.node.getComponent(Collider)!;
         this.tigger.on('onTriggerEnter', this.onTriggerEnter, this);
+        this.tigger.on('onTriggerStay', this.onTriggerStay, this);
         this.tigger.on('onTriggerExit', this.onTriggerExit, this);
     }
 
@@ -79,11 +83,50 @@ export class PropComponent extends Component {
             .start();
     }
 
+    private shake() {
+        if (this.isShaking || this.isMove) return;
+        this.isShaking = true;
+
+        const originalPosition = this.node.position.clone();
+        const shakeStrength = 0.2;
+        const shakeDuration = 0.05;
+
+        tween(this.node)
+            .to(shakeDuration, { position: new Vec3(originalPosition.x + shakeStrength, originalPosition.y, originalPosition.z) })
+            .to(shakeDuration, { position: new Vec3(originalPosition.x - shakeStrength, originalPosition.y, originalPosition.z) })
+            .to(shakeDuration, { position: new Vec3(originalPosition.x, originalPosition.y + shakeStrength, originalPosition.z) })
+            .to(shakeDuration, { position: new Vec3(originalPosition.x, originalPosition.y - shakeStrength, originalPosition.z) })
+            .to(shakeDuration, { position: originalPosition })
+            .call(() => {
+                this.isShaking = false;
+            })
+            .start();
+    }
+
     protected onTriggerEnter(event: ITriggerEvent): void {
     }
 
+    protected onTriggerStay(event: ITriggerEvent): void {
+        if (GameMgr.inst.getGameStatus() != GameStatus.Playing) return;
+        //建筑抖动效果
+        if (isValid(this.node)) {
+            const otherCollider = event.otherCollider.node;
+            if (otherCollider.name == "RigibodyStorm") {
+                // this.shake();
+            }
+        }
+    }
+
     onTriggerExit(event: ITriggerEvent): void {
         Effect2DUIMgr.Instance.removeBlood(this.node);
+
+        // if (!this.isMove) {
+        //     const otherCollider = event.otherCollider.node;
+        //     if (otherCollider.name == "RigibodyStorm") {
+        //         Tween.stopAllByTarget(this.node);
+        //         this.isShaking = false;
+        //     }
+        // }
     }
 
     update(deltaTime: number) {
@@ -91,7 +134,7 @@ export class PropComponent extends Component {
     }
 
     protected onDestroy(): void {
-
+        Tween.stopAllByTarget(this.node);
     }
 }
 

+ 0 - 1
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -8,7 +8,6 @@ import { PropComponent, PropStatus } from './PropComponent';
 import { PlayerInfo } from './PlayerInfoComponent';
 import { Effect2DUIMgr } from '../Manager/Effect2DUIMgr';
 import { AttributeBonusMgr } from '../Manager/AttributeBonusMgr';
-import { TornadoAIComponent } from './TornadoAIComponent';
 import { EasyControllerEvent } from 'db://assets/core_tgx/easy_controller/EasyController';
 const { ccclass, property } = _decorator;
 

+ 2 - 2
assets/module_storm_sunder/Script/Manager/PropMgr.ts

@@ -39,7 +39,7 @@ export class PropMgr {
 
     public tornadoNode: Node = null;//玩家节点
 
-    public spawnRadius: number = 20; // 生成范围半径
+    public spawnRadius: number = 10; // 生成范围半径
     public raycastDistance: number = 1;//射线检测距离
     curMovePropsCount: number = 0; //当前移动道具数量
     lastCreateTime: number = 0;//上次生成时间
@@ -104,7 +104,7 @@ export class PropMgr {
         if (!this.tornadoNode || !this.tornadoNode.worldPosition) return;
 
         let playerPos = this.tornadoNode.worldPosition;
-        let angle = Math.random() * Math.PI * 2; // 随机角度
+        let angle = Math.random() * Math.PI * 180; // 随机角度
         let distance = Math.random() * this.spawnRadius + this.spawnRadius;
 
         // 创建射线检测前方障碍物

+ 1 - 1
assets/module_storm_sunder/Script/Manager/TimerMgr.ts

@@ -78,6 +78,6 @@ export class TimerMgr {
 
         const mapConfig = MapMgr.Instance.getMapConfig(1);
         this.countDownTime = mapConfig.time;
-        this.countDownTime = 10; //测试
+        this.countDownTime = 100; //测试
     }
 }

+ 1 - 1
assets/module_storm_sunder/Script/Model/UserModel.ts

@@ -6,7 +6,7 @@ import { AttributeBonusMgr, BonusType } from "../Manager/AttributeBonusMgr";
  * @param expPower 经验加成
 */
 export class UserModel {
-    money: number = 1000;
+    money: number = 0;
     nickName: string = 'player'; //昵称
     // userTornadoLevel: number = 1; //玩家风暴等级