feat: 新增英雄出售功能并优化UI交互
- 在 Hero 类中添加 removeByEid 静态方法,用于安全移除英雄实体 - 在 HInfoComp 中集成出售按钮逻辑,点击可移除对应英雄并关闭信息面板 - 为 card.prefab 和 hnode.prefab 添加召唤/出售按钮及相关UI组件 - 调整 role_controller.prefab 面板高度并禁用部分组件 - 移除未使用的 hit-flash-white 场景资源文件 - 暂时注释 CardComp 中的触摸事件绑定以进行调试
This commit is contained in:
@@ -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 { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { mLogger } from "../common/Logger";
|
||||
|
||||
const {property, ccclass } = _decorator;
|
||||
|
||||
@@ -22,14 +24,14 @@ export class HInfoComp extends CCComp {
|
||||
private hpLabel: Label | null = null;
|
||||
private iconVisualToken: number = 0;
|
||||
private iconHeroUuid: number = 0;
|
||||
|
||||
private debugMode: boolean = true;
|
||||
onLoad() {
|
||||
this.cacheLabels();
|
||||
this.bindEvents();
|
||||
// this.bindEvents();
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.unbindEvents();
|
||||
// this.unbindEvents();
|
||||
}
|
||||
|
||||
bindData(eid: number, model: HeroAttrsComp) {
|
||||
@@ -125,16 +127,19 @@ export class HInfoComp extends CCComp {
|
||||
[...clips].forEach(clip => anim.removeClip(clip, true));
|
||||
}
|
||||
|
||||
private bindEvents() {
|
||||
this.node.on(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
||||
}
|
||||
// private bindEvents() {
|
||||
// this.sell_node?.on(Button.EventType.CLICK, this.onSellHero, this);
|
||||
// this.node.on(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
||||
// }
|
||||
|
||||
private unbindEvents() {
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
||||
}
|
||||
// private unbindEvents() {
|
||||
// this.sell_node?.off(Button.EventType.CLICK, this.onSellHero, this);
|
||||
// this.node.off(NodeEventType.TOUCH_END, this.onOpenIBox, this);
|
||||
// }
|
||||
|
||||
private onOpenIBox() {
|
||||
if (!this.model) return;
|
||||
if (!this.isModelAlive()) return;
|
||||
const heroUuid = this.model.hero_uuid ?? 0;
|
||||
if (!heroUuid || !HeroInfo[heroUuid]) return;
|
||||
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) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.clearIconAnimation(this.icon_node);
|
||||
|
||||
Reference in New Issue
Block a user