feat: 新增英雄出售功能并优化UI交互
- 在 Hero 类中添加 removeByEid 静态方法,用于安全移除英雄实体 - 在 HInfoComp 中集成出售按钮逻辑,点击可移除对应英雄并关闭信息面板 - 为 card.prefab 和 hnode.prefab 添加召唤/出售按钮及相关UI组件 - 调整 role_controller.prefab 面板高度并禁用部分组件 - 移除未使用的 hit-flash-white 场景资源文件 - 暂时注释 CardComp 中的触摸事件绑定以进行调试
This commit is contained in:
@@ -47,19 +47,22 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 150
|
"__id__": 150
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 196
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 196
|
"__id__": 211
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 198
|
"__id__": 213
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": {
|
"_prefab": {
|
||||||
"__id__": 200
|
"__id__": 215
|
||||||
},
|
},
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
@@ -2279,7 +2282,7 @@
|
|||||||
"__id__": 101
|
"__id__": 101
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": false,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 107
|
"__id__": 107
|
||||||
@@ -2530,7 +2533,7 @@
|
|||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_spriteFrame": {
|
"_spriteFrame": {
|
||||||
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@13f92",
|
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@15f3b",
|
||||||
"__expectedType__": "cc.SpriteFrame"
|
"__expectedType__": "cc.SpriteFrame"
|
||||||
},
|
},
|
||||||
"_type": 0,
|
"_type": 0,
|
||||||
@@ -4562,6 +4565,381 @@
|
|||||||
"targetOverrides": null,
|
"targetOverrides": null,
|
||||||
"nestedPrefabInstanceRoots": null
|
"nestedPrefabInstanceRoots": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "use",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_children": [
|
||||||
|
{
|
||||||
|
"__id__": 197
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 203
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 205
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 207
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 210
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": -140.805,
|
||||||
|
"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.Node",
|
||||||
|
"_name": "Label",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 196
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 198
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 200
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": {
|
||||||
|
"__id__": 202
|
||||||
|
},
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 2,
|
||||||
|
"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__": 197
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 199
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 60.94580078125,
|
||||||
|
"height": 54.4
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "eeZuu04rJFzoa4hbflZ24S"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Label",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 197
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 201
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_string": "召 唤",
|
||||||
|
"_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": false,
|
||||||
|
"_isUnderline": false,
|
||||||
|
"_underlineHeight": 2,
|
||||||
|
"_cacheMode": 0,
|
||||||
|
"_enableOutline": true,
|
||||||
|
"_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": "20iOHSh+RE9I1iLzeZ3LBi"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "0bHU/Up11A8YP6z6eGMtQU",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 196
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 204
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 160,
|
||||||
|
"height": 45
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "106cH+DGZAxooglHMvE045"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Sprite",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 196
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 206
|
||||||
|
},
|
||||||
|
"_customMaterial": null,
|
||||||
|
"_srcBlendFactor": 2,
|
||||||
|
"_dstBlendFactor": 4,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_spriteFrame": {
|
||||||
|
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@15f3b",
|
||||||
|
"__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": {
|
||||||
|
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4",
|
||||||
|
"__expectedType__": "cc.SpriteAtlas"
|
||||||
|
},
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "81ukyY51tDrL2JwfvnGb6H"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Button",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"__editorExtras__": {},
|
||||||
|
"node": {
|
||||||
|
"__id__": 196
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": {
|
||||||
|
"__id__": 208
|
||||||
|
},
|
||||||
|
"clickEvents": [
|
||||||
|
{
|
||||||
|
"__id__": 209
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_interactable": true,
|
||||||
|
"_transition": 3,
|
||||||
|
"_normalColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_hoverColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 211,
|
||||||
|
"g": 211,
|
||||||
|
"b": 211,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_pressedColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 255,
|
||||||
|
"b": 255,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_disabledColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 124,
|
||||||
|
"g": 124,
|
||||||
|
"b": 124,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_normalSprite": null,
|
||||||
|
"_hoverSprite": null,
|
||||||
|
"_pressedSprite": null,
|
||||||
|
"_disabledSprite": null,
|
||||||
|
"_duration": 0.1,
|
||||||
|
"_zoomScale": 1.2,
|
||||||
|
"_target": null,
|
||||||
|
"_id": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.CompPrefabInfo",
|
||||||
|
"fileId": "d5rlKxmj5A4Jw0V9vPZk0N"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.ClickEvent",
|
||||||
|
"target": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"component": "",
|
||||||
|
"_componentId": "c4842RlEXFBsYWrZpIuY9c0",
|
||||||
|
"handler": "useCard",
|
||||||
|
"customEventData": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.PrefabInfo",
|
||||||
|
"root": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"asset": {
|
||||||
|
"__id__": 0
|
||||||
|
},
|
||||||
|
"fileId": "ebG3ulmyZGU7zACc3IXmag",
|
||||||
|
"instance": null,
|
||||||
|
"targetOverrides": null,
|
||||||
|
"nestedPrefabInstanceRoots": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.UITransform",
|
"__type__": "cc.UITransform",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
@@ -4572,7 +4950,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 197
|
"__id__": 212
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
@@ -4600,7 +4978,7 @@
|
|||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 199
|
"__id__": 214
|
||||||
},
|
},
|
||||||
"Lock": {
|
"Lock": {
|
||||||
"__id__": 100
|
"__id__": 100
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -11739,7 +11739,7 @@
|
|||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 720,
|
"width": 720,
|
||||||
"height": 500
|
"height": 450
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -11834,7 +11834,7 @@
|
|||||||
"node": {
|
"node": {
|
||||||
"__id__": 70
|
"__id__": 70
|
||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": false,
|
||||||
"__prefab": {
|
"__prefab": {
|
||||||
"__id__": 570
|
"__id__": 570
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -45,6 +45,17 @@ export class Hero extends ecs.Entity {
|
|||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static removeByEid(eid: number): boolean {
|
||||||
|
const targetEid = Math.floor(eid);
|
||||||
|
if (!targetEid) return false;
|
||||||
|
const entity = ecs.getEntityByEid(targetEid);
|
||||||
|
if (!entity) return false;
|
||||||
|
const model = entity.get(HeroAttrsComp);
|
||||||
|
if (!model || model.fac !== FacSet.HERO) return false;
|
||||||
|
entity.destroy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载并初始化英雄
|
* 加载并初始化英雄
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.2.0",
|
|
||||||
"importer": "directory",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "e091410c-c7b6-4416-ae99-38697c103286",
|
|
||||||
"files": [],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"ver": "1.1.50",
|
|
||||||
"importer": "scene",
|
|
||||||
"imported": true,
|
|
||||||
"uuid": "5e1d3eb2-c300-4627-94c7-2ee03b8314f1",
|
|
||||||
"files": [
|
|
||||||
".json"
|
|
||||||
],
|
|
||||||
"subMetas": {},
|
|
||||||
"userData": {}
|
|
||||||
}
|
|
||||||
@@ -277,22 +277,22 @@ export class CardComp extends CCComp {
|
|||||||
|
|
||||||
/** 绑定触控:卡面点击使用,锁按钮点击切换锁定 */
|
/** 绑定触控:卡面点击使用,锁按钮点击切换锁定 */
|
||||||
private bindEvents() {
|
private bindEvents() {
|
||||||
this.node.on(NodeEventType.TOUCH_START, this.onCardTouchStart, this);
|
// this.node.on(NodeEventType.TOUCH_START, this.onCardTouchStart, this);
|
||||||
this.node.on(NodeEventType.TOUCH_MOVE, this.onCardTouchMove, this);
|
// this.node.on(NodeEventType.TOUCH_MOVE, this.onCardTouchMove, this);
|
||||||
this.node.on(NodeEventType.TOUCH_END, this.onCardTouchEnd, this);
|
// this.node.on(NodeEventType.TOUCH_END, this.onCardTouchEnd, this);
|
||||||
this.node.on(NodeEventType.TOUCH_CANCEL, this.onCardTouchCancel, this);
|
// this.node.on(NodeEventType.TOUCH_CANCEL, this.onCardTouchCancel, this);
|
||||||
this.Lock?.on(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
// this.Lock?.on(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||||
this.unLock?.on(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
// this.unLock?.on(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 解绑触控,防止节点销毁后残留回调 */
|
/** 解绑触控,防止节点销毁后残留回调 */
|
||||||
private unbindEvents() {
|
private unbindEvents() {
|
||||||
this.node.off(NodeEventType.TOUCH_START, this.onCardTouchStart, this);
|
// this.node.off(NodeEventType.TOUCH_START, this.onCardTouchStart, this);
|
||||||
this.node.off(NodeEventType.TOUCH_MOVE, this.onCardTouchMove, this);
|
// this.node.off(NodeEventType.TOUCH_MOVE, this.onCardTouchMove, this);
|
||||||
this.node.off(NodeEventType.TOUCH_END, this.onCardTouchEnd, this);
|
// this.node.off(NodeEventType.TOUCH_END, this.onCardTouchEnd, this);
|
||||||
this.node.off(NodeEventType.TOUCH_CANCEL, this.onCardTouchCancel, this);
|
// this.node.off(NodeEventType.TOUCH_CANCEL, this.onCardTouchCancel, this);
|
||||||
this.Lock?.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
// this.Lock?.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||||
this.unLock?.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
// this.unLock?.off(NodeEventType.TOUCH_END, this.onToggleLock, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onCardTouchStart(event: EventTouch) {
|
private onCardTouchStart(event: EventTouch) {
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { _decorator, Animation, AnimationClip, Label, Node, NodeEventType, Sprite, resources } from "cc";
|
import { _decorator, Animation, AnimationClip, Button, Event, Label, Node, NodeEventType, Sprite, resources } 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 { HeroInfo } from "../common/config/heroSet";
|
import { HeroInfo } from "../common/config/heroSet";
|
||||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||||
|
import { Hero } from "../hero/Hero";
|
||||||
import { oops } from "db://oops-framework/core/Oops";
|
import { oops } from "db://oops-framework/core/Oops";
|
||||||
import { UIID } from "../common/config/GameUIConfig";
|
import { UIID } from "../common/config/GameUIConfig";
|
||||||
|
import { mLogger } from "../common/Logger";
|
||||||
|
|
||||||
const {property, ccclass } = _decorator;
|
const {property, ccclass } = _decorator;
|
||||||
|
|
||||||
@@ -22,14 +24,14 @@ export class HInfoComp extends CCComp {
|
|||||||
private hpLabel: Label | null = null;
|
private hpLabel: Label | null = null;
|
||||||
private iconVisualToken: number = 0;
|
private iconVisualToken: number = 0;
|
||||||
private iconHeroUuid: number = 0;
|
private iconHeroUuid: number = 0;
|
||||||
|
private debugMode: boolean = true;
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.cacheLabels();
|
this.cacheLabels();
|
||||||
this.bindEvents();
|
// this.bindEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
this.unbindEvents();
|
// this.unbindEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
bindData(eid: number, model: HeroAttrsComp) {
|
bindData(eid: number, model: HeroAttrsComp) {
|
||||||
@@ -125,16 +127,19 @@ export class HInfoComp extends CCComp {
|
|||||||
[...clips].forEach(clip => anim.removeClip(clip, true));
|
[...clips].forEach(clip => anim.removeClip(clip, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bindEvents() {
|
// private bindEvents() {
|
||||||
this.node.on(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
// this.sell_node?.on(Button.EventType.CLICK, this.onSellHero, this);
|
||||||
}
|
// this.node.on(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
||||||
|
// }
|
||||||
|
|
||||||
private unbindEvents() {
|
// private unbindEvents() {
|
||||||
this.node.off(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
// this.sell_node?.off(Button.EventType.CLICK, this.onSellHero, this);
|
||||||
}
|
// this.node.off(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
||||||
|
// }
|
||||||
|
|
||||||
private onOpenIBox() {
|
private onOpenIBox() {
|
||||||
if (!this.model) return;
|
if (!this.model) return;
|
||||||
|
if (!this.isModelAlive()) return;
|
||||||
const heroUuid = this.model.hero_uuid ?? 0;
|
const heroUuid = this.model.hero_uuid ?? 0;
|
||||||
if (!heroUuid || !HeroInfo[heroUuid]) return;
|
if (!heroUuid || !HeroInfo[heroUuid]) return;
|
||||||
const heroLv = Math.max(1, Math.floor(this.model.lv ?? 1));
|
const heroLv = Math.max(1, Math.floor(this.model.lv ?? 1));
|
||||||
@@ -146,6 +151,18 @@ export class HInfoComp extends CCComp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onSellHero(event?: Event) {
|
||||||
|
if (!this.eid) return;
|
||||||
|
const removed = Hero.removeByEid(this.eid);
|
||||||
|
mLogger.log(this.debugMode, "HInfoComp", "onSellHero", {
|
||||||
|
eid: this.eid,
|
||||||
|
isAlive: this.isModelAlive(),
|
||||||
|
removed
|
||||||
|
});
|
||||||
|
if (!removed) return;
|
||||||
|
oops.gui.remove(UIID.IBox);
|
||||||
|
}
|
||||||
|
|
||||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||||
reset() {
|
reset() {
|
||||||
this.clearIconAnimation(this.icon_node);
|
this.clearIconAnimation(this.icon_node);
|
||||||
|
|||||||
Reference in New Issue
Block a user