Ver Fonte

下雨效果添加

woso_javan há 4 meses atrás
pai
commit
43684ecc08

+ 1 - 2
assets/module_movecar/Prefabs/UI/Result/Layout_BattleResult.ts

@@ -19,6 +19,5 @@ export class Layout_BattleResult extends Component {
     loseNode: Node;
 
     @property(Node)
-    levStars: Node = null!;
-
+    rain: Node = null!;
 }

+ 186 - 154
assets/module_movecar/Prefabs/UI/Result/UI_BattleResult.prefab

@@ -30,9 +30,6 @@
     ],
     "_active": true,
     "_components": [
-      {
-        "__id__": 158
-      },
       {
         "__id__": 160
       },
@@ -41,10 +38,13 @@
       },
       {
         "__id__": 164
+      },
+      {
+        "__id__": 166
       }
     ],
     "_prefab": {
-      "__id__": 166
+      "__id__": 168
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -940,6 +940,8 @@
       "__id__": 0
     },
     "fileId": "4aMiweH71DqoeU9zhbEz2l",
+    "instance": null,
+    "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
   {
@@ -1534,17 +1536,17 @@
         "__id__": 65
       },
       {
-        "__id__": 141
+        "__id__": 143
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 155
+        "__id__": 157
       }
     ],
     "_prefab": {
-      "__id__": 157
+      "__id__": 159
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1589,19 +1591,25 @@
       },
       {
         "__id__": 72
+      },
+      {
+        "__id__": 78
+      },
+      {
+        "__id__": 84
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 136
+        "__id__": 138
       },
       {
-        "__id__": 138
+        "__id__": 140
       }
     ],
     "_prefab": {
-      "__id__": 140
+      "__id__": 142
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -1768,109 +1776,31 @@
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
-  {
-    "__type__": "cc.Node",
-    "_name": "Rain",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "_parent": {
-      "__id__": 65
-    },
-    "_children": [
-      {
-        "__id__": 73
-      },
-      {
-        "__id__": 79
-      },
-      {
-        "__id__": 85
-      },
-      {
-        "__id__": 91
-      },
-      {
-        "__id__": 97
-      },
-      {
-        "__id__": 103
-      },
-      {
-        "__id__": 109
-      },
-      {
-        "__id__": 115
-      },
-      {
-        "__id__": 121
-      },
-      {
-        "__id__": 127
-      }
-    ],
-    "_active": true,
-    "_components": [
-      {
-        "__id__": 133
-      }
-    ],
-    "_prefab": {
-      "__id__": 135
-    },
-    "_lpos": {
-      "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 294.121,
-      "z": 0
-    },
-    "_lrot": {
-      "__type__": "cc.Quat",
-      "x": 0,
-      "y": 0,
-      "z": 0,
-      "w": 1
-    },
-    "_lscale": {
-      "__type__": "cc.Vec3",
-      "x": 1,
-      "y": 1,
-      "z": 1
-    },
-    "_mobility": 0,
-    "_layer": 33554432,
-    "_euler": {
-      "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 0,
-      "z": 0
-    },
-    "_id": ""
-  },
   {
     "__type__": "cc.Node",
     "_name": "Yun",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 65
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 74
+        "__id__": 73
       },
       {
-        "__id__": 76
+        "__id__": 75
       }
     ],
     "_prefab": {
-      "__id__": 78
+      "__id__": 77
     },
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -138.144,
-      "y": 22.67,
+      "y": 316.79100000000005,
       "z": 0
     },
     "_lrot": {
@@ -1902,11 +1832,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 73
+      "__id__": 72
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 75
+      "__id__": 74
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -1930,11 +1860,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 73
+      "__id__": 72
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 77
+      "__id__": 76
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -1988,25 +1918,25 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 65
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 80
+        "__id__": 79
       },
       {
-        "__id__": 82
+        "__id__": 81
       }
     ],
     "_prefab": {
-      "__id__": 84
+      "__id__": 83
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 72.969,
-      "y": -8.501,
+      "x": 120,
+      "y": 285.62,
       "z": 0
     },
     "_lrot": {
@@ -2038,11 +1968,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 79
+      "__id__": 78
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 81
+      "__id__": 80
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -2066,11 +1996,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 79
+      "__id__": 78
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 83
+      "__id__": 82
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -2118,13 +2048,88 @@
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "Rain",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 65
+    },
+    "_children": [
+      {
+        "__id__": 85
+      },
+      {
+        "__id__": 91
+      },
+      {
+        "__id__": 97
+      },
+      {
+        "__id__": 103
+      },
+      {
+        "__id__": 109
+      },
+      {
+        "__id__": 115
+      },
+      {
+        "__id__": 121
+      },
+      {
+        "__id__": 127
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 133
+      },
+      {
+        "__id__": 135
+      }
+    ],
+    "_prefab": {
+      "__id__": 137
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
   {
     "__type__": "cc.Node",
     "_name": "YuDi-1",
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2142,7 +2147,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -257.492,
-      "y": -84.919,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -2260,7 +2265,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2278,7 +2283,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -207.006,
-      "y": -84.919,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -2396,7 +2401,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2414,7 +2419,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -159.943,
-      "y": -121.27,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -2532,7 +2537,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2550,7 +2555,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -51.27,
-      "y": -90.623,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -2668,7 +2673,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2686,7 +2691,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": -16.757,
-      "y": -113.441,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -2804,7 +2809,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2822,7 +2827,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 61.111,
-      "y": -84.918,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -2940,7 +2945,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -2958,7 +2963,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 113.879,
-      "y": -124.85,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -3076,7 +3081,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 72
+      "__id__": 84
     },
     "_children": [],
     "_active": true,
@@ -3094,7 +3099,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 164.365,
-      "y": -80.354,
+      "y": 226.698,
       "z": 0
     },
     "_lrot": {
@@ -3212,7 +3217,7 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 72
+      "__id__": 84
     },
     "_enabled": true,
     "__prefab": {
@@ -3221,7 +3226,7 @@
     "_contentSize": {
       "__type__": "cc.Size",
       "width": 600,
-      "height": 179
+      "height": 500
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -3234,6 +3239,31 @@
     "__type__": "cc.CompPrefabInfo",
     "fileId": "84VMdlm75OYJ/JGa8TjN79"
   },
+  {
+    "__type__": "5ade39TXTBLhavCAiPa8H8E",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 84
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 136
+    },
+    "speed": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": -200,
+      "z": 0
+    },
+    "resetY": 200,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "03Oy452DlJ0r/EHxua2kni"
+  },
   {
     "__type__": "cc.PrefabInfo",
     "root": {
@@ -3257,7 +3287,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 137
+      "__id__": 139
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -3285,7 +3315,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 139
+      "__id__": 141
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -3343,23 +3373,23 @@
     },
     "_children": [
       {
-        "__id__": 142
+        "__id__": 144
       }
     ],
     "_active": true,
     "_components": [
-      {
-        "__id__": 148
-      },
       {
         "__id__": 150
       },
       {
         "__id__": 152
+      },
+      {
+        "__id__": 154
       }
     ],
     "_prefab": {
-      "__id__": 154
+      "__id__": 156
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -3396,20 +3426,20 @@
     "_objFlags": 512,
     "__editorExtras__": {},
     "_parent": {
-      "__id__": 141
+      "__id__": 143
     },
     "_children": [],
     "_active": true,
     "_components": [
       {
-        "__id__": 143
+        "__id__": 145
       },
       {
-        "__id__": 145
+        "__id__": 147
       }
     ],
     "_prefab": {
-      "__id__": 147
+      "__id__": 149
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -3446,11 +3476,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 142
+      "__id__": 144
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 144
+      "__id__": 146
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -3474,11 +3504,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 142
+      "__id__": 144
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 146
+      "__id__": 148
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -3558,11 +3588,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 141
+      "__id__": 143
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 149
+      "__id__": 151
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -3586,11 +3616,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 141
+      "__id__": 143
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 151
+      "__id__": 153
     },
     "_customMaterial": null,
     "_srcBlendFactor": 2,
@@ -3631,11 +3661,11 @@
     "_objFlags": 0,
     "__editorExtras__": {},
     "node": {
-      "__id__": 141
+      "__id__": 143
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 153
+      "__id__": 155
     },
     "clickEvents": [],
     "_interactable": true,
@@ -3675,7 +3705,7 @@
     "_duration": 0.1,
     "_zoomScale": 0.8,
     "_target": {
-      "__id__": 141
+      "__id__": 143
     },
     "_id": ""
   },
@@ -3706,7 +3736,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 156
+      "__id__": 158
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -3747,7 +3777,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 159
+      "__id__": 161
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -3775,13 +3805,13 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 161
+      "__id__": 163
     },
     "btNext": {
       "__id__": 50
     },
     "btRestart": {
-      "__id__": 152
+      "__id__": 154
     },
     "light": {
       "__id__": 15
@@ -3792,7 +3822,9 @@
     "loseNode": {
       "__id__": 64
     },
-    "levStars": null,
+    "rain": {
+      "__id__": 84
+    },
     "_id": ""
   },
   {
@@ -3809,7 +3841,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 163
+      "__id__": 165
     },
     "_id": ""
   },
@@ -3827,7 +3859,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 165
+      "__id__": 167
     },
     "_id": ""
   },

+ 11 - 0
assets/module_movecar/Prefabs/UI/Result/UI_BattleResult_Impl.ts

@@ -8,6 +8,7 @@ import { GtagMgr, GtagType } from "db://assets/core_tgx/base/GtagMgr";
 import { GameEvent } from "../../../Script/Enum/GameEvent";
 import { LevelManager } from "../../../Script/Manager/LevelMgr";
 import { CarUnscrewAudioMgr } from "../../../Script/Manager/CarUnscrewAudioMgr";
+import { RainEffect } from "../../../Script/Components/RainEffect";
 
 export class UI_BattleResult_Impl extends UI_BattleResult {
     rewardBase: number = 0; //基础奖励
@@ -39,9 +40,19 @@ export class UI_BattleResult_Impl extends UI_BattleResult {
         layout.winNode.active = this.win;
         layout.loseNode.active = !this.win;
 
+        if (!this.win) {
+            this.rainEffect();
+        }
+
         this.rotationLight();
     }
 
+    //下雨效果播放
+    private rainEffect(): void {
+        let layout = this.layout as Layout_BattleResult;
+        layout.rain.getComponent(RainEffect)!.startRain();
+    }
+
     private rotationLight(): void {
         if (!this.win) return;
         const { light } = this.layout;

+ 72 - 0
assets/module_movecar/Script/Components/RainEffect.ts

@@ -0,0 +1,72 @@
+import { _decorator, Component, Node, Vec3, view, randomRangeInt, UITransform } from 'cc';
+const { ccclass, property } = _decorator;
+
+@ccclass('RainEffect')
+export class RainEffect extends Component {
+
+    @property(Vec3)
+    public speed: Vec3 = new Vec3(0, -100, 0); // 雨点下落速度
+
+    @property
+    public resetY: number = 120; // 雨点重置的Y坐标
+
+    private isRaining: boolean = false;
+    private rainDrops: Node[] = [];
+
+    start() {
+        // 获取所有雨点子节点
+        this.rainDrops = this.node.children;
+
+        // 初始化雨点位置
+        this.resetRainDrops();
+        this.startRain();
+    }
+
+    public startRain() {
+        this.isRaining = true;
+    }
+
+    public stopRain() {
+        this.isRaining = false;
+    }
+
+    public clearRain() {
+        this.stopRain();
+        this.resetRainDrops();
+    }
+
+    private resetRainDrops() {
+        const _width = this.node.getComponent(UITransform).width;
+        const _height = this.node.getComponent(UITransform).height;
+
+        // 随机初始化雨点的位置
+        for (let drop of this.rainDrops) {
+            const randomX = randomRangeInt(-_width / 2, _width / 2);
+            const randomY = randomRangeInt(0, _height / 2);
+            drop.setPosition(randomX, randomY, 0);
+        }
+    }
+
+    update(dt: number) {
+        if (!this.isRaining) return;
+
+        for (let drop of this.rainDrops) {
+            // 更新雨点位置
+            const position = drop.position;
+            position.add3f(this.speed.x * dt, this.speed.y * dt, this.speed.z * dt);
+            drop.setPosition(position);
+
+            const _width = this.node.getComponent(UITransform).width;
+            const _height = this.node.getComponent(UITransform).height;
+
+            if (drop.position.y < -_height / 2) {
+                const randomX = randomRangeInt(-_width / 2, _height / 2);
+                drop.setPosition(randomX, this.resetY, 0);
+            }
+        }
+    }
+
+    protected onDestroy(): void {
+        // this.clearRain();
+    }
+}

+ 9 - 0
assets/module_movecar/Script/Components/RainEffect.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "5ade3f53-5d30-4b85-abc2-0223daf07f04",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}