Browse Source

武器基础实现,弹夹换弹逻辑实现

greg 4 years ago
parent
commit
b16ab825e4

+ 5 - 35
assets/d3d/hands/Hand_R.fbx.meta

@@ -104,12 +104,12 @@
         "events": []
       }
     },
-    "a5fc5": {
+    "50b81": {
       "importer": "gltf-animation",
-      "uuid": "4c5c56bf-bd01-4841-8115-43f5238e1230@a5fc5",
+      "uuid": "4c5c56bf-bd01-4841-8115-43f5238e1230@50b81",
       "displayName": "",
-      "id": "a5fc5",
-      "name": "ReloadDown.animation",
+      "id": "50b81",
+      "name": "Reload.animation",
       "ver": "1.0.14",
       "imported": true,
       "files": [
@@ -123,30 +123,6 @@
         "sample": 30,
         "span": {
           "from": 2.1666666666666665,
-          "to": 3
-        },
-        "events": []
-      }
-    },
-    "ca6b1": {
-      "importer": "gltf-animation",
-      "uuid": "4c5c56bf-bd01-4841-8115-43f5238e1230@ca6b1",
-      "displayName": "",
-      "id": "ca6b1",
-      "name": "ReloadUp.animation",
-      "ver": "1.0.14",
-      "imported": true,
-      "files": [
-        ".bin",
-        ".json"
-      ],
-      "subMetas": {},
-      "userData": {
-        "gltfIndex": 0,
-        "wrapMode": 1,
-        "sample": 30,
-        "span": {
-          "from": 3,
           "to": 3.6666667461395264
         },
         "events": []
@@ -236,14 +212,8 @@
             "wrapMode": 2
           },
           {
-            "name": "ReloadDown",
+            "name": "Reload",
             "from": 2.1666666666666665,
-            "to": 3,
-            "wrapMode": 1
-          },
-          {
-            "name": "ReloadUp",
-            "from": 3,
             "to": 3.6666667461395264,
             "wrapMode": 1
           }

+ 2 - 5
assets/resources/d3d/hands/Hand_L.prefab

@@ -850,7 +850,7 @@
       "__id__": 1
     },
     "_enabled": true,
-    "playOnLoad": true,
+    "playOnLoad": false,
     "_clips": [
       {
         "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@c2696"
@@ -859,10 +859,7 @@
         "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@88ed1"
       },
       {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@a5fc5"
-      },
-      {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@ca6b1"
+        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@50b81"
       }
     ],
     "_defaultClip": {

+ 41 - 47
assets/resources/d3d/hands/Hand_R.prefab

@@ -31,9 +31,9 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0,
+      "x": 0.3,
       "y": 0,
-      "z": -1
+      "z": 0
     },
     "_lrot": {
       "__type__": "cc.Quat",
@@ -127,10 +127,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911906,
+      "x": -0.7071068407911907,
       "y": 0,
       "z": 0,
-      "w": 0.7071067215818996
+      "w": 0.7071067215818994
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -175,10 +175,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7128733386984369,
-      "y": -0.12168298645414753,
-      "z": 0.6820341935561693,
-      "w": -0.10878516719079445
+      "x": 0.7128733386984368,
+      "y": -0.12168298645414762,
+      "z": 0.6820341935561695,
+      "w": -0.10878516719079441
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -223,10 +223,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.46698844921770905,
-      "y": 0.8733058663251212,
-      "z": 0.09971510723327491,
-      "w": -0.0965170944901739
+      "x": -0.466988449217709,
+      "y": -0.8733058663251212,
+      "z": -0.09971510723327488,
+      "w": 0.09651709449017401
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -268,10 +268,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.5686733656216296,
-      "y": 0.09836318228904103,
-      "z": 0.7051433838438258,
-      "w": 0.4119564246662746
+      "x": -0.5686733656216297,
+      "y": 0.09836318228904112,
+      "z": 0.7051433838438259,
+      "w": 0.4119564246662747
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -316,10 +316,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.17887440785674324,
-      "y": 0.08786853629725101,
-      "z": 0.9795610561564844,
-      "w": -0.027261764514996394
+      "x": -0.17887440785674327,
+      "y": -0.08786853629725089,
+      "z": -0.9795610561564843,
+      "w": 0.027261764514996373
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -361,10 +361,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.16598473782119896,
+      "x": 0.1659847378211989,
       "y": 0.7220834621029274,
       "z": 0.6543067809145152,
-      "w": 0.15141722827063847
+      "w": 0.15141722827063853
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -402,10 +402,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -1.9718089641021365e-18,
-      "y": 0.26985764707823545,
+      "x": -1.9718089641021357e-18,
+      "y": 0.2698576470782355,
       "z": 7.035765905900923e-18,
-      "w": 0.962900228639187
+      "w": 0.9629002286391869
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -477,10 +477,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.010300790094140692,
-      "y": 0.047925357400886145,
+      "x": 0.010300790094140965,
+      "y": 0.04792535740088619,
       "z": 0.9732548721471967,
-      "w": 0.22443709070289086
+      "w": 0.22443709070289092
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -499,7 +499,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface1<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 12
@@ -607,10 +607,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7015816570744882,
-      "y": -0.11412622036854037,
-      "z": -0.6141477824497482,
-      "w": -0.34290069348583047
+      "x": -0.701581657074488,
+      "y": 0.11412622036854045,
+      "z": 0.6141477824497483,
+      "w": 0.34290069348583063
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -629,7 +629,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface2<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 18
@@ -722,10 +722,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7128733460429766,
-      "y": -0.12168294300433076,
-      "z": 0.6820342005829816,
-      "w": 0.10878512360809396
+      "x": 0.7128733460429769,
+      "y": -0.12168294300433088,
+      "z": 0.6820342005829815,
+      "w": 0.10878512360809416
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -744,7 +744,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface3<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 23
@@ -844,7 +844,7 @@
   },
   {
     "__type__": "cc.AnimationComponent",
-    "_name": "",
+    "_name": "Hand_R<AnimationComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 1
@@ -859,13 +859,7 @@
         "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@88ed1"
       },
       {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@a5fc5"
-      },
-      {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@ca6b1"
-      },
-      {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@c2696"
+        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@50b81"
       }
     ],
     "_defaultClip": {

+ 105 - 104
assets/resources/scenes/FightingScene.scene

@@ -219,17 +219,17 @@
     "rightHand": {
       "__id__": 41
     },
-    "_id": "32noWNOLlFEZkj8FL7OMTR"
+    "_id": "5fQvSASkJP/6MHZwcKcaeO"
   },
   {
     "__type__": "cc.AnimationComponent",
-    "_name": "",
+    "_name": "Hand_L<AnimationComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 10
     },
     "_enabled": true,
-    "playOnLoad": true,
+    "playOnLoad": false,
     "_clips": [
       {
         "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@c2696"
@@ -238,14 +238,13 @@
         "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@88ed1"
       },
       {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@a5fc5"
-      },
-      {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@ca6b1"
+        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@50b81"
       }
     ],
-    "_defaultClip": null,
-    "_id": "3a1xA9KTlF87XWEZu8Uqep"
+    "_defaultClip": {
+      "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@c2696"
+    },
+    "_id": "7e74/BZrFNF4zBjWTKSG1a"
   },
   {
     "__type__": "cc.Node",
@@ -461,10 +460,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911906,
+      "x": -0.7071068407911907,
       "y": 0,
       "z": 0,
-      "w": 0.7071067215818996
+      "w": 0.7071067215818994
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -509,10 +508,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7128733386984369,
-      "y": -0.12168298645414753,
-      "z": 0.6820341935561693,
-      "w": -0.10878516719079445
+      "x": 0.7128733386984368,
+      "y": -0.12168298645414762,
+      "z": 0.6820341935561695,
+      "w": -0.10878516719079441
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -557,10 +556,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.46698844921770905,
-      "y": 0.8733058663251212,
-      "z": 0.09971510723327491,
-      "w": -0.0965170944901739
+      "x": -0.466988449217709,
+      "y": -0.8733058663251212,
+      "z": -0.09971510723327488,
+      "w": 0.09651709449017401
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -602,10 +601,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.5686733656216296,
-      "y": 0.09836318228904103,
-      "z": 0.7051433838438258,
-      "w": 0.4119564246662746
+      "x": -0.5686733656216297,
+      "y": 0.09836318228904112,
+      "z": 0.7051433838438259,
+      "w": 0.4119564246662747
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -650,10 +649,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.17887440785674324,
-      "y": 0.08786853629725101,
-      "z": 0.9795610561564844,
-      "w": -0.027261764514996394
+      "x": -0.17887440785674327,
+      "y": -0.08786853629725089,
+      "z": -0.9795610561564843,
+      "w": 0.027261764514996373
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -695,10 +694,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.16598473782119896,
+      "x": 0.1659847378211989,
       "y": 0.7220834621029274,
       "z": 0.6543067809145152,
-      "w": 0.15141722827063847
+      "w": 0.15141722827063853
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -730,16 +729,16 @@
     },
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 0.092619,
-      "y": 0.115807,
-      "z": 0.477917
+      "x": 0.0926190093159676,
+      "y": 0.115806952118874,
+      "z": 0.477917075157166
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -1.9718089641021365e-18,
-      "y": 0.26985764707823545,
+      "x": -1.9718089641021357e-18,
+      "y": 0.2698576470782355,
       "z": 7.035765905900923e-18,
-      "w": 0.962900228639187
+      "w": 0.9629002286391869
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -811,10 +810,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.010300790094140692,
-      "y": 0.047925357400886145,
+      "x": 0.010300790094140965,
+      "y": 0.04792535740088619,
       "z": 0.9732548721471967,
-      "w": 0.22443709070289086
+      "w": 0.22443709070289092
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -833,7 +832,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface1<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 23
@@ -853,7 +852,7 @@
     },
     "_shadowCastingMode": 0,
     "_enableMorph": true,
-    "_id": "3dxaF0X79PJquXVDcBOEcv"
+    "_id": "efQqmidOtJTZMVBxfRmJ49"
   },
   {
     "__type__": "cc.ModelLightmapSettings",
@@ -941,10 +940,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7015816570744882,
-      "y": -0.11412622036854037,
-      "z": -0.6141477824497482,
-      "w": -0.34290069348583047
+      "x": -0.701581657074488,
+      "y": 0.11412622036854045,
+      "z": 0.6141477824497483,
+      "w": 0.34290069348583063
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -963,7 +962,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface2<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 29
@@ -983,7 +982,7 @@
     },
     "_shadowCastingMode": 0,
     "_enableMorph": true,
-    "_id": "d6zrfyVUJHQLESEXS8gT6e"
+    "_id": "e6X6r5klVI6YqeskjnjW9F"
   },
   {
     "__type__": "cc.ModelLightmapSettings",
@@ -1056,10 +1055,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7128733460429766,
-      "y": -0.12168294300433076,
-      "z": 0.6820342005829816,
-      "w": 0.10878512360809396
+      "x": 0.7128733460429769,
+      "y": -0.12168294300433088,
+      "z": 0.6820342005829815,
+      "w": 0.10878512360809416
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1078,7 +1077,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface3<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 34
@@ -1098,7 +1097,7 @@
     },
     "_shadowCastingMode": 0,
     "_enableMorph": true,
-    "_id": "e9nhrFgtFCYZZ3GeK345mM"
+    "_id": "e76uhzjxFOfLH2D9ekmwXI"
   },
   {
     "__type__": "cc.ModelLightmapSettings",
@@ -1178,7 +1177,7 @@
   },
   {
     "__type__": "cc.AnimationComponent",
-    "_name": "",
+    "_name": "Hand_R<AnimationComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 12
@@ -1193,17 +1192,13 @@
         "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@88ed1"
       },
       {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@a5fc5"
-      },
-      {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@ca6b1"
-      },
-      {
-        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@c2696"
+        "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@50b81"
       }
     ],
-    "_defaultClip": null,
-    "_id": "8coSbk3pBFhpbMr9lqmSUg"
+    "_defaultClip": {
+      "__uuid__": "4c5c56bf-bd01-4841-8115-43f5238e1230@c2696"
+    },
+    "_id": "58I5CZbvpOvKEwOgiAiwgb"
   },
   {
     "__type__": "cc.PrefabInfo",
@@ -1215,7 +1210,10 @@
     },
     "fileId": "9bHb4l/XtAn5Tv/diNe0aB",
     "sync": false,
-    "_synced": {}
+    "_synced": {
+      "default": false,
+      "serializable": false
+    }
   },
   {
     "__type__": "cc.Node",
@@ -1287,10 +1285,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.7071068407911906,
+      "x": -0.7071068407911907,
       "y": 0,
       "z": 0,
-      "w": 0.7071067215818996
+      "w": 0.7071067215818994
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1335,10 +1333,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7128733386984369,
-      "y": -0.12168298645414753,
-      "z": 0.6820341935561693,
-      "w": -0.10878516719079445
+      "x": 0.7128733386984368,
+      "y": -0.12168298645414762,
+      "z": 0.6820341935561695,
+      "w": -0.10878516719079441
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1383,10 +1381,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.46698844921770905,
-      "y": 0.8733058663251212,
-      "z": 0.09971510723327491,
-      "w": -0.0965170944901739
+      "x": -0.466988449217709,
+      "y": -0.8733058663251212,
+      "z": -0.09971510723327488,
+      "w": 0.09651709449017401
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1428,10 +1426,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -0.5686733656216296,
-      "y": 0.09836318228904103,
-      "z": 0.7051433838438258,
-      "w": 0.4119564246662746
+      "x": -0.5686733656216297,
+      "y": 0.09836318228904112,
+      "z": 0.7051433838438259,
+      "w": 0.4119564246662747
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1476,10 +1474,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.17887440785674324,
-      "y": 0.08786853629725101,
-      "z": 0.9795610561564844,
-      "w": -0.027261764514996394
+      "x": -0.17887440785674327,
+      "y": -0.08786853629725089,
+      "z": -0.9795610561564843,
+      "w": 0.027261764514996373
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1521,10 +1519,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.16598473782119896,
+      "x": 0.1659847378211989,
       "y": 0.7220834621029274,
       "z": 0.6543067809145152,
-      "w": 0.15141722827063847
+      "w": 0.15141722827063853
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1562,10 +1560,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": -1.9718089641021365e-18,
-      "y": 0.26985764707823545,
+      "x": -1.9718089641021357e-18,
+      "y": 0.2698576470782355,
       "z": 7.035765905900923e-18,
-      "w": 0.962900228639187
+      "w": 0.9629002286391869
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1637,10 +1635,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.010300790094140692,
-      "y": 0.047925357400886145,
+      "x": 0.010300790094140965,
+      "y": 0.04792535740088619,
       "z": 0.9732548721471967,
-      "w": 0.22443709070289086
+      "w": 0.22443709070289092
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1659,7 +1657,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface1<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 53
@@ -1679,7 +1677,7 @@
     },
     "_shadowCastingMode": 0,
     "_enableMorph": true,
-    "_id": "68nqe3Is1BHIafqLi9fr/R"
+    "_id": "f9yHyedL1FoqkMx/17ei2Q"
   },
   {
     "__type__": "cc.ModelLightmapSettings",
@@ -1767,10 +1765,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7015816570744882,
-      "y": -0.11412622036854037,
-      "z": -0.6141477824497482,
-      "w": -0.34290069348583047
+      "x": -0.701581657074488,
+      "y": 0.11412622036854045,
+      "z": 0.6141477824497483,
+      "w": 0.34290069348583063
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1789,7 +1787,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface2<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 59
@@ -1809,7 +1807,7 @@
     },
     "_shadowCastingMode": 0,
     "_enableMorph": true,
-    "_id": "31nI2fWCFBEoulGZWRBHrf"
+    "_id": "02+LSAWfNMYKsKsl4E1qKv"
   },
   {
     "__type__": "cc.ModelLightmapSettings",
@@ -1882,10 +1880,10 @@
     },
     "_lrot": {
       "__type__": "cc.Quat",
-      "x": 0.7128733460429766,
-      "y": -0.12168294300433076,
-      "z": 0.6820342005829816,
-      "w": 0.10878512360809396
+      "x": 0.7128733460429769,
+      "y": -0.12168294300433088,
+      "z": 0.6820342005829815,
+      "w": 0.10878512360809416
     },
     "_lscale": {
       "__type__": "cc.Vec3",
@@ -1904,7 +1902,7 @@
   },
   {
     "__type__": "cc.ModelComponent",
-    "_name": "",
+    "_name": "polySurface3<ModelComponent>",
     "_objFlags": 0,
     "node": {
       "__id__": 64
@@ -1924,7 +1922,7 @@
     },
     "_shadowCastingMode": 0,
     "_enableMorph": true,
-    "_id": "f2XJ8Rl7pKhaudQYUhoG7p"
+    "_id": "6bBHFNMq5HxZ5Rg4nyM6NM"
   },
   {
     "__type__": "cc.ModelLightmapSettings",
@@ -2012,7 +2010,10 @@
     },
     "fileId": "3aC5oiKOBEBbDRpjrEmq//",
     "sync": false,
-    "_synced": {}
+    "_synced": {
+      "default": false,
+      "serializable": false
+    }
   },
   {
     "__type__": "cc.SceneGlobals",

File diff suppressed because it is too large
+ 227 - 1335
assets/resources/ui/FightingUI.prefab


+ 131 - 0
assets/resources/ui/UIBulletPrefab.prefab

@@ -0,0 +1,131 @@
+[
+  {
+    "__type__": "cc.Prefab",
+    "_name": "",
+    "_objFlags": 0,
+    "_native": "",
+    "data": {
+      "__id__": 1
+    },
+    "optimizationPolicy": 0,
+    "asyncLoadAssets": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "UIBulletPrefab",
+    "_objFlags": 0,
+    "_parent": null,
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 2
+      },
+      {
+        "__id__": 3
+      }
+    ],
+    "_prefab": {
+      "__id__": 4
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 193,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransformComponent",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "_priority": 0,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 72,
+      "height": 18
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.SpriteComponent",
+    "_name": "",
+    "_objFlags": 0,
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_sharedMaterial": null,
+    "_spriteFrame": {
+      "__uuid__": "fe94f05a-befd-4991-ba46-437c7b4a4703@f9941"
+    },
+    "_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.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "76VVVgpgtB8pduJWPHBnUe",
+    "sync": false,
+    "_synced": {
+      "default": false,
+      "serializable": false
+    }
+  }
+]

+ 11 - 0
assets/resources/ui/UIBulletPrefab.prefab.meta

@@ -0,0 +1,11 @@
+{
+  "ver": "1.0.29",
+  "importer": "prefab",
+  "imported": true,
+  "uuid": "c8501bb6-ef6c-4576-bdf2-b21807f2b74b",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {}
+}

+ 58 - 4
assets/scripts/games/ui/fightings/FightingMediator.ts

@@ -1,13 +1,20 @@
-import { _decorator, Component, Node, ButtonComponent, EventTouch, director, SkeletalAnimationComponent } from 'cc';
+import { _decorator, Component, Node, ButtonComponent, EventTouch, director, SkeletalAnimationComponent, Prefab, instantiate, LayoutComponent } from 'cc';
 import { GUIMediator } from '../../../engines/gui/GUIMediator';
 import { GUIManager } from '../../../engines/gui/GUIManager';
 import { UIConst } from '../UIConst';
 import { GameController } from './GameController';
+import { GameModel } from '../../models/GameModel';
+import { WeaponBase } from './weapons/WeaponBase';
 const { ccclass, property } = _decorator;
 
 @ccclass('FightingMediator')
 export class FightingMediator extends GUIMediator {
-    private handPositions:number[]=[0.3,0.06];
+    
+    @property(Prefab)
+    BulletUIPrefab:Prefab=null;
+
+    @property(Node)
+    BulletClip:Node=null;
 
     @property(ButtonComponent)
     leftFireButton:ButtonComponent=null;
@@ -18,8 +25,10 @@ export class FightingMediator extends GUIMediator {
     @property(ButtonComponent)
     rightFireButton:ButtonComponent=null;
 
-
-    private currentFireButtonNode:Node;
+    /**
+     * 弹夹子弹池
+     */
+    bulletPool:Node[]=[];
     
     start () {
         // Your initialization goes here.
@@ -31,12 +40,35 @@ export class FightingMediator extends GUIMediator {
         this.leftFireButton.node.on(Node.EventType.TOUCH_END,this.FireButtonTouchEnd,this);
         this.middleFireButton.node.on(Node.EventType.TOUCH_END,this.FireButtonTouchEnd,this);
         this.rightFireButton.node.on(Node.EventType.TOUCH_END,this.FireButtonTouchEnd,this);
+
+        GameController.single.weapon.AddEvent(WeaponBase.EVENT_BULLET_CHANGE,this,this.bulletCountChanged,0);
+        this.RefreshBulletClip();
+    }
+
+
+    /**
+     * 刷新弹夹
+     */
+    RefreshBulletClip():void{
+        while(this.BulletClip.children.length!=GameController.single.weapon.bulletCount){
+            let bullet:Node;
+            //增加
+            if(this.BulletClip.children.length<GameController.single.weapon.bulletCount){
+                    bullet=this.CreateBullet();
+                    this.BulletClip.addChild(bullet);
+            }else{//删除
+                bullet=this.BulletClip.children[0];
+                this.BulletClip.removeChild(bullet);
+            }
+        }
     }
     
     update (deltaTime: number) {
         
     }
 
+
+    private currentFireButtonNode:Node;
     FireButtonTouchStart(e:EventTouch):void{
         this.currentFireButtonNode=e.target as Node;
         if(e.target==this.leftFireButton.node){
@@ -54,4 +86,26 @@ export class FightingMediator extends GUIMediator {
         }
         GameController.single.TryFire(0);
     }
+
+
+    private bulletCountChanged():void{
+        this.RefreshBulletClip();
+    }
+
+    /**
+     * 从池中创建子弹
+     */
+    private CreateBullet():Node{
+        if(this.bulletPool.length>0){
+            return this.bulletPool.shift();
+        }
+        return instantiate(this.BulletUIPrefab);
+    }
+    private DisposeBullet(bullet:Node){
+        if(this.bulletPool.indexOf(bullet)<0){
+            this.bulletPool.push(bullet);
+        }else{
+            console.error("重复回收弹夹子弹");
+        }
+    }
 }

+ 19 - 97
assets/scripts/games/ui/fightings/GameController.ts

@@ -1,126 +1,48 @@
 import { _decorator, Component, Node, SkeletalAnimationComponent, AnimationComponent, Vec3, director, find, instantiate } from 'cc';
 import { WeaponBase } from './weapons/WeaponBase';
 import { GameModel } from '../../models/GameModel';
+import { EventDispatcher } from '../../../engines/events/EventDispatcher';
 const { ccclass, property } = _decorator;
 
 
-export class GameController {
+export class GameController extends EventDispatcher{
 
-    private leftHand:AnimationComponent;
-    private rightHand:AnimationComponent;
-    private leftSocket:Node;
-    private rightSocket:Node;
-
-    private leftWeapon:AnimationComponent;
-    private rightWeapon:AnimationComponent;
-
-    private fireKey:number=0;
-    private lastFireTime:number=0;
-    private isLeftFire:boolean;
+    public weapon:WeaponBase;
 
     constructor()
     {
-
+        super();
     }
 
     /**
      * 初始化
-     * @param leftHand 
-     * @param rightHand 
+     * @param leftHand
+     * @param rightHand
      */
     Init(leftHand:AnimationComponent,rightHand:AnimationComponent):void{
-        this.leftHand=leftHand;
-        this.rightHand=rightHand;
-
-        this.leftSocket=find("RootNode/Arm/upper_arm_R/lower_arm_R/transform1/hand_R/transform2/Guns",this.leftHand.node);
-        this.rightSocket=find("RootNode/Arm/upper_arm_R/lower_arm_R/transform1/hand_R/transform2/Guns",this.rightHand.node);
-
-        this.leftWeapon=instantiate(GameModel.single.currentWeaponPrefab).getComponent(AnimationComponent);
-        this.leftSocket.addChild(this.leftWeapon.node);
-        this.rightWeapon=instantiate(GameModel.single.currentWeaponPrefab).getComponent(AnimationComponent);
-        this.rightSocket.addChild(this.rightWeapon.node);
-    }
-
-    TryFire(fireKey:number):void{
-        console.log(fireKey);
-        if(this.fireKey==fireKey){
-            return;
-        }
-        let oldFireKey=this.fireKey;
-        this.fireKey=fireKey;
-        if(this.fireKey==0){
-            this.Idle(oldFireKey);
-        }
-        this.MoveFirePosition();
+        this.weapon=new WeaponBase(leftHand,rightHand);
+        this.StartGame();
     }
 
     /**
-     * 将手移动到指定位置
+     * 开始游戏
      */
-    MoveFirePosition():void{
-        if(this.fireKey==0){
-            return;
-        }
-        let Pos:Vec3;
-        if(this.fireKey==1){
-            Pos=this.leftHand.node.position;
-            Pos.x=-0.3;
-            this.leftHand.node.setPosition(Pos);
-            
-        }else if(this.fireKey==3){
-            Pos=this.rightHand.node.position;
-            Pos.x=0.3;
-            this.rightHand.node.setPosition(Pos);
-        }else if(this.fireKey==2){
-            Pos=this.leftHand.node.position;
-            Pos.x=-0.06;
-            this.leftHand.node.setPosition(Pos);
-            Pos=this.rightHand.node.position;
-            Pos.x=0.06;
-            this.rightHand.node.setPosition(Pos);
-        }
+    StartGame():void{
+        //直接重置子弹数量
+        this.weapon.bulletCount=GameModel.single.currentWeaponConfig.clip;
     }
 
-    Update(dt:number):void{
-        if(this.fireKey==0){
-            return;
-        }
-        let currentTime=director.getCurrentTime();
-        if(currentTime-this.lastFireTime>500){
-            this.Fire();
-            this.lastFireTime=currentTime;
-        }
-    }
-
-    /**
-     * 开火
-     */
-    private Fire():void{
-        if(this.fireKey==1){
-            this.leftHand.crossFade("Fire");
-            this.isLeftFire=true;
-        }else if(this.fireKey==3){
-            this.rightHand.crossFade("Fire");
-            this.isLeftFire=false;
+    TryFire(fireKey:number):void{
+        if(fireKey==0){
+            this.weapon.StopFire();
         }else{
-            this.isLeftFire=!this.isLeftFire;
-            if(this.isLeftFire){
-                this.leftHand.crossFade("Fire");
-            }else{
-                this.rightHand.crossFade("Fire");
-            }
+            this.weapon.StartFire(fireKey);
         }
+       
     }
 
-    /**
-     * 空闲
-     */
-    private Idle(oldFireKey:number):void{
-        if(this.isLeftFire){
-            this.leftHand.crossFade("Idle",1.5);
-        }else{
-            this.rightHand.crossFade("Idle",1.5);
-        }
+    Update(dt:number):void{
+        this.weapon.Update(dt);
     }
 
 

+ 151 - 44
assets/scripts/games/ui/fightings/weapons/WeaponBase.ts

@@ -1,67 +1,174 @@
-import { _decorator, Component, Node, CCInteger, AnimationComponent } from 'cc';
+import { _decorator, Component, Node, CCInteger, AnimationComponent, find, instantiate, Vec3, director } from 'cc';
+import { GameModel } from '../../../models/GameModel';
+import { EventDispatcher } from '../../../../engines/events/EventDispatcher';
 const { ccclass, property } = _decorator;
 
-@ccclass('WeaponBase')
-export class WeaponBase extends Component {
-    /* class member could be defined like this */
-    // dummy = '';
-
-    /* use `property` decorator if your want the member to be serializable */
-    // @property
-    // serializableDummy = 0;
-
-    @property({
-        type:CCInteger,
-        tooltip:"射击类型0 单发 1 连发 2 三连发"
-    })
-    fireType:number=0;
-
-    @property({
-        type:CCInteger,
-        tooltip:"剩余子弹数量"
-    })
-    bullCount:number=0;
-
-    @property({
-        type:CCInteger,
-        tooltip:"最大子弹数量"
-    })
-    maxBullCount:number=3;
-    
-    private animation:AnimationComponent;
-    start () {
-        // Your initialization goes here.
-        this.animation=this.getComponent(AnimationComponent);
-    }
 
+export class WeaponBase extends EventDispatcher{
+
+    /**
+     * 子弹数量更改
+     */
+    public static EVENT_BULLET_CHANGE:string="EVENT_BULLET_CHANGE";
+
+    protected leftHand:AnimationComponent;
+    protected rightHand:AnimationComponent;
+    protected leftSocket:Node;
+    protected rightSocket:Node;
+
+    protected leftWeapon:AnimationComponent;
+    protected rightWeapon:AnimationComponent;
+
+    protected fireKey:number=0;
+    protected lastFireTime:number=0;
+    protected isLeftFire:boolean;
+
+    /**
+     * 开火中
+     */
+    protected isFire:boolean=false;
+    protected isReload:boolean=false;
+
+    constructor(leftHand:AnimationComponent,rightHand:AnimationComponent){
+        super();
+
+        this.leftHand=leftHand;
+        this.rightHand=rightHand;
 
-    StartFire():void{
+        this.leftSocket=find("RootNode/Arm/upper_arm_R/lower_arm_R/transform1/hand_R/transform2/Guns",this.leftHand.node);
+        this.rightSocket=find("RootNode/Arm/upper_arm_R/lower_arm_R/transform1/hand_R/transform2/Guns",this.rightHand.node);
 
+        this.leftWeapon=instantiate(GameModel.single.currentWeaponPrefab).getComponent(AnimationComponent);
+        this.leftSocket.addChild(this.leftWeapon.node);
+        this.rightWeapon=instantiate(GameModel.single.currentWeaponPrefab).getComponent(AnimationComponent);
+        this.rightSocket.addChild(this.rightWeapon.node);
+        this.Idle(true);
     }
 
+    StartFire(fireKey:number):void{
+        this.fireKey=fireKey;
+        this.isFire=true;
+        this.MoveFirePosition();
+    }
 
     StopFire():void{
+        this.isFire=false;
+        this.Idle();
+    }
+
+    Update(dt:number):void{
+        if(this.isFire==false||this.isReload){
+            return;
+        }
+        let currentTime=director.getCurrentTime();
+        if(currentTime-this.lastFireTime>GameModel.single.currentWeaponConfig.firingRate*1000){
+            this.Fire();
+            this.bulletCount--;
+            this.lastFireTime=currentTime;
+        }
+        //换弹
+        if(this.bulletCount<=0){
+            this.Reload();
+        }
+    }
+
+    /**
+     * 换弹
+     */
+    Reload():void{
+        this.isReload=true;
+        this.leftHand.crossFade("Reload");
+        this.rightHand.crossFade("Reload");
+        this.leftHand.on(AnimationComponent.EventType.FINISHED,this.ReloadComplete,this,true);
+    }
 
+    /**
+     * 换弹完成
+     */
+    ReloadComplete():void{
+        this.bulletCount=this.maxBulletCount;
+        this.isReload=false;
     }
 
+     /**
+     * 将手移动到指定位置
+     */
+    MoveFirePosition():void{
+        if(this.fireKey==0){
+            return;
+        }
+        let Pos:Vec3;
+        if(this.fireKey==1){
+            Pos=this.leftHand.node.position;
+            Pos.x=-0.3;
+            this.leftHand.node.setPosition(Pos);
+            
+        }else if(this.fireKey==3){
+            Pos=this.rightHand.node.position;
+            Pos.x=0.3;
+            this.rightHand.node.setPosition(Pos);
+        }else if(this.fireKey==2){
+            Pos=this.leftHand.node.position;
+            Pos.x=-0.06;
+            this.leftHand.node.setPosition(Pos);
+            Pos=this.rightHand.node.position;
+            Pos.x=0.06;
+            this.rightHand.node.setPosition(Pos);
+        }
+    }
+    
     /**
      * 开火
      */
-    Fire():void{
-        this.bullCount--;
-        if(this.animation!=null){
-            this.animation.play("Fire");
+    private Fire():void{
+        if(this.fireKey==1){
+            this.leftHand.crossFade("Fire");
+            this.isLeftFire=true;
+        }else if(this.fireKey==3){
+            this.rightHand.crossFade("Fire");
+            this.isLeftFire=false;
+        }else{
+            this.isLeftFire=!this.isLeftFire;
+            if(this.isLeftFire){
+                this.leftHand.crossFade("Fire");
+            }else{
+                this.rightHand.crossFade("Fire");
+            }
         }
     }
 
     /**
-     * 换弹
+     * 空闲
      */
-    Reload():void{
-        this.bullCount=this.maxBullCount;
+    private Idle(isAll?:boolean):void{
+        if(isAll){
+            this.leftHand.crossFade("Idle",1.5);
+            this.rightHand.crossFade("Idle",1.5);
+        }else{
+            if(this.isLeftFire){
+                this.leftHand.crossFade("Idle",1.5);
+            }else{
+                this.rightHand.crossFade("Idle",1.5);
+            }
+        }
     }
 
-    // update (deltaTime: number) {
-    //     // Your update function goes here.
-    // }
+    /**
+     * 剩余子弹数量
+     */
+    get bulletCount():number{
+        return this._bulletCount;
+    }
+    private _bulletCount:number=0;
+    set bulletCount(value:number){
+        this._bulletCount=value;
+        this.DispatchEvent(WeaponBase.EVENT_BULLET_CHANGE);
+    }
+
+    /**
+     * 弹夹数量
+     */
+    get maxBulletCount():number{
+        return GameModel.single.currentWeaponConfig.clip;
+    }
 }

Some files were not shown because too many files changed in this diff