Răsfoiți Sursa

#add 添加关卡编辑

hanpeng.zhp 2 zile în urmă
părinte
comite
53353f16f3

+ 9 - 0
assets/editor/prefab.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.2.0",
+  "importer": "directory",
+  "imported": true,
+  "uuid": "39d39c9f-091c-4785-977f-be0c6b755495",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 886 - 0
assets/editor/prefab/FindItem.prefab

@@ -0,0 +1,886 @@
+[
+  {
+    "__type__": "cc.Prefab",
+    "_name": "FindItem",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_native": "",
+    "data": {
+      "__id__": 1
+    },
+    "optimizationPolicy": 0,
+    "persistent": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "FindItem",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": null,
+    "_children": [
+      {
+        "__id__": 2
+      },
+      {
+        "__id__": 6
+      },
+      {
+        "__id__": 23
+      },
+      {
+        "__id__": 29
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 35
+      },
+      {
+        "__id__": 37
+      }
+    ],
+    "_prefab": {
+      "__id__": 39
+    },
+    "_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": "spine",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 3
+      }
+    ],
+    "_prefab": {
+      "__id__": 5
+    },
+    "_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.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 4
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "3b60FrQKtFZIxS2IgiNMj7"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "b0W50KuBJNA6kDXJkQtMXO",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Slider",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [
+      {
+        "__id__": 7
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 15
+      },
+      {
+        "__id__": 17
+      },
+      {
+        "__id__": 19
+      }
+    ],
+    "_prefab": {
+      "__id__": 22
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 155.537,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0.7071067811865475,
+      "w": 0.7071067811865476
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 90
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Handle",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 6
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 8
+      },
+      {
+        "__id__": 10
+      },
+      {
+        "__id__": 12
+      }
+    ],
+    "_prefab": {
+      "__id__": 14
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": -150,
+      "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.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 7
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 9
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 32,
+      "height": 32
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "2fvDQMSi9IHKzEgK/oCbmW"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 7
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 11
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "f12a23c4-b924-4322-a260-3d982428f1e8@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": "0b9V1e7E1AbLBTPbhbOfNh"
+  },
+  {
+    "__type__": "cc.Button",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 7
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 13
+    },
+    "clickEvents": [],
+    "_interactable": true,
+    "_transition": 0,
+    "_normalColor": {
+      "__type__": "cc.Color",
+      "r": 214,
+      "g": 214,
+      "b": 214,
+      "a": 255
+    },
+    "_hoverColor": {
+      "__type__": "cc.Color",
+      "r": 211,
+      "g": 211,
+      "b": 211,
+      "a": 255
+    },
+    "_pressedColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_disabledColor": {
+      "__type__": "cc.Color",
+      "r": 124,
+      "g": 124,
+      "b": 124,
+      "a": 255
+    },
+    "_normalSprite": {
+      "__uuid__": "f12a23c4-b924-4322-a260-3d982428f1e8@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_hoverSprite": null,
+    "_pressedSprite": null,
+    "_disabledSprite": null,
+    "_duration": 0.1,
+    "_zoomScale": 1.2,
+    "_target": {
+      "__id__": 7
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "70dIbdSMRNBJi3qM4DtJk5"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "6fPGtUlrpKppxi8fNjAHr+",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 6
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 16
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 300,
+      "height": 20
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "50KeljM3RND653GQDwKovJ"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 6
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 18
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "28765e2f-040a-4c65-8e8c-f9d0bb79d863@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 1,
+    "_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": "2exh5bYlxL6YeVf12W6YjV"
+  },
+  {
+    "__type__": "cc.Slider",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 6
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 20
+    },
+    "slideEvents": [
+      {
+        "__id__": 21
+      }
+    ],
+    "_handle": {
+      "__id__": 10
+    },
+    "_direction": 0,
+    "_progress": 0,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "314L4HliBGg6jdRNm6xnHq"
+  },
+  {
+    "__type__": "cc.ClickEvent",
+    "target": {
+      "__id__": 1
+    },
+    "component": "",
+    "_componentId": "7c76b6qfHxKx6okGvvTwHxQ",
+    "handler": "onScaleSliderChanged",
+    "customEventData": ""
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "f7YTyGiP1JMreguOyv4iby",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "FoundFrame",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 24
+      },
+      {
+        "__id__": 26
+      }
+    ],
+    "_prefab": {
+      "__id__": 28
+    },
+    "_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.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 23
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 25
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 62,
+      "height": 62
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "48RxIfMaxDmaesTVxqzVZy"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 23
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 27
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "b0ec82fe-f7c8-4a7b-8139-2979af07d506@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 0,
+    "_fillType": 0,
+    "_sizeMode": 1,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "24geEpD6NGKpMKpPRWN2jG"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "5fARlLM6FDQZpfXcuay4jB",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "HintFrame",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 30
+      },
+      {
+        "__id__": 32
+      }
+    ],
+    "_prefab": {
+      "__id__": 34
+    },
+    "_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.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 29
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 31
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 62,
+      "height": 62
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "b1nO+c2q1KXJeHLVDd2YU3"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 29
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 33
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 20,
+      "b": 253,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "b0ec82fe-f7c8-4a7b-8139-2979af07d506@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 0,
+    "_fillType": 0,
+    "_sizeMode": 1,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "28fn84R7lIn4Tc/KdQ30NU"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "109FT3QNtKfIbvBJIWqxFh",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 36
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "89zYywp71PvZ8NeO7uPh3K"
+  },
+  {
+    "__type__": "7c76b6qfHxKx6okGvvTwHxQ",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 38
+    },
+    "spineNode": {
+      "__id__": 2
+    },
+    "scaleSlider": {
+      "__id__": 19
+    },
+    "redFrame": {
+      "__id__": 23
+    },
+    "blueFrame": {
+      "__id__": 29
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "cfWF7yg9VMyLyoO4SpMbsq"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "b16w6hUbBBkJrJrZ/uKbvT",
+    "instance": null,
+    "targetOverrides": []
+  }
+]

+ 13 - 0
assets/editor/prefab/FindItem.prefab.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.50",
+  "importer": "prefab",
+  "imported": true,
+  "uuid": "4adbc36f-8ee3-4681-939e-abc0c25bb481",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {
+    "syncNodeName": "FindItem"
+  }
+}

+ 9 - 0
assets/editor/script.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.2.0",
+  "importer": "directory",
+  "imported": true,
+  "uuid": "50b7fa1a-7089-4bf7-8603-353d7f92dc32",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 217 - 0
assets/editor/script/FindItem.ts

@@ -0,0 +1,217 @@
+import { _decorator, Component, EventTouch, instantiate, Node, Prefab, Slider, tween, Vec2, Vec3 } from 'cc';
+
+const { ccclass, property } = _decorator;
+
+// 物品数据类
+export class ItemData {
+    position: Vec3 = new Vec3(0, 0, 0);
+    scale: number = 1;
+}
+
+// 物品状态枚举
+export enum ItemState {
+    EDIT,      // 编辑状态
+    NORMAL,    // 正常状态
+    FOUND,     // 已找到状态
+    HINT       // 提示状态
+}
+
+@ccclass
+export default class FindItem extends Component {
+
+    @property({ type: Node })
+    spineNode: Node = null;
+
+    @property({ type: Slider })
+    scaleSlider: Slider = null;  // 缩放滑动条
+
+    @property({ type: Node })
+    redFrame: Node = null;     // 红色框
+
+    @property({ type: Node })
+    blueFrame: Node = null;    // 蓝色框
+
+    // 组件数据
+    private data: ItemData = {
+        position: new Vec3(0, 0, 0),
+        scale: 1
+    };
+
+    // 当前状态
+    private currentState: ItemState = ItemState.EDIT;
+
+    // 拖动相关
+    private isDragging: boolean = false;
+
+    // 缩放范围
+    private readonly MIN_SCALE: number = 0.1;
+    private readonly MAX_SCALE: number = 1.5;
+
+    onLoad() {
+        this.setupEventListeners();
+    }
+
+    start() {
+        this.initializeFromData();
+        this.setState(this.currentState);
+    }
+
+    onDestroy() {
+        this.removeEventListeners();
+    }
+
+    // 设置事件监听
+    private setupEventListeners() {
+        this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
+        this.node.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
+        this.node.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
+        this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
+    }
+
+    // 移除事件监听
+    private removeEventListeners() {
+        this.node.off(Node.EventType.TOUCH_START, this.onTouchStart, this);
+        this.node.off(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
+        this.node.off(Node.EventType.TOUCH_END, this.onTouchEnd, this);
+        this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
+    }
+
+    // 根据数据初始化
+    private initializeFromData() {
+        this.node.setPosition(this.data.position);
+        this.spineNode.setScale(this.data.scale, this.data.scale, 1);
+        if (this.scaleSlider) {
+            const sliderComp = this.scaleSlider.getComponent(Slider);
+            if (sliderComp) {
+                sliderComp.progress = (this.data.scale - this.MIN_SCALE) / (this.MAX_SCALE - this.MIN_SCALE);
+            }
+        }
+    }
+
+    // 设置状态
+    public setState(state: ItemState) {
+        this.currentState = state;
+        this.updateVisualState();
+    }
+
+    // 更新视觉状态
+    private updateVisualState() {
+        // 重置所有状态
+        this.scaleSlider.node.active = false;
+        this.redFrame.active = false;
+        this.blueFrame.active = false;
+
+        switch (this.currentState) {
+            case ItemState.EDIT:
+                this.scaleSlider.node.active = true;
+                break;
+
+            case ItemState.NORMAL:
+                // 正常状态,无特殊显示
+                break;
+
+            case ItemState.FOUND:
+                this.redFrame.active = true;
+                break;
+
+            case ItemState.HINT:
+                this.blueFrame.active = true;
+                this.startBlueFrameAnimation();
+                break;
+        }
+    }
+
+    // 开始蓝色框动画
+    private startBlueFrameAnimation() {
+        tween(this.blueFrame)
+            .to(0.5, { scale: new Vec3(1.2, 1.2, 1) })
+            .to(0.5, { scale: new Vec3(1, 1, 1) })
+            .repeatForever()
+            .start();
+    }
+
+    _touchStartPos: Vec2 = new Vec2(0, 0);
+    _nodeStartPos: Vec3 = new Vec3(0, 0, 0);
+    // 触摸开始
+    private onTouchStart(event: EventTouch) {
+        const touch = event.touch;
+
+
+        if (this.currentState === ItemState.EDIT) {
+            this._touchStartPos = new Vec2(touch.getUILocation().x, touch.getUILocation().y);
+            this._nodeStartPos = this.node.getPosition();
+            // 编辑状态可以拖动
+            this.isDragging = true;
+        } else if (this.currentState === ItemState.NORMAL || this.currentState === ItemState.HINT) {
+            // 正常状态和提示状态可以点击
+            // 这里只是标记,在touchEnd时处理点击
+        }
+    }
+
+    // 触摸移动
+    private onTouchMove(event: EventTouch) {
+        if (this.isDragging && this.currentState === ItemState.EDIT) {
+            const touchLoc = event.getUILocation();
+            var deltaX = touchLoc.x - this._touchStartPos.x;
+            var deltaY = touchLoc.y - this._touchStartPos.y;
+            this.node.setPosition(this._nodeStartPos.x + deltaX, this._nodeStartPos.y + deltaY, 0);
+            this.data.position.set(this.node.position);
+        }
+    }
+
+    // 触摸结束
+    private onTouchEnd(event: EventTouch) {
+        if (this.isDragging) {
+            this.isDragging = false;
+        } else {
+            // 处理点击
+            if (this.currentState === ItemState.NORMAL || this.currentState === ItemState.HINT) {
+                this.setState(ItemState.FOUND);
+                this.node.emit("itemFound", this);
+            }
+        }
+    }
+
+    // 缩放滑动条值改变
+    private onScaleSliderChanged(slider: Slider) {
+        const newScale = this.MIN_SCALE + slider.progress * (this.MAX_SCALE - this.MIN_SCALE);
+        this.spineNode.setScale(newScale, newScale, 1);
+        this.data.scale = newScale;
+    }
+
+    // 公共接口:设置数据
+    public setData(data: ItemData) {
+        this.data = { ...data };
+        this.initializeFromData();
+    }
+
+    // 公共接口:获取数据
+    public getData(): ItemData {
+        return { ...this.data };
+    }
+
+    // 公共接口:获取当前状态
+    public getState(): ItemState {
+        return this.currentState;
+    }
+
+    // 公共接口:切换到编辑模式
+    public enterEditMode() {
+        this.setState(ItemState.EDIT);
+    }
+
+    // 公共接口:退出编辑模式
+    public exitEditMode() {
+        this.setState(ItemState.NORMAL);
+    }
+
+    // 公共接口:显示提示
+    public showHint() {
+        this.setState(ItemState.HINT);
+    }
+
+    addSpineContentByPrefab(prefab: Prefab) {
+        const spineNode = instantiate(prefab);
+        this.spineNode.addChild(spineNode);
+    }   
+}

+ 9 - 0
assets/editor/script/FindItem.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.24",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "7c76beaa-7c7c-4ac7-aa24-1afbd3c07c50",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 9 - 0
assets/editor/spine.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.2.0",
+  "importer": "directory",
+  "imported": true,
+  "uuid": "444b7cd0-e5d9-4a5a-9c53-9e0f4780d01f",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 27 - 0
assets/editor/spine/hecha.atlas

@@ -0,0 +1,27 @@
+
+hecha.png
+size: 1499,1087
+format: RGBA8888
+filter: Linear,Linear
+repeat: none
+cup
+  rotate: false
+  xy: 1166, 401
+  size: 192, 153
+  orig: 192, 153
+  offset: 0, 0
+  index: -1
+r1
+  rotate: true
+  xy: 2, 2
+  size: 1083, 1162
+  orig: 1083, 1162
+  offset: 0, 0
+  index: -1
+s1
+  rotate: true
+  xy: 1166, 556
+  size: 529, 331
+  orig: 534, 331
+  offset: 5, 0
+  index: -1

+ 1 - 0
assets/editor/spine/hecha.atlas.meta

@@ -0,0 +1 @@
+{"ver":"1.0.0","importer":"*","imported":true,"uuid":"f4d1bbe4-04e4-49ae-8841-a4c00859865f","files":[".atlas",".json"],"subMetas":{},"userData":{}}

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
assets/editor/spine/hecha.json


+ 1 - 0
assets/editor/spine/hecha.json.meta

@@ -0,0 +1 @@
+{"ver":"1.2.7","importer":"spine-data","imported":true,"uuid":"3bee2366-5c54-46b2-a17b-af20f102db5a","files":[".json"],"subMetas":{},"userData":{"atlasUuid":"9feda9b3-9c95-4fdd-abdb-bdc7e9a2390c"}}

BIN
assets/editor/spine/hecha.png


+ 134 - 0
assets/editor/spine/hecha.png.meta

@@ -0,0 +1,134 @@
+{
+  "ver": "1.0.27",
+  "importer": "image",
+  "imported": true,
+  "uuid": "b1ee79d3-7669-4a06-887d-123e787b8276",
+  "files": [
+    ".json",
+    ".png"
+  ],
+  "subMetas": {
+    "6c48a": {
+      "importer": "texture",
+      "uuid": "b1ee79d3-7669-4a06-887d-123e787b8276@6c48a",
+      "displayName": "hecha",
+      "id": "6c48a",
+      "name": "texture",
+      "userData": {
+        "wrapModeS": "clamp-to-edge",
+        "wrapModeT": "clamp-to-edge",
+        "imageUuidOrDatabaseUri": "b1ee79d3-7669-4a06-887d-123e787b8276",
+        "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": "b1ee79d3-7669-4a06-887d-123e787b8276@f9941",
+      "displayName": "hecha",
+      "id": "f9941",
+      "name": "spriteFrame",
+      "userData": {
+        "trimThreshold": 1,
+        "rotated": false,
+        "offsetX": -0.5,
+        "offsetY": -0.5,
+        "trimX": 3,
+        "trimY": 3,
+        "width": 1492,
+        "height": 1082,
+        "rawWidth": 1499,
+        "rawHeight": 1087,
+        "borderTop": 0,
+        "borderBottom": 0,
+        "borderLeft": 0,
+        "borderRight": 0,
+        "packable": true,
+        "pixelsToUnit": 100,
+        "pivotX": 0.5,
+        "pivotY": 0.5,
+        "meshType": 0,
+        "vertices": {
+          "rawPosition": [
+            -746,
+            -541,
+            0,
+            746,
+            -541,
+            0,
+            -746,
+            541,
+            0,
+            746,
+            541,
+            0
+          ],
+          "indexes": [
+            0,
+            1,
+            2,
+            2,
+            1,
+            3
+          ],
+          "uv": [
+            3,
+            1084,
+            1495,
+            1084,
+            3,
+            2,
+            1495,
+            2
+          ],
+          "nuv": [
+            0.0020013342228152103,
+            0.0018399264029438822,
+            0.9973315543695798,
+            0.0018399264029438822,
+            0.0020013342228152103,
+            0.9972401103955841,
+            0.9973315543695798,
+            0.9972401103955841
+          ],
+          "minPos": [
+            -746,
+            -541,
+            0
+          ],
+          "maxPos": [
+            746,
+            541,
+            0
+          ]
+        },
+        "isUuid": true,
+        "imageUuidOrDatabaseUri": "b1ee79d3-7669-4a06-887d-123e787b8276@6c48a",
+        "atlasUuid": "",
+        "trimType": "auto"
+      },
+      "ver": "1.0.12",
+      "imported": true,
+      "files": [
+        ".json"
+      ],
+      "subMetas": {}
+    }
+  },
+  "userData": {
+    "type": "sprite-frame",
+    "hasAlpha": true,
+    "fixAlphaTransparencyArtifacts": false,
+    "redirect": "b1ee79d3-7669-4a06-887d-123e787b8276@6c48a"
+  }
+}

+ 26 - 0
assets/script/Manager/LayerMgr.ts

@@ -199,4 +199,30 @@ export class LayerMgr {
         if (bundleName == BundleName.Res) return assetManager.resources
         return assetManager.getBundle(bundleName)
     }
+
+    loadPrefab(bundleName: BundleName | string, path: string, callback: (prefab: Prefab) => void) {
+        let bundle: AssetManager.Bundle = this.getBundle(bundleName)
+        if (bundle) {
+            bundle.load(path, Prefab, (err, res) => {
+                if (err) {
+                    console.log(`load ${path} err: `, bundleName);
+                    return
+                }
+                callback(res as Prefab);
+            })
+        }
+    }
+
+    loadSprite(bundleName: BundleName | string, path: string, callback: (spriteFrame: SpriteFrame) => void) {
+        let bundle: AssetManager.Bundle = this.getBundle(bundleName)
+        if (bundle) {
+            bundle.load(path + "/spriteFrame", SpriteFrame, (err, res) => {
+                if (err) {
+                    console.log(`load ${path} err: `, bundleName, err);
+                    return
+                }
+                callback(res as SpriteFrame);
+            })
+        }
+    }
 }

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff