Browse Source

血条以及Toast优化

181404010226 3 months ago
parent
commit
cab8814591

+ 1 - 1
assets/Scenes/GameLevel.scene

@@ -32503,7 +32503,7 @@
       "a": 255
     },
     "_spriteFrame": {
-      "__uuid__": "72524b1c-42dd-4b55-a85b-caf16d212d0c@f9941",
+      "__uuid__": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970@f9941",
       "__expectedType__": "cc.SpriteFrame"
     },
     "_type": 0,

+ 0 - 478
assets/assets/Prefabs/Toast.prefab

@@ -1,478 +0,0 @@
-[
-  {
-    "__type__": "cc.Prefab",
-    "_name": "Toast",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "_native": "",
-    "data": {
-      "__id__": 1
-    },
-    "optimizationPolicy": 0,
-    "persistent": false
-  },
-  {
-    "__type__": "cc.Node",
-    "_name": "Toast",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "_parent": null,
-    "_children": [
-      {
-        "__id__": 2
-      },
-      {
-        "__id__": 10
-      }
-    ],
-    "_active": true,
-    "_components": [
-      {
-        "__id__": 18
-      }
-    ],
-    "_prefab": {
-      "__id__": 20
-    },
-    "_lpos": {
-      "__type__": "cc.Vec3",
-      "x": -310,
-      "y": 617,
-      "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": 1073741824,
-    "_euler": {
-      "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 0,
-      "z": 0
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.Node",
-    "_name": "bg",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "_parent": {
-      "__id__": 1
-    },
-    "_children": [],
-    "_active": true,
-    "_components": [
-      {
-        "__id__": 3
-      },
-      {
-        "__id__": 5
-      },
-      {
-        "__id__": 7
-      }
-    ],
-    "_prefab": {
-      "__id__": 9
-    },
-    "_lpos": {
-      "__type__": "cc.Vec3",
-      "x": 310,
-      "y": -564.818,
-      "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": 1073741824,
-    "_euler": {
-      "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 0,
-      "z": 0
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.UITransform",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 2
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 4
-    },
-    "_contentSize": {
-      "__type__": "cc.Size",
-      "width": 720,
-      "height": 129
-    },
-    "_anchorPoint": {
-      "__type__": "cc.Vec2",
-      "x": 0.5,
-      "y": 0.5
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "d9vb2cDEhDe7uLwcofFqhG"
-  },
-  {
-    "__type__": "cc.Sprite",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 2
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 6
-    },
-    "_customMaterial": null,
-    "_srcBlendFactor": 2,
-    "_dstBlendFactor": 4,
-    "_color": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_spriteFrame": {
-      "__uuid__": "72524b1c-42dd-4b55-a85b-caf16d212d0c@f9941",
-      "__expectedType__": "cc.SpriteFrame"
-    },
-    "_type": 0,
-    "_fillType": 0,
-    "_sizeMode": 0,
-    "_fillCenter": {
-      "__type__": "cc.Vec2",
-      "x": 0,
-      "y": 0
-    },
-    "_fillStart": 0,
-    "_fillRange": 0,
-    "_isTrimmedMode": true,
-    "_useGrayscale": false,
-    "_atlas": null,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "eaSdq8JURFbrYeDlBRtq86"
-  },
-  {
-    "__type__": "cc.Widget",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 2
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 8
-    },
-    "_alignFlags": 9,
-    "_target": null,
-    "_left": 0,
-    "_right": 0,
-    "_top": 550.318,
-    "_bottom": 0,
-    "_horizontalCenter": 0,
-    "_verticalCenter": 0,
-    "_isAbsLeft": true,
-    "_isAbsRight": true,
-    "_isAbsTop": true,
-    "_isAbsBottom": true,
-    "_isAbsHorizontalCenter": true,
-    "_isAbsVerticalCenter": true,
-    "_originalWidth": 0,
-    "_originalHeight": 0,
-    "_alignMode": 2,
-    "_lockFlags": 0,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "2bRiERCQBD8ZNNycbbMaaP"
-  },
-  {
-    "__type__": "cc.PrefabInfo",
-    "root": {
-      "__id__": 1
-    },
-    "asset": {
-      "__id__": 0
-    },
-    "fileId": "ceWpIWJRVFypnqfwgXhc+X",
-    "instance": null,
-    "targetOverrides": null,
-    "nestedPrefabInstanceRoots": null
-  },
-  {
-    "__type__": "cc.Node",
-    "_name": "label",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "_parent": {
-      "__id__": 1
-    },
-    "_children": [],
-    "_active": true,
-    "_components": [
-      {
-        "__id__": 11
-      },
-      {
-        "__id__": 13
-      },
-      {
-        "__id__": 15
-      }
-    ],
-    "_prefab": {
-      "__id__": 17
-    },
-    "_lpos": {
-      "__type__": "cc.Vec3",
-      "x": 323.635,
-      "y": -555.572,
-      "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": 1073741824,
-    "_euler": {
-      "__type__": "cc.Vec3",
-      "x": 0,
-      "y": 0,
-      "z": 0
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.UITransform",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 10
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 12
-    },
-    "_contentSize": {
-      "__type__": "cc.Size",
-      "width": 264.6278280709945,
-      "height": 54.4
-    },
-    "_anchorPoint": {
-      "__type__": "cc.Vec2",
-      "x": 0.5,
-      "y": 0.5
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "729MbBaOBItLy50H9u7Ree"
-  },
-  {
-    "__type__": "cc.Label",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 10
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 14
-    },
-    "_customMaterial": null,
-    "_srcBlendFactor": 2,
-    "_dstBlendFactor": 4,
-    "_color": {
-      "__type__": "cc.Color",
-      "r": 255,
-      "g": 255,
-      "b": 255,
-      "a": 255
-    },
-    "_string": "金币不足!",
-    "_horizontalAlign": 1,
-    "_verticalAlign": 1,
-    "_actualFontSize": 50,
-    "_fontSize": 50,
-    "_fontFamily": "Arial",
-    "_lineHeight": 40,
-    "_overflow": 0,
-    "_enableWrapText": true,
-    "_font": null,
-    "_isSystemFontUsed": true,
-    "_spacingX": 0,
-    "_isItalic": true,
-    "_isBold": false,
-    "_isUnderline": false,
-    "_underlineHeight": 2,
-    "_cacheMode": 0,
-    "_enableOutline": true,
-    "_outlineColor": {
-      "__type__": "cc.Color",
-      "r": 0,
-      "g": 0,
-      "b": 0,
-      "a": 255
-    },
-    "_outlineWidth": 2,
-    "_enableShadow": false,
-    "_shadowColor": {
-      "__type__": "cc.Color",
-      "r": 0,
-      "g": 0,
-      "b": 0,
-      "a": 255
-    },
-    "_shadowOffset": {
-      "__type__": "cc.Vec2",
-      "x": 2,
-      "y": 2
-    },
-    "_shadowBlur": 2,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "6egMeJy8pLgqVcPJtn5JzQ"
-  },
-  {
-    "__type__": "cc.Widget",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 10
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 16
-    },
-    "_alignFlags": 18,
-    "_target": null,
-    "_left": 0,
-    "_right": 0,
-    "_top": 0,
-    "_bottom": 0,
-    "_horizontalCenter": 323.635,
-    "_verticalCenter": -555.572,
-    "_isAbsLeft": true,
-    "_isAbsRight": true,
-    "_isAbsTop": true,
-    "_isAbsBottom": true,
-    "_isAbsHorizontalCenter": true,
-    "_isAbsVerticalCenter": true,
-    "_originalWidth": 0,
-    "_originalHeight": 0,
-    "_alignMode": 2,
-    "_lockFlags": 0,
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "7f0N/IhqJG2IwneTE/3PIF"
-  },
-  {
-    "__type__": "cc.PrefabInfo",
-    "root": {
-      "__id__": 1
-    },
-    "asset": {
-      "__id__": 0
-    },
-    "fileId": "5dIalXnjxD16yd+0b5ZKPn",
-    "instance": null,
-    "targetOverrides": null,
-    "nestedPrefabInstanceRoots": null
-  },
-  {
-    "__type__": "cc.UITransform",
-    "_name": "",
-    "_objFlags": 0,
-    "__editorExtras__": {},
-    "node": {
-      "__id__": 1
-    },
-    "_enabled": true,
-    "__prefab": {
-      "__id__": 19
-    },
-    "_contentSize": {
-      "__type__": "cc.Size",
-      "width": 100,
-      "height": 100
-    },
-    "_anchorPoint": {
-      "__type__": "cc.Vec2",
-      "x": 0.5,
-      "y": 0.5
-    },
-    "_id": ""
-  },
-  {
-    "__type__": "cc.CompPrefabInfo",
-    "fileId": "c20Xh+GTtI347zkf8qQxrM"
-  },
-  {
-    "__type__": "cc.PrefabInfo",
-    "root": {
-      "__id__": 1
-    },
-    "asset": {
-      "__id__": 0
-    },
-    "fileId": "c9H59Pt9hMU7hpGfgYkt8d",
-    "targetOverrides": null
-  }
-]

+ 0 - 13
assets/assets/Prefabs/Toast.prefab.meta

@@ -1,13 +0,0 @@
-{
-  "ver": "1.1.50",
-  "importer": "prefab",
-  "imported": true,
-  "uuid": "48da814f-5847-4b90-8045-7c58cec88258",
-  "files": [
-    ".json"
-  ],
-  "subMetas": {},
-  "userData": {
-    "syncNodeName": "Toast"
-  }
-}

+ 9 - 0
assets/resources/Font.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.2.0",
+  "importer": "directory",
+  "imported": true,
+  "uuid": "77cb251b-610b-4dc7-b0db-629fdc36e500",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

BIN
assets/resources/Font/0011.png


+ 134 - 0
assets/resources/Font/0011.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.27",
+  "importer": "image",
+  "imported": true,
+  "uuid": "ef9282e8-2773-4edb-9dac-cd37adf523c5",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "ef9282e8-2773-4edb-9dac-cd37adf523c5@6c48a",
+      "displayName": "0011",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "ef9282e8-2773-4edb-9dac-cd37adf523c5",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "ef9282e8-2773-4edb-9dac-cd37adf523c5@f9941",
+      "displayName": "0011",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 290,
+        "height": 33,
+        "rawWidth": 290,
+        "rawHeight": 33,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -145,
+            -16.5,
+            0,
+            145,
+            -16.5,
+            0,
+            -145,
+            16.5,
+            0,
+            145,
+            16.5,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            33,
+            290,
+            33,
+            0,
+            0,
+            290,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -145,
+            -16.5,
+            0
+          ],
+          "maxPos": [
+            145,
+            16.5,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "ef9282e8-2773-4edb-9dac-cd37adf523c5@6c48a",
+        "atlasUuid": "",
+        "trimType": "auto"
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "ef9282e8-2773-4edb-9dac-cd37adf523c5@6c48a"
+  }
+}

+ 0 - 0
assets/resources/Font/label-atlas.labelatlas


+ 135 - 0
assets/resources/Font/label-atlas.labelatlas.meta

@@ -0,0 +1,135 @@
+{
+  "ver": "1.0.1",
+  "importer": "label-atlas",
+  "imported": true,
+  "uuid": "f5482737-839c-4813-9511-f36bf1223968",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {
+    "itemWidth": 29,
+    "itemHeight": 33,
+    "fontSize": 29.04,
+    "startChar": "0",
+    "spriteFrameUuid": "ef9282e8-2773-4edb-9dac-cd37adf523c5@f9941",
+    "_fntConfig": {
+      "commonHeight": 33,
+      "fontSize": 29,
+      "atlasName": 11,
+      "fontDefDictionary": {
+        "48": {
+          "rect": {
+            "x": 0,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "49": {
+          "rect": {
+            "x": 29,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "50": {
+          "rect": {
+            "x": 58,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "51": {
+          "rect": {
+            "x": 87,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "52": {
+          "rect": {
+            "x": 116,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "53": {
+          "rect": {
+            "x": 145,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "54": {
+          "rect": {
+            "x": 174,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "55": {
+          "rect": {
+            "x": 203,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "56": {
+          "rect": {
+            "x": 232,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        },
+        "57": {
+          "rect": {
+            "x": 261,
+            "y": 0,
+            "width": 29,
+            "height": 33
+          },
+          "xOffset": 0,
+          "yOffset": 0,
+          "xAdvance": 29
+        }
+      },
+      "kerningDict": {}
+    }
+  }
+}

BIN
assets/resources/images/UI/主界面/dtfff.png


+ 134 - 0
assets/resources/images/UI/主界面/dtfff.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.27",
+  "importer": "image",
+  "imported": true,
+  "uuid": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970@6c48a",
+      "displayName": "dtfff",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970",
+        "isUuid": true,
+        "visible": false,
+        "minfilter": "linear",
+        "magfilter": "linear",
+        "mipfilter": "none",
+        "anisotropy": 0
+      },
+      "ver": "1.0.22",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    },
+    "f9941": {
+      "importer": "sprite-frame",
+      "uuid": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970@f9941",
+      "displayName": "dtfff",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": 0,
+        "offsetY": 0,
+        "trimX": 0,
+        "trimY": 0,
+        "width": 720,
+        "height": 120,
+        "rawWidth": 720,
+        "rawHeight": 120,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -360,
+            -60,
+            0,
+            360,
+            -60,
+            0,
+            -360,
+            60,
+            0,
+            360,
+            60,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            0,
+            120,
+            720,
+            120,
+            0,
+            0,
+            720,
+            0
+          ],
+          "nuv": [
+            0,
+            0,
+            1,
+            0,
+            0,
+            1,
+            1,
+            1
+          ],
+          "minPos": [
+            -360,
+            -60,
+            0
+          ],
+          "maxPos": [
+            360,
+            60,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970@6c48a",
+        "atlasUuid": "",
+        "trimType": "auto"
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "d14e8c8e-e0bf-4ab0-bdd1-90039e359970@6c48a"
+  }
+}

+ 9 - 6
assets/resources/prefabs/DamageNumber.prefab

@@ -76,8 +76,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 26.24609375,
-      "height": 54.4
+      "width": 38,
+      "height": 40
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -115,14 +115,17 @@
     "_string": "12",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
-    "_actualFontSize": 20,
+    "_actualFontSize": 19,
     "_fontSize": 20,
     "_fontFamily": "Arial",
     "_lineHeight": 40,
-    "_overflow": 0,
+    "_overflow": 2,
     "_enableWrapText": true,
-    "_font": null,
-    "_isSystemFontUsed": true,
+    "_font": {
+      "__uuid__": "f5482737-839c-4813-9511-f36bf1223968",
+      "__expectedType__": "cc.LabelAtlas"
+    },
+    "_isSystemFontUsed": false,
     "_spacingX": 0,
     "_isItalic": false,
     "_isBold": false,

+ 104 - 3
assets/scripts/Animations/HPBarAnimation.ts

@@ -1,10 +1,11 @@
-import { _decorator, Component, Node, ProgressBar,  tween } from 'cc';
+import { _decorator, Component, Node, ProgressBar, tween } from 'cc';
 const { ccclass, property } = _decorator;
 
 /**
  * 血条动画组件
  * 使用两个重叠的血条实现黄色血皮滑动动画效果
  * 红色血条显示当前血量,黄色血条用于滑动动画
+ * 血条默认隐藏,只在受伤时显示并播放动画
  */
 @ccclass('HPBarAnimation')
 export class HPBarAnimation extends Component {
@@ -21,11 +22,18 @@ export class HPBarAnimation extends Component {
     })
     public yellowBarNode: Node = null;
     
+    @property({
+        type: Node,
+        tooltip: 'HPBar根节点'
+    })
+    public hpBarRootNode: Node = null;
+    
     private redProgressBar: ProgressBar = null;
     private yellowProgressBar: ProgressBar = null;
     private currentProgress: number = 1.0;
     private targetProgress: number = 1.0;
     private currentTween: any = null; // 当前正在运行的动画
+    private hideTimer: any = null; // 隐藏血条的定时器
     
     start() {
         this.initializeComponents();
@@ -38,6 +46,11 @@ export class HPBarAnimation extends Component {
         // 获取组件所属的敌人节点信息
         const enemyNode = this.node;
         const enemyName = enemyNode ? enemyNode.name : 'Unknown';
+        
+        // 如果没有设置HPBar根节点,尝试自动查找
+        if (!this.hpBarRootNode) {
+            this.hpBarRootNode = this.node.getChildByName('HPBar');
+        }
      
         // 获取红色血条组件
         if (this.redBarNode) {
@@ -64,6 +77,9 @@ export class HPBarAnimation extends Component {
         } else {
             console.error(`[HPBarAnimation] [${enemyName}] 黄色血条节点未设置!`);
         }
+        
+        // 初始化时隐藏血条
+        this.hideHealthBar();
     }
     
     /**
@@ -98,11 +114,53 @@ export class HPBarAnimation extends Component {
         }
     }
     
+    /**
+     * 显示血条
+     */
+    public showHealthBar() {
+        if (this.hpBarRootNode && this.hpBarRootNode.isValid) {
+            this.hpBarRootNode.active = true;
+        }
+        
+        // 清除隐藏定时器
+        if (this.hideTimer) {
+            clearTimeout(this.hideTimer);
+            this.hideTimer = null;
+        }
+    }
+    
+    /**
+     * 隐藏血条
+     */
+    public hideHealthBar() {
+        if (this.hpBarRootNode && this.hpBarRootNode.isValid) {
+            this.hpBarRootNode.active = false;
+        }
+    }
+    
+    /**
+     * 延迟隐藏血条
+     * @param delay 延迟时间(秒)
+     */
+    private scheduleHideHealthBar(delay: number = 3.0) {
+        // 清除之前的定时器
+        if (this.hideTimer) {
+            clearTimeout(this.hideTimer);
+        }
+        
+        // 设置新的定时器
+        this.hideTimer = setTimeout(() => {
+            this.hideHealthBar();
+            this.hideTimer = null;
+        }, delay * 1000);
+    }
+    
     /**
      * 更新血条进度并播放动画
      * @param newProgress 新的血量百分比 (0-1)
+     * @param showBar 是否显示血条(默认为true)
      */
-    public updateProgress(newProgress: number) {
+    public updateProgress(newProgress: number, showBar: boolean = true) {
         const enemyName = this.node ? this.node.name : 'Unknown';
         
         if (!this.redProgressBar || !this.yellowProgressBar) {
@@ -113,6 +171,11 @@ export class HPBarAnimation extends Component {
         // 限制进度范围
         newProgress = Math.max(0, Math.min(1, newProgress));
         
+        // 如果需要显示血条
+        if (showBar) {
+            this.showHealthBar();
+        }
+        
         // 如果血量增加或没有变化,直接更新
         if (newProgress >= this.currentProgress) {
             this.currentProgress = newProgress;
@@ -125,6 +188,13 @@ export class HPBarAnimation extends Component {
                 this.yellowProgressBar.progress = newProgress;
             }
             this.updateBarDisplay();
+            
+            // 如果血量满了,立即隐藏血条
+            if (newProgress >= 1.0) {
+                this.scheduleHideHealthBar(1.0); // 1秒后隐藏
+            } else if (showBar) {
+                this.scheduleHideHealthBar(3.0); // 3秒后隐藏
+            }
             return;
         }
         
@@ -182,6 +252,11 @@ export class HPBarAnimation extends Component {
                     }
                     // 清除动画引用
                     this.currentTween = null;
+                    
+                    // 动画完成后延迟隐藏血条
+                    if (newProgress > 0) {
+                        this.scheduleHideHealthBar(3.0); // 3秒后隐藏血条
+                    }
                 }
             })
             .start();
@@ -198,7 +273,27 @@ export class HPBarAnimation extends Component {
      * 重置血条到满血状态
      */
     public resetToFull() {
-        this.updateProgress(1.0);
+        this.updateProgress(1.0, false); // 重置时不显示血条
+    }
+    
+    /**
+     * 重置血条到满血状态并隐藏
+     */
+    public resetToFullAndHide() {
+        this.currentProgress = 1.0;
+        this.targetProgress = 1.0;
+        
+        // 同步更新两个血条到满血状态
+        if (this.redProgressBar && this.redProgressBar.isValid) {
+            this.redProgressBar.progress = 1.0;
+        }
+        if (this.yellowProgressBar && this.yellowProgressBar.isValid) {
+            this.yellowProgressBar.progress = 1.0;
+        }
+        this.updateBarDisplay();
+        
+        // 立即隐藏血条
+        this.hideHealthBar();
     }
     
     onDestroy() {
@@ -207,5 +302,11 @@ export class HPBarAnimation extends Component {
             this.currentTween.stop();
             this.currentTween = null;
         }
+        
+        // 清理隐藏血条的定时器,防止内存泄漏
+        if (this.hideTimer) {
+            clearTimeout(this.hideTimer);
+            this.hideTimer = null;
+        }
     }
 }

+ 26 - 4
assets/scripts/CombatSystem/EnemyInstance.ts

@@ -286,6 +286,7 @@ export class EnemyInstance extends Component {
                     // 正确设置红色和黄色血条节点引用
                     this.hpBarAnimation.redBarNode = redBarNode;
                     this.hpBarAnimation.yellowBarNode = yellowBarNode;
+                    this.hpBarAnimation.hpBarRootNode = hpBar; // 设置HPBar根节点
                     console.log(`[EnemyInstance] 血条动画组件已初始化`);
                 }
             } else {
@@ -297,7 +298,7 @@ export class EnemyInstance extends Component {
     }
     
     // 更新血量显示
-    updateHealthDisplay() {
+    updateHealthDisplay(showBar: boolean = false) {
         // 确保血量值在有效范围内
         this.health = Math.max(0, Math.min(this.maxHealth, this.health));
         
@@ -307,7 +308,7 @@ export class EnemyInstance extends Component {
         
         // 使用血条动画组件更新血条
         if (this.hpBarAnimation) {
-            this.hpBarAnimation.updateProgress(healthProgress);
+            this.hpBarAnimation.updateProgress(healthProgress, showBar);
         } else {
             // 备用方案:直接更新血条
             const hpBar = this.node.getChildByName('HPBar');
@@ -316,6 +317,8 @@ export class EnemyInstance extends Component {
                 if (progressBar) {
                     progressBar.progress = healthProgress;
                 }
+                // 根据showBar参数控制血条显示
+                hpBar.active = showBar;
             }
         }
         
@@ -369,8 +372,8 @@ export class EnemyInstance extends Component {
             DamageNumberAni.showDamageNumber(damage, this.node.worldPosition, isCritical);
         }
         
-        // 更新血量显示和动画
-        this.updateHealthDisplay();
+        // 更新血量显示和动画,受伤时显示血条
+        this.updateHealthDisplay(true);
         
         // 如果血量低于等于0,销毁敌人
         if (this.health <= 0) {
@@ -604,4 +607,23 @@ export class EnemyInstance extends Component {
     public isPausedState(): boolean {
         return this.isPaused;
     }
+    
+    /**
+     * 重置血条状态(满血并隐藏)
+     */
+    public resetHealthBar(): void {
+        if (this.hpBarAnimation) {
+            this.hpBarAnimation.resetToFullAndHide();
+        } else {
+            // 备用方案:直接隐藏血条
+            const hpBar = this.node.getChildByName('HPBar');
+            if (hpBar) {
+                hpBar.active = false;
+                const progressBar = hpBar.getComponent(ProgressBar);
+                if (progressBar) {
+                    progressBar.progress = 1.0;
+                }
+            }
+        }
+    }
 }