- 在 GameSet 中新增技能卡牌释放起始坐标常量 - 卡牌使用组件增加技能卡释放事件分发 - 任务英雄组件监听技能卡事件并转发给技能施放系统 - 卡牌组件支持技能卡牌的显示和等级星级 - 卡牌配置中添加技能卡牌池和对应的配置信息 - 技能施放系统扩展以支持卡牌技能的直接触发
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import { mLogger } from "../common/Logger";
|
|
import { _decorator } 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 { oops } from "db://oops-framework/core/Oops";
|
|
import { GameEvent } from "../common/config/GameEvent";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
interface CardUsePayload {
|
|
uuid: number
|
|
type: CardType
|
|
cost: number
|
|
slotName?: string
|
|
}
|
|
|
|
/** 视图层对象 */
|
|
@ccclass('CardUseComp')
|
|
@ecs.register('CardUseComp', false)
|
|
export class CardUseComp extends CCComp {
|
|
private debugMode: boolean = true;
|
|
private useCount: number = 0;
|
|
|
|
onLoad() {
|
|
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
onCardUsed(payload: CardUsePayload) {
|
|
this.useCount += 1;
|
|
mLogger.log(this.debugMode, "CardUseComp", "onCardUsed", {
|
|
useCount: this.useCount,
|
|
...payload
|
|
});
|
|
this.executeCardEffectEntry(payload);
|
|
}
|
|
|
|
private executeCardEffectEntry(payload: CardUsePayload) {
|
|
const effectTag = this.getEffectEntryTag(payload);
|
|
mLogger.log(this.debugMode, "CardUseComp", "executeCardEffectEntry", payload);
|
|
mLogger.log(this.debugMode, "CardUseComp", "effect entry tag", effectTag);
|
|
}
|
|
|
|
private getEffectEntryTag(used:CardUsePayload): string {
|
|
switch (used.type) {
|
|
case CardType.Hero:
|
|
oops.message.dispatchEvent(GameEvent.CallHero, used);
|
|
return "hero";
|
|
case CardType.Skill:
|
|
oops.message.dispatchEvent(GameEvent.UseSkillCard, used);
|
|
return "skill";
|
|
case CardType.SpecialUpgrade:
|
|
case CardType.SpecialRefresh:
|
|
oops.message.dispatchEvent(GameEvent.UseSpecialCard, used);
|
|
return "special";
|
|
default:
|
|
return "unknown";
|
|
}
|
|
}
|
|
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
}
|