feat(map): 新增任务技能面板并优化技能触发逻辑

- 新增 mskills.prefab 作为任务技能容器
- 将 MissSkillsComp 挂载到场景实体层,移除 MissionCardComp 中的引用
- 优化 SkillBoxComp 触发坐标计算,改为基于父节点位置
- 调整技能盒尺寸并添加等级标签显示
- 修复战斗开始时技能触发计时器重置逻辑
This commit is contained in:
walkpan
2026-04-06 22:09:43 +08:00
parent 2010e2adc5
commit 62b7b9783a
8 changed files with 1716 additions and 1310 deletions

View File

@@ -28,17 +28,17 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 120 "__id__": 136
}, },
{ {
"__id__": 122 "__id__": 138
}, },
{ {
"__id__": 124 "__id__": 140
} }
], ],
"_prefab": { "_prefab": {
"__id__": 126 "__id__": 142
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -197,17 +197,17 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 113 "__id__": 129
}, },
{ {
"__id__": 115 "__id__": 131
}, },
{ {
"__id__": 117 "__id__": 133
} }
], ],
"_prefab": { "_prefab": {
"__id__": 119 "__id__": 135
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -257,17 +257,17 @@
"__id__": 70 "__id__": 70
}, },
{ {
"__id__": 104 "__id__": 120
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 110 "__id__": 126
} }
], ],
"_prefab": { "_prefab": {
"__id__": 112 "__id__": 128
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -1100,6 +1100,8 @@
"__id__": 0 "__id__": 0
}, },
"fileId": "afC1QRFbdIJrdpKczcbi3p", "fileId": "afC1QRFbdIJrdpKczcbi3p",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
@@ -1719,19 +1721,22 @@
}, },
{ {
"__id__": 95 "__id__": 95
},
{
"__id__": 99
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 99 "__id__": 115
}, },
{ {
"__id__": 101 "__id__": 117
} }
], ],
"_prefab": { "_prefab": {
"__id__": 103 "__id__": 119
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -2378,6 +2383,212 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 70
},
"_prefab": {
"__id__": 100
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 99
},
"asset": {
"__uuid__": "0f2aeee0-d590-4c36-9f20-a93b058d5b91",
"__expectedType__": "cc.Prefab"
},
"fileId": "5622mxbS1PNqMFP0FH5Mir",
"instance": {
"__id__": 101
},
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "f99PWIj1JPJqRhcUsVZf3M",
"prefabRootNode": {
"__id__": 1
},
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 102
},
{
"__id__": 104
},
{
"__id__": 105
},
{
"__id__": 106
},
{
"__id__": 107
},
{
"__id__": 109
},
{
"__id__": 110
},
{
"__id__": 111
},
{
"__id__": 112
},
{
"__id__": 114
}
],
"removedComponents": []
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 103
},
"propertyPath": [
"_name"
],
"value": "mskills"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"5622mxbS1PNqMFP0FH5Mir"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 103
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": -180,
"y": 314.571,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 103
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 103
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 108
},
"propertyPath": [
"_alignFlags"
],
"value": 10
},
{
"__type__": "cc.TargetInfo",
"localID": [
"baKsIzXktAyqqNBZKVQXO+"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 108
},
"propertyPath": [
"_left"
],
"value": -360
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 108
},
"propertyPath": [
"_right"
],
"value": -130
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 108
},
"propertyPath": [
"_originalWidth"
],
"value": 360
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 113
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 360,
"height": 100
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"4dNsDtN3ZGiZ+om9xELLFQ"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 108
},
"propertyPath": [
"_verticalCenter"
],
"value": 264.571
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
@@ -2388,7 +2599,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 100 "__id__": 116
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -2416,7 +2627,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 102 "__id__": 118
}, },
"_id": "" "_id": ""
}, },
@@ -2449,14 +2660,14 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 105 "__id__": 121
}, },
{ {
"__id__": 107 "__id__": 123
} }
], ],
"_prefab": { "_prefab": {
"__id__": 109 "__id__": 125
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -2493,11 +2704,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 104 "__id__": 120
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 106 "__id__": 122
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -2521,11 +2732,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 104 "__id__": 120
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 108 "__id__": 124
}, },
"light": null, "light": null,
"_id": "" "_id": ""
@@ -2557,7 +2768,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 111 "__id__": 127
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -2598,7 +2809,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 114 "__id__": 130
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -2626,7 +2837,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 116 "__id__": 132
}, },
"camera": { "camera": {
"__id__": 3 "__id__": 3
@@ -2641,10 +2852,10 @@
"__id__": 66 "__id__": 66
}, },
"entityLayer": { "entityLayer": {
"__id__": 101 "__id__": 117
}, },
"SkillLayer": { "SkillLayer": {
"__id__": 107 "__id__": 123
}, },
"isFollowPlayer": true, "isFollowPlayer": true,
"_id": "" "_id": ""
@@ -2663,7 +2874,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 118 "__id__": 134
}, },
"_id": "" "_id": ""
}, },
@@ -2694,7 +2905,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 121 "__id__": 137
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -2722,7 +2933,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 123 "__id__": 139
}, },
"_cameraComponent": { "_cameraComponent": {
"__id__": 3 "__id__": 3
@@ -2744,7 +2955,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 125 "__id__": 141
}, },
"_alignFlags": 45, "_alignFlags": 45,
"_target": null, "_target": null,
@@ -2780,6 +2991,11 @@
}, },
"fileId": "32qENLKwZHV5S2IyZfpNx2", "fileId": "32qENLKwZHV5S2IyZfpNx2",
"instance": null, "instance": null,
"targetOverrides": null "targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 99
}
]
} }
] ]

View File

@@ -0,0 +1,203 @@
[
{
"__type__": "cc.Prefab",
"_name": "mskills",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "mskills",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": true,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
}
],
"_prefab": {
"__id__": 10
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -180,
"y": 990,
"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__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_contentSize": {
"__type__": "cc.Size",
"width": 360,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "4dNsDtN3ZGiZ+om9xELLFQ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_alignFlags": 10,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 350,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "baKsIzXktAyqqNBZKVQXO+"
},
{
"__type__": "68387wnH45AVo6Nco+pXtG5",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"skill_box": {
"__uuid__": "d19cde30-f5d0-47de-a0d5-3a272b696343",
"__expectedType__": "cc.Prefab"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "d4AyZdLXNB07iSaFvEU6BB"
},
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"_resizeMode": 0,
"_layoutType": 1,
"_cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
},
"_startAxis": 0,
"_paddingLeft": 10,
"_paddingRight": 0,
"_paddingTop": 0,
"_paddingBottom": 0,
"_spacingX": 10,
"_spacingY": 0,
"_verticalDirection": 1,
"_horizontalDirection": 0,
"_constraint": 0,
"_constraintNum": 2,
"_affectedByScale": false,
"_isAlign": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "786tQWlIxKHLEpV0oUK9dj"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5622mxbS1PNqMFP0FH5Mir",
"targetOverrides": null
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "0f2aeee0-d590-4c36-9f20-a93b058d5b91",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "mskills"
}
}

View File

@@ -32,19 +32,22 @@
}, },
{ {
"__id__": 42 "__id__": 42
},
{
"__id__": 50
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 50 "__id__": 56
}, },
{ {
"__id__": 52 "__id__": 58
} }
], ],
"_prefab": { "_prefab": {
"__id__": 54 "__id__": 60
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -142,8 +145,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 99.7, "width": 80,
"height": 100 "height": 80
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -460,8 +463,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 97.7, "width": 78,
"height": 98 "height": 78
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -660,8 +663,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 95.7, "width": 76,
"height": 96 "height": 76
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -835,8 +838,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 87.7, "width": 68,
"height": 88 "height": 68
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -1010,8 +1013,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 99.7, "width": 80,
"height": 100 "height": 80
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -1118,6 +1121,165 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{
"__type__": "cc.Node",
"_name": "Label",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 51
},
{
"__id__": 53
}
],
"_prefab": {
"__id__": 55
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -35.658,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 50
},
"_enabled": true,
"__prefab": {
"__id__": 52
},
"_contentSize": {
"__type__": "cc.Size",
"width": 21.90380859375,
"height": 58.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "00QcmelCJILbM8JzAOuLX0"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 50
},
"_enabled": true,
"__prefab": {
"__id__": 54
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "9",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 25,
"_fontSize": 25,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": true,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 4,
"_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": "c9LY8ld0BAtrfUEiEvIGKN"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "95w1bEWo1Fx6DZZbD+r43Q",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
@@ -1128,12 +1290,12 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 51 "__id__": 57
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 99.7, "width": 80,
"height": 100 "height": 80
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -1156,11 +1318,14 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 53 "__id__": 59
}, },
"icon_node": { "icon_node": {
"__id__": 11 "__id__": 11
}, },
"info_label": {
"__id__": 53
},
"_id": "" "_id": ""
}, },
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -5,6 +5,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { SkillBoxComp } from "./SkillBoxComp"; import { SkillBoxComp } from "./SkillBoxComp";
import { oops } from "db://oops-framework/core/Oops"; import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -19,6 +20,7 @@ export class MissSkillsComp extends CCComp {
onLoad() { onLoad() {
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this); oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
this.node.parent=smc.map.MapView.scene.entityLayer!.node!
} }
onDestroy() { onDestroy() {

View File

@@ -55,8 +55,6 @@ export class MissionCardComp extends CCComp {
hero_info_prefab:Prefab=null! //场上英雄信息面板Prefab hero_info_prefab:Prefab=null! //场上英雄信息面板Prefab
@property(Node) @property(Node)
hero_num_node:Node=null! hero_num_node:Node=null!
@property(Node)
miss_skill_node:Node=null!
/** 预留图集缓存(后续接入按钮/卡面图标时复用) */ /** 预留图集缓存(后续接入按钮/卡面图标时复用) */
private uiconsAtlas: SpriteAtlas | null = null; private uiconsAtlas: SpriteAtlas | null = null;

View File

@@ -47,6 +47,7 @@ export class SkillBoxComp extends CCComp {
} }
init(uuid: number, card_lv: number) { init(uuid: number, card_lv: number) {
// this.node.parent=smc.map.MapView.scene.entityLayer!.node!
this.s_uuid = uuid; this.s_uuid = uuid;
this.card_lv = card_lv; this.card_lv = card_lv;
@@ -104,7 +105,9 @@ export class SkillBoxComp extends CCComp {
this.in_combat = true; this.in_combat = true;
if (!this.is_instant) { if (!this.is_instant) {
this.timer = this.trigger_interval; // 确保第一次能立即或按间隔触发 // 战斗开始时计时归0重新计时
this.timer = 0;
// 如果这个技能每回合都可以触发 t_times 次,则在每回合开始时重置当前回合触发次数
this.current_trigger_times = 0; this.current_trigger_times = 0;
} }
} }
@@ -141,7 +144,7 @@ export class SkillBoxComp extends CCComp {
if (this.current_trigger_times < this.trigger_times) { if (this.current_trigger_times < this.trigger_times) {
this.timer += dt; this.timer += dt;
if (this.timer >= this.trigger_interval) { if (this.timer >= this.trigger_interval) {
this.timer = 0; this.timer = 0; // 触发后重新计时
this.triggerSkill(); this.triggerSkill();
this.current_trigger_times++; this.current_trigger_times++;
} }
@@ -149,8 +152,13 @@ export class SkillBoxComp extends CCComp {
} }
private triggerSkill() { private triggerSkill() {
// 使用固定的全局坐标 // 获取自身在父节点下的局部坐标
const targetPos = new Vec3(-340, 30, 0); // UI 的局部坐标在 2D 相机中和实际的游戏逻辑坐标存在偏移关系,
// 可以结合自身局部坐标做一次偏移,此处直接读取自身的 localPosition 加上父节点的偏移
let targetPos = new Vec3();
const localPos = this.node.position;
const parentPos = this.node.parent ? this.node.parent.position : new Vec3(0, 0, 0);
targetPos.set(parentPos.x + localPos.x, parentPos.y + localPos.y, 0);
oops.message.dispatchEvent(GameEvent.TriggerSkill, { oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: this.s_uuid, s_uuid: this.s_uuid,