背后载入

This commit is contained in:
2024-07-22 16:49:11 +08:00
parent e3b5f4bd05
commit 5c961f1f37
44 changed files with 1020 additions and 109 deletions

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "8acb3fd5-26f2-4436-b699-0f755a10bc98",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -315,7 +315,7 @@
"a": 255 "a": 255
}, },
"_skeletonData": { "_skeletonData": {
"__uuid__": "52673d05-5225-4ac6-98e4-efe6494452ce", "__uuid__": "8e6ee39e-8b23-4562-846f-ad44c2bddb09",
"__expectedType__": "sp.SkeletonData" "__expectedType__": "sp.SkeletonData"
}, },
"defaultSkin": "heath", "defaultSkin": "heath",

View File

@@ -0,0 +1,34 @@
skeleton.png
size: 1271,324
format: RGBA8888
filter: Linear,Linear
repeat: none
hb_01
rotate: false
xy: 2, 2
size: 320, 320
orig: 320, 320
offset: 0, 0
index: -1
hb_02
rotate: false
xy: 645, 10
size: 312, 312
orig: 320, 320
offset: 1, 4
index: -1
hb_03
rotate: true
xy: 324, 2
size: 320, 319
orig: 320, 320
offset: 0, 1
index: -1
hb_04
rotate: false
xy: 959, 12
size: 310, 310
orig: 320, 320
offset: 2, 8
index: -1

View File

@@ -0,0 +1 @@
{"ver":"1.0.1","importer":"*","imported":true,"uuid":"c73188bd-afda-4450-945f-1c1b442c561a","files":[".atlas",".json"],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,99 @@
{
"skeleton": {
"hash": "fYDeOpztoYDiS0D+OqdbTuJk36Y",
"spine": "3.8.99",
"x": -170,
"y": -170,
"width": 320,
"height": 320,
"images": "",
"audio": ""
},
"bones": [
{ "name": "root", "x": -10, "y": -10 }
],
"slots": [
{ "name": "hero_background", "bone": "root", "attachment": "hb_03" }
],
"skins": [
{
"name": "heath",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_04", "width": 320, "height": 320 }
}
}
},
{
"name": "magic",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_01", "x": -0.1, "y": 0.19, "width": 320, "height": 320 }
}
}
},
{
"name": "monster",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_02", "width": 320, "height": 320 }
}
}
},
{
"name": "war",
"attachments": {
"hero_background": {
"hb_03": { "width": 320, "height": 320 }
}
}
}
],
"animations": {
"act1": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3333, "x": -20 },
{ "time": 0.5667, "x": 40 },
{ "time": 0.8 }
]
}
}
},
"idle": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.5, "y": 8 },
{ "time": 1 }
]
}
}
},
"magic1": {
"bones": {
"root": {
"rotate": [
{},
{ "time": 0.5, "angle": 15 },
{ "time": 1 }
]
}
}
},
"move": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3667, "y": 15 },
{ "time": 0.8 }
]
}
}
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"1.2.6","importer":"spine-data","imported":true,"uuid":"8e6ee39e-8b23-4562-846f-ad44c2bddb09","files":[".json"],"subMetas":{},"userData":{}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

View File

@@ -0,0 +1,42 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "c71977ce-c225-48e2-a5a7-b1d8dda2358a",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "c71977ce-c225-48e2-a5a7-b1d8dda2358a@6c48a",
"displayName": "skeleton",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "c71977ce-c225-48e2-a5a7-b1d8dda2358a",
"visible": false
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "texture",
"fixAlphaTransparencyArtifacts": false,
"redirect": "c71977ce-c225-48e2-a5a7-b1d8dda2358a@6c48a"
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "85cd5c8a-4f51-413c-9927-942272ca3366",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -315,10 +315,10 @@
"a": 255 "a": 255
}, },
"_skeletonData": { "_skeletonData": {
"__uuid__": "52673d05-5225-4ac6-98e4-efe6494452ce", "__uuid__": "17e711b6-d84d-4ff4-b043-e7928c5ef1b3",
"__expectedType__": "sp.SkeletonData" "__expectedType__": "sp.SkeletonData"
}, },
"defaultSkin": "heath", "defaultSkin": "magic",
"defaultAnimation": "idle", "defaultAnimation": "idle",
"_premultipliedAlpha": false, "_premultipliedAlpha": false,
"_timeScale": 1, "_timeScale": 1,

View File

@@ -0,0 +1,34 @@
skeleton.png
size: 1271,324
format: RGBA8888
filter: Linear,Linear
repeat: none
hb_01
rotate: false
xy: 2, 2
size: 320, 320
orig: 320, 320
offset: 0, 0
index: -1
hb_02
rotate: false
xy: 645, 10
size: 312, 312
orig: 320, 320
offset: 1, 4
index: -1
hb_03
rotate: true
xy: 324, 2
size: 320, 319
orig: 320, 320
offset: 0, 1
index: -1
hb_04
rotate: false
xy: 959, 12
size: 310, 310
orig: 320, 320
offset: 2, 8
index: -1

View File

@@ -0,0 +1 @@
{"ver":"1.0.1","importer":"*","imported":true,"uuid":"f2c1a17c-5c28-446c-83a6-34a71fa7dec5","files":[".atlas",".json"],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,99 @@
{
"skeleton": {
"hash": "fYDeOpztoYDiS0D+OqdbTuJk36Y",
"spine": "3.8.99",
"x": -170,
"y": -170,
"width": 320,
"height": 320,
"images": "",
"audio": ""
},
"bones": [
{ "name": "root", "x": -10, "y": -10 }
],
"slots": [
{ "name": "hero_background", "bone": "root", "attachment": "hb_03" }
],
"skins": [
{
"name": "heath",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_04", "width": 320, "height": 320 }
}
}
},
{
"name": "magic",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_01", "x": -0.1, "y": 0.19, "width": 320, "height": 320 }
}
}
},
{
"name": "monster",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_02", "width": 320, "height": 320 }
}
}
},
{
"name": "war",
"attachments": {
"hero_background": {
"hb_03": { "width": 320, "height": 320 }
}
}
}
],
"animations": {
"act1": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3333, "x": -20 },
{ "time": 0.5667, "x": 40 },
{ "time": 0.8 }
]
}
}
},
"idle": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.5, "y": 8 },
{ "time": 1 }
]
}
}
},
"magic1": {
"bones": {
"root": {
"rotate": [
{},
{ "time": 0.5, "angle": 15 },
{ "time": 1 }
]
}
}
},
"move": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3667, "y": 15 },
{ "time": 0.8 }
]
}
}
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"1.2.6","importer":"spine-data","imported":true,"uuid":"17e711b6-d84d-4ff4-b043-e7928c5ef1b3","files":[".json"],"subMetas":{},"userData":{}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

View File

@@ -0,0 +1,42 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "d3fde7d2-a222-40ab-92db-b6f5ce1b6934",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "d3fde7d2-a222-40ab-92db-b6f5ce1b6934@6c48a",
"displayName": "skeleton",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "d3fde7d2-a222-40ab-92db-b6f5ce1b6934",
"visible": false
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "texture",
"fixAlphaTransparencyArtifacts": false,
"redirect": "d3fde7d2-a222-40ab-92db-b6f5ce1b6934@6c48a"
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "b4872ab4-d44d-4b30-8d27-0638078b6371",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -315,10 +315,10 @@
"a": 255 "a": 255
}, },
"_skeletonData": { "_skeletonData": {
"__uuid__": "52673d05-5225-4ac6-98e4-efe6494452ce", "__uuid__": "a71075a2-74ca-44c5-82f3-9098b70b8108",
"__expectedType__": "sp.SkeletonData" "__expectedType__": "sp.SkeletonData"
}, },
"defaultSkin": "heath", "defaultSkin": "monster",
"defaultAnimation": "idle", "defaultAnimation": "idle",
"_premultipliedAlpha": false, "_premultipliedAlpha": false,
"_timeScale": 1, "_timeScale": 1,

View File

@@ -0,0 +1,34 @@
skeleton.png
size: 1271,324
format: RGBA8888
filter: Linear,Linear
repeat: none
hb_01
rotate: false
xy: 2, 2
size: 320, 320
orig: 320, 320
offset: 0, 0
index: -1
hb_02
rotate: false
xy: 645, 10
size: 312, 312
orig: 320, 320
offset: 1, 4
index: -1
hb_03
rotate: true
xy: 324, 2
size: 320, 319
orig: 320, 320
offset: 0, 1
index: -1
hb_04
rotate: false
xy: 959, 12
size: 310, 310
orig: 320, 320
offset: 2, 8
index: -1

View File

@@ -0,0 +1 @@
{"ver":"1.0.1","importer":"*","imported":true,"uuid":"375ddb2c-62cd-4fdc-bae3-ee6227c9ab29","files":[".atlas",".json"],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,99 @@
{
"skeleton": {
"hash": "fYDeOpztoYDiS0D+OqdbTuJk36Y",
"spine": "3.8.99",
"x": -170,
"y": -170,
"width": 320,
"height": 320,
"images": "",
"audio": ""
},
"bones": [
{ "name": "root", "x": -10, "y": -10 }
],
"slots": [
{ "name": "hero_background", "bone": "root", "attachment": "hb_03" }
],
"skins": [
{
"name": "heath",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_04", "width": 320, "height": 320 }
}
}
},
{
"name": "magic",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_01", "x": -0.1, "y": 0.19, "width": 320, "height": 320 }
}
}
},
{
"name": "monster",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_02", "width": 320, "height": 320 }
}
}
},
{
"name": "war",
"attachments": {
"hero_background": {
"hb_03": { "width": 320, "height": 320 }
}
}
}
],
"animations": {
"act1": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3333, "x": -20 },
{ "time": 0.5667, "x": 40 },
{ "time": 0.8 }
]
}
}
},
"idle": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.5, "y": 8 },
{ "time": 1 }
]
}
}
},
"magic1": {
"bones": {
"root": {
"rotate": [
{},
{ "time": 0.5, "angle": 15 },
{ "time": 1 }
]
}
}
},
"move": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3667, "y": 15 },
{ "time": 0.8 }
]
}
}
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"1.2.6","importer":"spine-data","imported":true,"uuid":"a71075a2-74ca-44c5-82f3-9098b70b8108","files":[".json"],"subMetas":{},"userData":{}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

View File

@@ -0,0 +1,42 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "911c45f2-0418-4291-8bbd-ef8716c5f34d",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "911c45f2-0418-4291-8bbd-ef8716c5f34d@6c48a",
"displayName": "skeleton",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "911c45f2-0418-4291-8bbd-ef8716c5f34d",
"visible": false
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "texture",
"fixAlphaTransparencyArtifacts": false,
"redirect": "911c45f2-0418-4291-8bbd-ef8716c5f34d@6c48a"
}
}

View File

@@ -315,7 +315,7 @@
"a": 255 "a": 255
}, },
"_skeletonData": { "_skeletonData": {
"__uuid__": "52673d05-5225-4ac6-98e4-efe6494452ce", "__uuid__": "6683952a-05cc-4103-9cfd-dbd67fea128a",
"__expectedType__": "sp.SkeletonData" "__expectedType__": "sp.SkeletonData"
}, },
"defaultSkin": "war", "defaultSkin": "war",

View File

@@ -0,0 +1 @@
{"ver":"1.2.0","importer":"directory","imported":true,"uuid":"2f43601d-548f-4b60-8db5-4fd7715916b6","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,154 @@
{
"animator": "1.0.0",
"mainStateMachine": {
"layerPos": [
0,
0
],
"layerScale": 1,
"anyStatePos": [
-660,
390
],
"subStates": [
"act1",
"idle",
"magic1",
"move"
],
"subStateMachines": []
},
"subStateMachines": [],
"defaultState": "idle",
"anyState": {
"transitions": []
},
"states": [
{
"position": [
-180,
420
],
"upStateMachine": "BaseLayer",
"state": "act1",
"motion": "act1",
"speed": 1,
"multiplier": "",
"loop": false,
"transitions": [
{
"toState": "idle",
"hasExitTime": true,
"conditions": []
}
]
},
{
"position": [
-390,
240
],
"upStateMachine": "BaseLayer",
"state": "idle",
"motion": "idle",
"speed": 1,
"multiplier": "",
"loop": true,
"transitions": [
{
"toState": "move",
"hasExitTime": false,
"conditions": [
{
"param": "act1",
"value": 0,
"logic": 0
}
]
},
{
"toState": "act1",
"hasExitTime": false,
"conditions": [
{
"param": "magic1",
"value": 0,
"logic": 0
}
]
},
{
"toState": "magic1",
"hasExitTime": false,
"conditions": [
{
"param": "move",
"value": 0,
"logic": 0
}
]
}
]
},
{
"position": [
60,
180
],
"upStateMachine": "BaseLayer",
"state": "magic1",
"motion": "magic1",
"speed": 1,
"multiplier": "",
"loop": false,
"transitions": [
{
"toState": "idle",
"hasExitTime": true,
"conditions": []
}
]
},
{
"position": [
-240,
0
],
"upStateMachine": "BaseLayer",
"state": "move",
"motion": "move",
"speed": 1,
"multiplier": "",
"loop": false,
"transitions": [
{
"toState": "idle",
"hasExitTime": true,
"conditions": []
}
]
}
],
"parameters": [
{
"param": "act1",
"type": 3,
"init": 0
},
{
"param": "magic1",
"type": 3,
"init": 0
},
{
"param": "move",
"type": 3,
"init": 0
},
{
"param": "idle",
"type": 3,
"init": 0
}
]
}

View File

@@ -0,0 +1 @@
{"ver":"2.0.1","importer":"json","imported":true,"uuid":"ce02d24b-929d-41cb-a63f-49458f0b237f","files":[".json"],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,34 @@
skeleton.png
size: 1271,324
format: RGBA8888
filter: Linear,Linear
repeat: none
hb_01
rotate: false
xy: 2, 2
size: 320, 320
orig: 320, 320
offset: 0, 0
index: -1
hb_02
rotate: false
xy: 645, 10
size: 312, 312
orig: 320, 320
offset: 1, 4
index: -1
hb_03
rotate: true
xy: 324, 2
size: 320, 319
orig: 320, 320
offset: 0, 1
index: -1
hb_04
rotate: false
xy: 959, 12
size: 310, 310
orig: 320, 320
offset: 2, 8
index: -1

View File

@@ -0,0 +1 @@
{"ver":"1.0.1","importer":"*","imported":true,"uuid":"f87ad63c-320c-4ca5-b18a-79f174843462","files":[".atlas",".json"],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,99 @@
{
"skeleton": {
"hash": "fYDeOpztoYDiS0D+OqdbTuJk36Y",
"spine": "3.8.99",
"x": -170,
"y": -170,
"width": 320,
"height": 320,
"images": "",
"audio": ""
},
"bones": [
{ "name": "root", "x": -10, "y": -10 }
],
"slots": [
{ "name": "hero_background", "bone": "root", "attachment": "hb_03" }
],
"skins": [
{
"name": "heath",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_04", "width": 320, "height": 320 }
}
}
},
{
"name": "magic",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_01", "x": -0.1, "y": 0.19, "width": 320, "height": 320 }
}
}
},
{
"name": "monster",
"attachments": {
"hero_background": {
"hb_03": { "name": "hb_02", "width": 320, "height": 320 }
}
}
},
{
"name": "war",
"attachments": {
"hero_background": {
"hb_03": { "width": 320, "height": 320 }
}
}
}
],
"animations": {
"act1": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3333, "x": -20 },
{ "time": 0.5667, "x": 40 },
{ "time": 0.8 }
]
}
}
},
"idle": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.5, "y": 8 },
{ "time": 1 }
]
}
}
},
"magic1": {
"bones": {
"root": {
"rotate": [
{},
{ "time": 0.5, "angle": 15 },
{ "time": 1 }
]
}
}
},
"move": {
"bones": {
"root": {
"translate": [
{},
{ "time": 0.3667, "y": 15 },
{ "time": 0.8 }
]
}
}
}
}
}

View File

@@ -0,0 +1 @@
{"ver":"1.2.6","importer":"spine-data","imported":true,"uuid":"6683952a-05cc-4103-9cfd-dbd67fea128a","files":[".json"],"subMetas":{},"userData":{}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 KiB

View File

@@ -0,0 +1,42 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "94eb7a7d-f511-437e-84f0-6ce986da145c",
"files": [
".json",
".png"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "94eb7a7d-f511-437e-84f0-6ce986da145c@6c48a",
"displayName": "skeleton",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "repeat",
"wrapModeT": "repeat",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "94eb7a7d-f511-437e-84f0-6ce986da145c",
"visible": false
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "texture",
"fixAlphaTransparencyArtifacts": false,
"redirect": "94eb7a7d-f511-437e-84f0-6ce986da145c@6c48a"
}
}

View File

@@ -24,7 +24,12 @@ export class Main extends Root {
protected async run() { protected async run() {
smc.initialize = ecs.getEntity<Initialize>(Initialize); smc.initialize = ecs.getEntity<Initialize>(Initialize);
smc.monsters = ['war','magic','heath'] smc.monsters = ['war','magic','heath']
smc.heros = ['war','magic','heath'] smc.heros = [
{profession:'war',speed:60},
{profession:'magic',speed:60},
{profession:'heath',speed:60},
{profession:'war',speed:60},
]
console.log("Game start"); console.log("Game start");
} }
protected initGui() { protected initGui() {

View File

@@ -0,0 +1,63 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, tween, Vec3,Label } from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp";
import { HeroModelComp } from "./HeroModelComp";
import { HeroSpine } from "./HeroSpine";
import { HeroViewComp } from "./HeroViewComp";
/** 角色实体 */
@ecs.register(`Hero`)
export class Hero extends ecs.Entity {
// 数据层
HeroModel!: HeroModelComp;
// 视图层
HeroView!: HeroViewComp;
protected init() {
this.addComponents<ecs.Comp>(
HeroModelComp);
}
destroy(): void {
this.remove(HeroViewComp);
super.destroy();
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,profession:string = "war") {
var path = "game/heros/"+profession;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
let label =node.getChildByName("top").getChildByName("lab_name")
label.getComponent(Label)!.string = profession;
var scene = smc.map.MapView.scene;
node.parent = scene.entityLayer!.node!;
var as = node.getComponent(HeroSpine);
node.setPosition(pos)
node.setScale(1, 1, 1);
var mv = node.getComponent(HeroViewComp)!;
this.add(mv);
let speed = smc.heros[0].speed;
tween(node).to(speed/60, { position: new Vec3(0, -60, 0) }, {
onComplete: () => {
// this.as.walk();
}
}).start();
//移除全局列表
smc.heros.splice(0,1)
console.log(ecs.query(ecs.allOf(HeroViewComp))
)
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"984e9949-2b16-4e46-bb30-6ac00a2a838e","files":[],"subMetas":{},"userData":{}}

View File

@@ -0,0 +1,27 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 15:56:01
* @LastEditors: dgflash
* @LastEditTime: 2022-08-17 13:43:25
*/
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/**
* 角色属性数据
*/
@ecs.register('HeroModel')
export class HeroModelComp extends ecs.Comp {
/** 角色编号 */
id: number = -1;
/** 角色名 */
name: string = "Hero";
/** 动画名资源 */
anim: string = "Hero";
reset() {
this.id = -1;
this.name = "";
}
}

View File

@@ -0,0 +1 @@
{"ver":"4.0.23","importer":"typescript","imported":true,"uuid":"0ce59d56-a495-4b95-9405-a8a85d47a439","files":[],"subMetas":{},"userData":{}}

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18 * @LastEditTime: 2022-08-17 12:36:18
*/ */
import { Vec3, _decorator } from "cc"; import { Vec3, _decorator ,tween} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroSpine } from "./HeroSpine"; import { HeroSpine } from "./HeroSpine";
@@ -23,6 +23,7 @@ export class HeroViewComp extends CCComp {
/** 视图层逻辑代码分离演示 */ /** 视图层逻辑代码分离演示 */
onLoad() { onLoad() {
this.as = this.getComponent(HeroSpine); this.as = this.getComponent(HeroSpine);
} }

View File

@@ -3,7 +3,8 @@ import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../../common/SingletonModuleComp"; import { smc } from "../../common/SingletonModuleComp";
import { Role } from "../../role/Role"; import { Role } from "../../role/Role";
import { Monster } from "../../monster/monster"; import { Monster } from "../../monster/Monster";
import { Hero } from "../../heros/Hero";
// import MapRoadUtils from "./map/road/MapRoadUtils"; // import MapRoadUtils from "./map/road/MapRoadUtils";
import { MapViewScene } from "./MapViewScene"; import { MapViewScene } from "./MapViewScene";
import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; import { Timer } from "../../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
@@ -45,69 +46,28 @@ export class MapViewComp extends CCComp {
} }
/** 添加玩家 */ /** 添加玩家 */
private addHero(pos?: Vec3) { private addHero() {
this.scene.node.active = true this.scene.node.active = true
// smc.monsters = ['war','magic','heath'] // smc.monsters = ['war','magic','heath']
// smc.heros = ['war','magic','heath'] // smc.heros = ['war','magic','heath']
// if (smc.heros.length>0){ if (smc.heros.length>0){
// let hero = ecs.getEntity<Role>(Role); let hero = ecs.getEntity<Hero>(Hero);
// let x = this.getRandomInt(-300, 0) hero.load(v3(-360,-60), smc.heros[0].profession);
// hero.load(this.aStarToVec3(x+',60'), false, "magic");
// } }
if (smc.monsters.length>0){ if (smc.monsters.length>0){
let monster = ecs.getEntity<Monster>(Monster); let monster = ecs.getEntity<Monster>(Monster);
let x = this.getRandomInt(-100, 100) monster.load(v3(360,-60));
monster.load(this.aStarToVec3(x+',-60')); smc.monsters.splice(0,1)
} }
// smc.own.loadJoystick();
// smc.heros.forEach(element => {
// var heros$i = ecs.getEntity<Role>(Role);
// let i =1
// switch (element) {
// case "war":
// heros$i.load(this.aStarToVec3("-30,-60"), false);
// break;
// case "magic":
// heros$i.load(this.aStarToVec3("-140,-60"), false);
// break;
// case "heath":
// heros$i.load(this.aStarToVec3("-230,-60"), false)
// }
// i=i+1
// });
// let x = 1
// smc.monsters.forEach(element => {
// var monsters$x = ecs.getEntity<Role>(Role);
// switch (element) {
// case "war":
// monsters$x.load(this.aStarToVec3("30,-60"), true);
// break;
// case "magic":
// monsters$x.load(this.aStarToVec3("140,-60"), true);
// break;
// case "heath":
// monsters$x.load(this.aStarToVec3("230,-60"), true)
// }
// x=x+1
// });
} }
private getRandomInt(min: number, max: number): number { private getRandomInt(min: number, max: number): number {
min = Math.ceil(min); min = Math.ceil(min);
max = Math.floor(max); max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; return Math.floor(Math.random() * (max - min + 1)) + min;
} }
private aStarToVec3(str: string) {
let array = str.split(",");
let x = parseInt(array[0]);
let y = parseInt(array[1]);
// let p = MapRoadUtils.instance.getPixelByDerect(x, y);
return v3(x, y);
}
} }

View File

@@ -5,7 +5,7 @@
* @LastEditors: dgflash * @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04 * @LastEditTime: 2022-08-04 15:43:04
*/ */
import { instantiate, Node, Prefab, Vec3 } from "cc"; import { instantiate, Node, Prefab, Vec3 ,tween} from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines"; import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
@@ -14,7 +14,7 @@ import { smc } from "../common/SingletonModuleComp";
import { MonsterModelComp } from "./MonsterModelComp"; import { MonsterModelComp } from "./MonsterModelComp";
import { MonsterSpine } from "./MonsterSpine"; import { MonsterSpine } from "./MonsterSpine";
import { MonsterViewComp } from "./MonsterViewComp"; import { MonsterViewComp } from "./MonsterViewComp";
import { MoveTo } from "../../../../extensions/oops-plugin-framework/assets/libs/animator-move/MoveTo";
/** 角色实体 */ /** 角色实体 */
@ecs.register(`Monster`) @ecs.register(`Monster`)
export class Monster extends ecs.Entity { export class Monster extends ecs.Entity {
@@ -48,7 +48,12 @@ export class Monster extends ecs.Entity {
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
this.add(mv); this.add(mv);
node.setScale(-1, 1, 1); node.setScale(-1, 1, 1);
tween(node).to(1, { position: new Vec3(0, -60, 0) }, {
onComplete: () => {
// this.as.walk();
}
}).start();
} }
} }

View File

@@ -5,7 +5,7 @@
* @LastEditTime: 2022-08-17 12:36:18 * @LastEditTime: 2022-08-17 12:36:18
*/ */
import { Vec3, _decorator } from "cc"; import { Vec3, _decorator ,tween} from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { MonsterSpine } from "./MonsterSpine"; import { MonsterSpine } from "./MonsterSpine";
@@ -23,6 +23,8 @@ export class MonsterViewComp extends CCComp {
/** 视图层逻辑代码分离演示 */ /** 视图层逻辑代码分离演示 */
onLoad() { onLoad() {
this.as = this.getComponent(MonsterSpine); this.as = this.getComponent(MonsterSpine);
//移动到0-60
} }

View File

@@ -23,51 +23,6 @@ export default class RoleSpineAnimator extends Component {
this.spine = this.getComponent(sp.Skeleton)!; this.spine = this.getComponent(sp.Skeleton)!;
console.log("RoleSpineAnimator start smc.heros",smc.heros); console.log("RoleSpineAnimator start smc.heros",smc.heros);
let heros=smc.heros
if(heros.length>0){
/**
* 取第一个heros
*/
this.spine.setSkin(heros[0])
console.log("RoleSpineAnimator setSkin", heros[0]);
switch (heros[0]) {
case 'war':
this.spine.setAnimation(0, 'idle', true)
break;
case 'magic':
this.spine.setAnimation(0, 'idle', true)
break;
case 'heath':
this.spine.setAnimation(0, 'idle', true)
break;
default:
this.spine.setAnimation(0, 'idle', true)
break;
}
//移除smc.heros[0],heros key 重新取
heros.splice(0,1)
smc.heros=heros
}else if(smc.monsters.length>0){
this.spine.setSkin(smc.monsters[0])
console.log("RoleSpineAnimator setSkin", smc.monsters[0]);
switch (smc.monsters[0]) {
case 'war':
this.spine.setAnimation(0, 'idle', true)
break;
case 'magic':
this.spine.setAnimation(0, 'idle', true)
break;
case 'heath':
this.spine.setAnimation(0, 'idle', true)
break;
default:
this.spine.setAnimation(0, 'idle', true)
break;
}
}
} }
lateUpdate(dt: number) { lateUpdate(dt: number) {