feat(技能): 将技能卡释放逻辑移至独立组件并添加UI显示
- 新增 MissSkillsComp 组件,用于管理场景中释放的技能卡 - 将技能卡释放监听从 MissionHeroComp 移至 MissSkillsComp - 新增 SkillBoxComp 组件,负责单个技能卡的表现和触发逻辑 - 在 role_controller.prefab 中添加 miss_skill_node 节点引用 - 技能卡现在会在场景中显示图标和剩余回合信息 - 支持即时技能和持续多回合技能的不同触发机制
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { _decorator, Node, Prefab } from "cc";
|
||||
import { _decorator, Node, Prefab, instantiate } 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 { CardType } from "../common/config/CardSet";
|
||||
import { SkillBoxComp } from "./SkillBoxComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -18,14 +18,35 @@ export class MissSkillsComp extends CCComp {
|
||||
private skill_box: Prefab = null;
|
||||
|
||||
onLoad() {
|
||||
oops.message.on(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
oops.message.off(GameEvent.UseSkillCard, this.onUseSkillCard, this);
|
||||
}
|
||||
|
||||
private onUseSkillCard(event: string, args: any) {
|
||||
const payload = args ?? event;
|
||||
const uuid = Number(payload?.uuid ?? 0);
|
||||
const card_lv = Math.max(1, Math.floor(Number(payload?.card_lv ?? 1)));
|
||||
if (!uuid) return;
|
||||
this.addSkill(uuid, card_lv);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
addSkill(uuid: number, card_lv: number) {
|
||||
if (!this.skill_box) {
|
||||
mLogger.error(this.debugMode, "MissSkillsComp", "skill_box prefab not set");
|
||||
return;
|
||||
}
|
||||
const node = instantiate(this.skill_box);
|
||||
node.parent = this.node;
|
||||
const comp = node.getComponent(SkillBoxComp) || node.addComponent(SkillBoxComp);
|
||||
comp.init(uuid, card_lv);
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user