From 904a60b04fe45c16d72388e0b0565e5e6eda9bf4 Mon Sep 17 00:00:00 2001 From: "pan@work" Date: Thu, 1 Aug 2024 16:53:02 +0800 Subject: [PATCH] dd --- assets/resources/game/animation.anim | 162 ++++++++ assets/resources/game/animation.anim.meta | 13 + assets/resources/game/monster/animation.anim | 17 + .../game/monster/animation.anim.meta | 13 + assets/resources/game/monster/niu.prefab | 352 +++++++++++++++--- assets/scene/main.scene | 248 ++---------- assets/script/Main.ts | 16 +- assets/script/game/monster/Monster.ts | 3 +- assets/script/game/monster/MonsterViewComp.ts | 67 +++- 9 files changed, 610 insertions(+), 281 deletions(-) create mode 100644 assets/resources/game/animation.anim create mode 100644 assets/resources/game/animation.anim.meta create mode 100644 assets/resources/game/monster/animation.anim create mode 100644 assets/resources/game/monster/animation.anim.meta diff --git a/assets/resources/game/animation.anim b/assets/resources/game/animation.anim new file mode 100644 index 00000000..6f77197a --- /dev/null +++ b/assets/resources/game/animation.anim @@ -0,0 +1,162 @@ +[ + { + "__type__": "cc.AnimationClip", + "_name": "animation", + "_objFlags": 0, + "__editorExtras__": { + "embeddedPlayerGroups": [] + }, + "_native": "", + "sample": 60, + "speed": 1, + "wrapMode": 2, + "enableTrsBlending": false, + "_duration": 0.3333333333333333, + "_hash": 500763545, + "_tracks": [ + { + "__id__": 1 + } + ], + "_exoticAnimation": null, + "_events": [], + "_embeddedPlayers": [], + "_additiveSettings": { + "__id__": 11 + }, + "_auxiliaryCurveEntries": [] + }, + { + "__type__": "cc.animation.VectorTrack", + "_binding": { + "__type__": "cc.animation.TrackBinding", + "path": { + "__id__": 2 + }, + "proxy": null + }, + "_channels": [ + { + "__id__": 3 + }, + { + "__id__": 5 + }, + { + "__id__": 7 + }, + { + "__id__": 9 + } + ], + "_nComponents": 3 + }, + { + "__type__": "cc.animation.TrackPath", + "_paths": [ + "position" + ] + }, + { + "__type__": "cc.animation.Channel", + "_curve": { + "__id__": 4 + } + }, + { + "__type__": "cc.RealCurve", + "_times": [ + 0, + 0.16666666666666666, + 0.3333333333333333 + ], + "_values": [ + { + "__type__": "cc.RealKeyframeValue", + "interpolationMode": 0, + "tangentWeightMode": 0, + "value": 0, + "rightTangent": 0, + "rightTangentWeight": 1, + "leftTangent": 0, + "leftTangentWeight": 1, + "easingMethod": 0, + "__editorExtras__": null + }, + { + "__type__": "cc.RealKeyframeValue", + "interpolationMode": 0, + "tangentWeightMode": 0, + "value": 25.451, + "rightTangent": 0, + "rightTangentWeight": 1, + "leftTangent": 0, + "leftTangentWeight": 1, + "easingMethod": 0, + "__editorExtras__": { + "tangentMode": 0 + } + }, + { + "__type__": "cc.RealKeyframeValue", + "interpolationMode": 0, + "tangentWeightMode": 0, + "value": 0, + "rightTangent": 0, + "rightTangentWeight": 1, + "leftTangent": 0, + "leftTangentWeight": 1, + "easingMethod": 0, + "__editorExtras__": { + "tangentMode": 0 + } + } + ], + "preExtrapolation": 1, + "postExtrapolation": 1 + }, + { + "__type__": "cc.animation.Channel", + "_curve": { + "__id__": 6 + } + }, + { + "__type__": "cc.RealCurve", + "_times": [], + "_values": [], + "preExtrapolation": 1, + "postExtrapolation": 1 + }, + { + "__type__": "cc.animation.Channel", + "_curve": { + "__id__": 8 + } + }, + { + "__type__": "cc.RealCurve", + "_times": [], + "_values": [], + "preExtrapolation": 1, + "postExtrapolation": 1 + }, + { + "__type__": "cc.animation.Channel", + "_curve": { + "__id__": 10 + } + }, + { + "__type__": "cc.RealCurve", + "_times": [], + "_values": [], + "preExtrapolation": 1, + "postExtrapolation": 1 + }, + { + "__type__": "cc.AnimationClipAdditiveSettings", + "enabled": false, + "refClip": null + } +] \ No newline at end of file diff --git a/assets/resources/game/animation.anim.meta b/assets/resources/game/animation.anim.meta new file mode 100644 index 00000000..5fbd17b9 --- /dev/null +++ b/assets/resources/game/animation.anim.meta @@ -0,0 +1,13 @@ +{ + "ver": "2.0.3", + "importer": "animation-clip", + "imported": true, + "uuid": "e9c26937-5a7d-49ae-8ace-742c1f2b9b19", + "files": [ + ".cconb" + ], + "subMetas": {}, + "userData": { + "name": "animation" + } +} diff --git a/assets/resources/game/monster/animation.anim b/assets/resources/game/monster/animation.anim new file mode 100644 index 00000000..fc151c71 --- /dev/null +++ b/assets/resources/game/monster/animation.anim @@ -0,0 +1,17 @@ +{ + "__type__": "cc.AnimationClip", + "_name": "", + "_objFlags": 0, + "_native": "", + "sample": 60, + "speed": 1, + "wrapMode": 1, + "events": [], + "_duration": 0, + "_keys": [], + "_stepness": 0, + "curveDatas": {}, + "_curves": [], + "_commonTargets": [], + "_hash": 0 +} diff --git a/assets/resources/game/monster/animation.anim.meta b/assets/resources/game/monster/animation.anim.meta new file mode 100644 index 00000000..a08a2c69 --- /dev/null +++ b/assets/resources/game/monster/animation.anim.meta @@ -0,0 +1,13 @@ +{ + "ver": "2.0.3", + "importer": "animation-clip", + "imported": true, + "uuid": "65f071b3-4171-4f60-bd36-cc665f54f6ae", + "files": [ + ".cconb" + ], + "subMetas": {}, + "userData": { + "name": "animation" + } +} diff --git a/assets/resources/game/monster/niu.prefab b/assets/resources/game/monster/niu.prefab index 6e97ebc9..92d93c80 100644 --- a/assets/resources/game/monster/niu.prefab +++ b/assets/resources/game/monster/niu.prefab @@ -22,32 +22,32 @@ "__id__": 2 }, { - "__id__": 10 + "__id__": 21 } ], "_active": true, "_components": [ { - "__id__": 24 + "__id__": 35 }, { - "__id__": 26 + "__id__": 37 }, { - "__id__": 28 + "__id__": 39 }, { - "__id__": 30 + "__id__": 41 }, { - "__id__": 32 + "__id__": 43 }, { - "__id__": 34 + "__id__": 45 } ], "_prefab": { - "__id__": 36 + "__id__": 47 }, "_lpos": { "__type__": "cc.Vec3", @@ -86,21 +86,25 @@ "_parent": { "__id__": 1 }, - "_children": [], + "_children": [ + { + "__id__": 3 + } + ], "_active": true, "_components": [ { - "__id__": 3 + "__id__": 13 }, { - "__id__": 5 + "__id__": 15 }, { - "__id__": 7 + "__id__": 18 } ], "_prefab": { - "__id__": 9 + "__id__": 20 }, "_lpos": { "__type__": "cc.Vec3", @@ -131,6 +135,257 @@ }, "_id": "" }, + { + "__type__": "cc.Node", + "_name": "T_Node", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 4 + } + ], + "_active": false, + "_components": [ + { + "__id__": 10 + } + ], + "_prefab": { + "__id__": 12 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 7.09929895401001, + "y": 13.99220085144043, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 3.2783540711047184e-8, + "w": 0.9999999999999989 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.4300000071525574, + "y": 0.4300000071525611, + "z": 1 + }, + "_mobility": 0, + "_layer": 1, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0.0000037567170404766334 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 3 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 5 + }, + { + "__id__": 7 + } + ], + "_prefab": { + "__id__": 9 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 29.435, + "y": 26.613, + "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": 1, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 4 + }, + "_enabled": true, + "__prefab": { + "__id__": 6 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 20, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f3GNL1lZpCHqFA6w5tcCsJ" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 4 + }, + "_enabled": true, + "__prefab": { + "__id__": 8 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_string": "角", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 20, + "_fontSize": 20, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_enableOutline": false, + "_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": "f4c1lgTFJBGIxvY4/cxQD4" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "00+njfGJhMdKDK8x/a34+r", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 3 + }, + "_enabled": true, + "__prefab": { + "__id__": 11 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "49UVV15d5MXJXprWQPuIaB" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c6JznUtWBKEKfDvFTxGhKW", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.UITransform", "_name": "", @@ -141,7 +396,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 4 + "__id__": 14 }, "_contentSize": { "__type__": "cc.Size", @@ -169,7 +424,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 6 + "__id__": 16 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -191,7 +446,11 @@ "_timeScale": 1, "_preCacheMode": 1, "_cacheMode": 1, - "_sockets": [], + "_sockets": [ + { + "__id__": 17 + } + ], "_useTint": false, "_debugMesh": false, "_debugBones": false, @@ -204,6 +463,13 @@ "__type__": "cc.CompPrefabInfo", "fileId": "d6Qb8NhhhN1ascGn7UPZok" }, + { + "__type__": "sp.Skeleton.SpineSocket", + "path": "root/bone/t", + "target": { + "__id__": 3 + } + }, { "__type__": "d3a79W3OpNBsL5WHT9mZqHd", "_name": "", @@ -214,7 +480,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 8 + "__id__": 19 }, "_id": "" }, @@ -245,20 +511,20 @@ }, "_children": [ { - "__id__": 11 + "__id__": 22 } ], "_active": true, "_components": [ { - "__id__": 19 + "__id__": 30 }, { - "__id__": 21 + "__id__": 32 } ], "_prefab": { - "__id__": 23 + "__id__": 34 }, "_lpos": { "__type__": "cc.Vec3", @@ -295,23 +561,23 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 10 + "__id__": 21 }, "_children": [], "_active": true, "_components": [ { - "__id__": 12 + "__id__": 23 }, { - "__id__": 14 + "__id__": 25 }, { - "__id__": 16 + "__id__": 27 } ], "_prefab": { - "__id__": 18 + "__id__": 29 }, "_lpos": { "__type__": "cc.Vec3", @@ -348,11 +614,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 11 + "__id__": 22 }, "_enabled": true, "__prefab": { - "__id__": 13 + "__id__": 24 }, "_contentSize": { "__type__": "cc.Size", @@ -376,11 +642,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 11 + "__id__": 22 }, "_enabled": true, "__prefab": { - "__id__": 15 + "__id__": 26 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -444,11 +710,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 11 + "__id__": 22 }, "_enabled": true, "__prefab": { - "__id__": 17 + "__id__": 28 }, "_id": "" }, @@ -475,11 +741,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 10 + "__id__": 21 }, "_enabled": true, "__prefab": { - "__id__": 20 + "__id__": 31 }, "_contentSize": { "__type__": "cc.Size", @@ -503,11 +769,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 10 + "__id__": 21 }, "_enabled": true, "__prefab": { - "__id__": 22 + "__id__": 33 }, "_resizeMode": 1, "_layoutType": 2, @@ -558,7 +824,7 @@ }, "_enabled": false, "__prefab": { - "__id__": 25 + "__id__": 36 }, "_contentSize": { "__type__": "cc.Size", @@ -586,7 +852,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 27 + "__id__": 38 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -628,10 +894,10 @@ }, "_enabled": true, "__prefab": { - "__id__": 29 + "__id__": 40 }, "animator": { - "__id__": 7 + "__id__": 18 }, "_id": "" }, @@ -649,7 +915,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 31 + "__id__": 42 }, "_id": "" }, @@ -667,7 +933,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 33 + "__id__": 44 }, "tag": 90, "_group": 2, @@ -701,7 +967,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 35 + "__id__": 46 }, "enabledContactListener": true, "bullet": true, diff --git a/assets/scene/main.scene b/assets/scene/main.scene index cc8fb1ff..58b403f8 100644 --- a/assets/scene/main.scene +++ b/assets/scene/main.scene @@ -20,13 +20,13 @@ "__id__": 2 }, { - "__id__": 19 + "__id__": 14 } ], "_active": true, "_components": [], "_prefab": { - "__id__": 25 + "__id__": 20 }, "_lpos": { "__type__": "cc.Vec3", @@ -57,7 +57,7 @@ }, "autoReleaseAssets": false, "_globals": { - "__id__": 26 + "__id__": 21 }, "_id": "ba0b085f-f8d5-40b0-9964-2fd25728d707" }, @@ -80,7 +80,7 @@ "_active": true, "_components": [ { - "__id__": 18 + "__id__": 13 } ], "_prefab": null, @@ -170,13 +170,13 @@ "_active": true, "_components": [ { - "__id__": 12 + "__id__": 7 }, { - "__id__": 14 + "__id__": 9 }, { - "__id__": 16 + "__id__": 11 } ], "_prefab": null, @@ -217,15 +217,11 @@ "_parent": { "__id__": 4 }, - "_children": [ - { - "__id__": 6 - } - ], + "_children": [], "_active": true, "_components": [ { - "__id__": 11 + "__id__": 6 } ], "_prefab": null, @@ -258,186 +254,6 @@ }, "_id": "12eU6E2KlEvrZaF2ie+unH" }, - { - "__type__": "cc.Node", - "_name": "controller", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 5 - }, - "_children": [ - { - "__id__": 7 - } - ], - "_active": true, - "_components": [ - { - "__id__": 10 - } - ], - "_prefab": null, - "_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": "28RFUSCKVPK4Ut1eJzTZgY" - }, - { - "__type__": "cc.Node", - "_name": "table", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 6 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 8 - }, - { - "__id__": 9 - } - ], - "_prefab": null, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": -400, - "z": -1000 - }, - "_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": "98M5MC38RHPpQKuqRsJic3" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 7 - }, - "_enabled": true, - "__prefab": null, - "_contentSize": { - "__type__": "cc.Size", - "width": 710, - "height": 480 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "aeRMR4BatNXppqW+wVpLKs" - }, - { - "__type__": "cc.Sprite", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 7 - }, - "_enabled": true, - "__prefab": null, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_spriteFrame": { - "__uuid__": "f25b4fd6-e7d0-4c21-b49a-736b850d13e4@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": "0crNGn4YBK6psNrEOQXB2y" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 6 - }, - "_enabled": true, - "__prefab": null, - "_contentSize": { - "__type__": "cc.Size", - "width": 100, - "height": 100 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "cafU29jDZFvZmfG8w2usbj" - }, { "__type__": "cc.Camera", "_name": "", @@ -494,7 +310,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 13 + "__id__": 8 }, "_contentSize": { "__type__": "cc.Size", @@ -522,10 +338,10 @@ }, "_enabled": true, "__prefab": { - "__id__": 15 + "__id__": 10 }, "_cameraComponent": { - "__id__": 11 + "__id__": 6 }, "_alignCanvasWithScreen": true, "_id": "7acBC/yU9N05fc6HGd8fZS" @@ -544,7 +360,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 17 + "__id__": 12 }, "_alignFlags": 45, "_target": null, @@ -598,19 +414,19 @@ }, "_children": [ { - "__id__": 20 + "__id__": 15 } ], "_active": true, "_components": [ { - "__id__": 22 + "__id__": 17 }, { - "__id__": 23 + "__id__": 18 }, { - "__id__": 24 + "__id__": 19 } ], "_prefab": null, @@ -649,13 +465,13 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 19 + "__id__": 14 }, "_children": [], "_active": true, "_components": [ { - "__id__": 21 + "__id__": 16 } ], "_prefab": null, @@ -694,7 +510,7 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 20 + "__id__": 15 }, "_enabled": true, "__prefab": null, @@ -740,7 +556,7 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 19 + "__id__": 14 }, "_enabled": true, "__prefab": null, @@ -762,12 +578,12 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 19 + "__id__": 14 }, "_enabled": true, "__prefab": null, "_cameraComponent": { - "__id__": 21 + "__id__": 16 }, "_alignCanvasWithScreen": true, "_id": "9edXgHOHxPK4QQ1IzNJ4ej" @@ -778,7 +594,7 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 19 + "__id__": 14 }, "_enabled": true, "__prefab": null, @@ -813,28 +629,28 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 27 + "__id__": 22 }, "shadows": { - "__id__": 28 + "__id__": 23 }, "_skybox": { - "__id__": 29 + "__id__": 24 }, "fog": { - "__id__": 30 + "__id__": 25 }, "octree": { - "__id__": 31 + "__id__": 26 }, "skin": { - "__id__": 32 + "__id__": 27 }, "lightProbeInfo": { - "__id__": 33 + "__id__": 28 }, "postSettings": { - "__id__": 34 + "__id__": 29 }, "bakedWithStationaryMainLight": false, "bakedWithHighpLightmap": false diff --git a/assets/script/Main.ts b/assets/script/Main.ts index cae8ed94..62d7c158 100644 --- a/assets/script/Main.ts +++ b/assets/script/Main.ts @@ -24,16 +24,16 @@ export class Main extends Root { protected async run() { smc.initialize = ecs.getEntity(Initialize); smc.monsters = [ - {prefab_path:'niu',name:'m1',speed:40}, - {prefab_path:'niu',name:'m2',speed:80}, - {prefab_path:'niu',name:'m3',speed:40}, - {prefab_path:'niu',name:'m4',speed:80}, + {prefab_path:'niu',name:'m1',speed:110}, + // {prefab_path:'niu',name:'m2',speed:80}, + // {prefab_path:'niu',name:'m3',speed:40}, + // {prefab_path:'niu',name:'m4',speed:80}, ] smc.heros = [ - {prefab_path:'niu',name:'war',speed:60}, - {prefab_path:'niu',name:'magic',speed:60}, - {prefab_path:'niu',name:'heath',speed:60}, - {prefab_path:'niu',name:'war',speed:60}, + {prefab_path:'niu',name:'war',speed:110}, + // {prefab_path:'niu',name:'magic',speed:60}, + // {prefab_path:'niu',name:'heath',speed:60}, + // {prefab_path:'niu',name:'war',speed:60}, ] console.log("Game start"); } diff --git a/assets/script/game/monster/Monster.ts b/assets/script/game/monster/Monster.ts index 53435e99..237a6d34 100644 --- a/assets/script/game/monster/Monster.ts +++ b/assets/script/game/monster/Monster.ts @@ -47,12 +47,11 @@ export class Monster extends ecs.Entity { node.getChildByName("avatar").setScale(node.getChildByName("avatar").scale.x*camp, node.getChildByName("avatar").scale.y, node.getChildByName("avatar").scale.z); node.setPosition(pos) var mv = node.getComponent(MonsterViewComp)!; - console.log('speed:'+speed) mv.speed =mv.ospeed = speed; mv.hero_name= name; mv.camp = camp; mv.Tpos = v3(0,0,0); - mv.change_name(name) + mv.change_name(name,camp) this.add(mv); if(camp == 1){ smc.heros_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}) diff --git a/assets/script/game/monster/MonsterViewComp.ts b/assets/script/game/monster/MonsterViewComp.ts index 95fb52f3..8b63b6fd 100644 --- a/assets/script/game/monster/MonsterViewComp.ts +++ b/assets/script/game/monster/MonsterViewComp.ts @@ -23,9 +23,15 @@ export class MonsterViewComp extends CCComp { /** 角色动画 */ as: MonsterSpine = null!; hero_name : string = "hero"; + /** 角色阵营 1:hero -1 :monster */ camp: number = 1; + /**角色类型 1:近战 2 远程 */ + type: number = 1; + /** 角色移动速度 */ speed: number = 100; + /** 角色初始速度 */ ospeed: number = 100; + Tpos: Vec3 = v3(0,-60,0); timer: number = 0; /** 视图层逻辑代码分离演示 */ @@ -42,12 +48,33 @@ export class MonsterViewComp extends CCComp { } onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) { - // 只在两个碰撞体开始接触时被调用一次 - // console.log('onBeginContact otherCollider.tag :',otherCollider,selfCollider); - if ( otherCollider.tag == BoxSet.HERO && selfCollider.tag == BoxSet.MONSTER) { - this.speed = 0 - this.timer = 0.5 + switch (selfCollider.tag) { + case BoxSet.MONSTER: + switch (otherCollider.tag){ + case BoxSet.HERO: + console.log("im monster other is hero"); + this.speed = 0; + this.timer = 1; + console.log("speed:"+this.speed+" | timer:"+this.timer); + break; + case BoxSet.HERO_SKILL: + + break; + case BoxSet.MONSTER_SKILL: + break; + } + break; + case BoxSet.HERO: + switch (otherCollider.tag){ + case BoxSet.MONSTER: + + break; + case BoxSet.HERO_SKILL: + + break; + } } + } onEndContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) { // 只在两个碰撞体结束接触时被调用一次 @@ -69,30 +96,45 @@ export class MonsterViewComp extends CCComp { onLoad() { this.as = this.getComponent(MonsterSpine); - console.log('hero load ent:',this); + // console.log('hero load ent:',this); PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb | EPhysics2DDrawFlags.Pair | EPhysics2DDrawFlags.CenterOfMass | EPhysics2DDrawFlags.Joint | EPhysics2DDrawFlags.Shape; } - change_name(hero_name:string){ + change_name(hero_name:string='hero',camp:number=1){ this.name=hero_name; let label:any =this.node.getChildByName("top").getChildByName("lab_name") label.getComponent(Label)!.string = hero_name; + let collider = this.getComponent(Collider2D); + if(camp==1){ + collider.tag=BoxSet.HERO; + }else{ + collider.tag=BoxSet.MONSTER; + } + } update(dt: number){ if(this.timer > 0){ this.timer -= dt; if(this.timer <= 0){ this.speed = this.ospeed; + console.log("speed:"+this.speed); this.timer = 0; } } + switch (this.type) { + case 1: + this.as.walk(); + break; + case 2: + this.as.idle(); + break; + } + if(this.camp == -1){ if(this.node.position.x < BoxSet.LETF_END){ - console.log(this.node,this.ent) - smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid); this.node.destroy(); }else{ this.move(dt); @@ -100,9 +142,7 @@ export class MonsterViewComp extends CCComp { } if(this.camp == 1){ if(this.node.position.x > BoxSet.RIGHT_END){ - console.log(this.node,this.ent) - smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid); - this.node.destroy(); + this.reset(); }else{ this.move(dt); } @@ -125,6 +165,9 @@ export class MonsterViewComp extends CCComp { // console.log('smc.monsters_in',smc.monsters_in); } reset() { + console.log("node destroy:",this.node,this.ent) + smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid); + smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid); this.node.destroy(); }