chore: 清理未使用的组件文件及更新预制体引用

- 删除多个未使用的组件文件及其meta文件,包括HeroAttrsSystem.ts、TalComp.ts、MGetComp.ts、HInfoComp.ts、SCDSystem.ts、HeroSkills.ts、MissionCardComp.ts、MissionGetsComp.ts、TalSet.ts、CardSet.ts
- 新增SCastSystem.ts组件文件
- 更新角色控制器预制体结构,修复节点引用问题
- 移除无效的组件绑定,优化界面节点层次结构
This commit is contained in:
panw
2026-03-12 10:08:14 +08:00
parent 5d09b3361e
commit 01bff64561
9 changed files with 972 additions and 2982 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +0,0 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "d63b992b-cdaf-4e5a-8472-866c0038857a",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "get"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "7ddd121f-1918-4eed-ad9b-ebaa2fe5b606",
"uuid": "ed36ef97-521c-4570-ba81-b6ec2e6b6eeb",
"files": [],
"subMetas": {},
"userData": {}

View File

@@ -99,13 +99,9 @@ export class HInfoComp extends CCComp {
this.type_node.getComponent(Label).string=HTypeName[HeroInfo[uuid].type]
this.ap_node.getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
this.hp_node.getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
this.def_node.getChildByName("num").getComponent(Label).string=HeroInfo[uuid].def.toString()
this.mp_node.getChildByName("num").getComponent(Label).string=HeroInfo[uuid].mp.toString()
let bar_num=getPreAttr(uuid)
this.ap_node.getChildByName("bar").getComponent(ProgressBar).progress=bar_num.ap
this.hp_node.getChildByName("bar").getComponent(ProgressBar).progress=bar_num.hp
this.def_node.getChildByName("bar").getComponent(ProgressBar).progress=bar_num.def
this.mp_node.getChildByName("bar").getComponent(ProgressBar).progress=bar_num.mp
// 更新技能图标
this.updateSkillIcon(this.skill1_node, skill1.icon);
@@ -255,7 +251,6 @@ export class HInfoComp extends CCComp {
// 更新数据
this.h_uuid = nextHero;
smc.updateFihgtHero(nextHero)
this.update_data(nextHero);
// 执行平滑移动动画
this.moveHeroesRight();
@@ -275,7 +270,6 @@ export class HInfoComp extends CCComp {
// 更新数据
this.h_uuid = prevHero;
smc.updateFihgtHero(prevHero)
this.update_data(prevHero);
// 执行平滑移动动画
this.moveHeroesLeft();
@@ -304,11 +298,7 @@ export class HInfoComp extends CCComp {
this.show_lock()
this.close_buy()
}
start_mission() {
mLogger.log(this.debugMode, 'HInfoComp', "start_mission")
oops.message.dispatchEvent(GameEvent.MissionStart, {})
this.node.active=false;
}
moveHeroesLeft() {
// 取消前一个待处理的异步操作
if (this.moveTimeoutId !== null) {

View File

@@ -1,30 +0,0 @@
import { _decorator, Node, Label } 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MGetsCompComp')
@ecs.register('MGetsComp', false)
export class MGetsCompComp extends CCComp {
get_uuid:number=0;
get_num:number=0;
start() {
}
onDestroy() {
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -6,14 +6,8 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { GameEvent } from "../common/config/GameEvent";
import { smc } from "../common/SingletonModuleComp";
import { CardType, FightSet, CardKind } from "../common/config/GameSet";
import { getCardOptions, ICardInfo } from "../common/config/CardSet";
import { TalComp } from "../hero/TalComp";
import { HeroSkillsComp } from "../hero/HeroSkills";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { BuffConf } from "../common/config/SkillSet";
import { BType } from "../common/config/HeroAttrs";
import { AttrCards, PotionCards } from "../common/config/AttrSet";
import { AttrsType } from "../common/config/HeroAttrs";
import { HeroMasterComp } from "../hero/HeroMasterComp";
@@ -49,10 +43,10 @@ export class MissionCardComp extends CCComp {
@property(Node)
noStop: Node = null!
card1_data: ICardInfo = null!
card2_data: ICardInfo = null!
card3_data: ICardInfo = null!
card4_data: ICardInfo = null!
// card1_data: ICardInfo = null!
// card2_data: ICardInfo = null!
// card3_data: ICardInfo = null!
// card4_data: ICardInfo = null!
// 当前卡片类型 (用于特殊获取模式)
curCardType: CardType | null = null;
@@ -271,22 +265,22 @@ export class MissionCardComp extends CCComp {
// 使用 CardSet 的 getCardOptions 获取卡牌
// 这里我们要获取 4 张卡牌
const options = getCardOptions(level, 4, [], forcedType, preferredAttrs);
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 获取到的卡牌选项: ${JSON.stringify(options)}`);
// 更新卡片数据
if (options.length > 0) this.updateCardData(1, options[0]);
if (options.length > 1) this.updateCardData(2, options[1]);
if (options.length > 2) this.updateCardData(3, options[2]);
if (options.length > 3) this.updateCardData(4, options[3]);
// const options = getCardOptions(level, 4, [], forcedType, preferredAttrs);
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 获取到的卡牌选项: ${JSON.stringify(options)}`);
// // 更新卡片数据
// if (options.length > 0) this.updateCardData(1, options[0]);
// if (options.length > 1) this.updateCardData(2, options[1]);
// if (options.length > 2) this.updateCardData(3, options[2]);
// if (options.length > 3) this.updateCardData(4, options[3]);
// 如果获取不足4张隐藏多余的卡片节点 (UI可能需要处理空数据)
if (options.length < 4 && this.card4) this.card4.active = false;
if (options.length < 3 && this.card3) this.card3.active = false;
if (options.length < 2 && this.card2) this.card2.active = false;
if (options.length < 1 && this.card1) this.card1.active = false;
// // 如果获取不足4张隐藏多余的卡片节点 (UI可能需要处理空数据)
// if (options.length < 4 && this.card4) this.card4.active = false;
// if (options.length < 3 && this.card3) this.card3.active = false;
// if (options.length < 2 && this.card2) this.card2.active = false;
// if (options.length < 1 && this.card1) this.card1.active = false;
}
updateCardInfo(card:Node, data: ICardInfo){
updateCardInfo(card:Node, data: any){
if(!card) return
card.active = true;
// 隐藏选中状态
@@ -405,7 +399,7 @@ export class MissionCardComp extends CCComp {
}
}
updateCardData(index: number, data: ICardInfo) {
updateCardData(index: number, data: any) {
// 使用动态属性访问
(this as any)[`card${index}_data`] = data;
this.updateCardInfo((this as any)[`card${index}`], data);
@@ -418,7 +412,7 @@ export class MissionCardComp extends CCComp {
if (this.hasSelected) return;
// 动态获取数据和节点
let selectedData: ICardInfo = (this as any)[`card${_index}_data`];
let selectedData: any;
let selectedCardNode: Node | null = (this as any)[`card${_index}`];
if (selectedData && selectedCardNode) {
@@ -446,126 +440,126 @@ export class MissionCardComp extends CCComp {
.to(0.1, { scale: new Vec3(1.1, 1.1, 1.1) })
.to(0.1, { scale: new Vec3(1, 1, 1) })
.delay(0.5)
.call(() => {
// 使用 HeroMasterComp 查找主角实体
// @ts-ignore
const entities = ecs.query(ecs.allOf(HeroMasterComp));
let role = entities.length > 0 ? entities[0] : null;
// .call(() => {
// // 使用 HeroMasterComp 查找主角实体
// // @ts-ignore
// const entities = ecs.query(ecs.allOf(HeroMasterComp));
// let role = entities.length > 0 ? entities[0] : null;
if (!role) {
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 未找到挂载 HeroMasterComp 的主角实体`);
} else {
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 成功定位主角实体: ${role.eid}`);
}
// if (!role) {
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 未找到挂载 HeroMasterComp 的主角实体`);
// } else {
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 成功定位主角实体: ${role.eid}`);
// }
if (role) {
switch (selectedData.type) {
case CardType.Talent:
smc.addTalentRecord(selectedData.uuid);
// 直接调用 TalComp 添加天赋
const talComp = role.get(TalComp);
if (talComp) {
const beforeCount = Object.keys(talComp.Tals).length;
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Talent Before: Count=${beforeCount}, Tals=${JSON.stringify(talComp.Tals)}`);
talComp.addTal(selectedData.uuid);
const afterCount = Object.keys(talComp.Tals).length;
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Talent After: Count=${afterCount}, Added=${selectedData.uuid}, Tals=${JSON.stringify(talComp.Tals)}`);
}
break;
case CardType.Skill:
smc.addSkillRecord(selectedData.uuid);
// 直接调用 HeroSkillsComp 添加技能
const skillComp = role.get(HeroSkillsComp);
if (skillComp) {
const beforeCount = Object.keys(skillComp.skills).length;
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Skill Before: Count=${beforeCount}, Skills=${JSON.stringify(skillComp.skills)}`);
skillComp.addSkill(selectedData.uuid);
const afterCount = Object.keys(skillComp.skills).length;
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Skill After: Count=${afterCount}, Added=${selectedData.uuid}, Skills=${JSON.stringify(skillComp.skills)}`);
}
break;
case CardType.Partner:
// 伙伴是召唤新实体,依然适合用事件,或者直接调用 summon 方法
oops.message.dispatchEvent(GameEvent.CallFriend, { uuid: selectedData.uuid });
break;
case CardType.Potion:
// 药水直接作用于 HeroAttrsComp
const attrsComp = role.get(HeroAttrsComp);
if (attrsComp) {
const potion = PotionCards[selectedData.uuid];
if (potion) {
const beforeVal = attrsComp.Attrs[potion.attr] || 0;
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Potion Before: Attr[${potion.attr}]=${beforeVal}, Attrs=${JSON.stringify(attrsComp.Attrs)}`);
// if (role) {
// switch (selectedData.type) {
// case CardType.Talent:
// smc.addTalentRecord(selectedData.uuid);
// // 直接调用 TalComp 添加天赋
// const talComp = role.get(TalComp);
// if (talComp) {
// const beforeCount = Object.keys(talComp.Tals).length;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Talent Before: Count=${beforeCount}, Tals=${JSON.stringify(talComp.Tals)}`);
// talComp.addTal(selectedData.uuid);
// const afterCount = Object.keys(talComp.Tals).length;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Talent After: Count=${afterCount}, Added=${selectedData.uuid}, Tals=${JSON.stringify(talComp.Tals)}`);
// }
// break;
// case CardType.Skill:
// smc.addSkillRecord(selectedData.uuid);
// // 直接调用 HeroSkillsComp 添加技能
// const skillComp = role.get(HeroSkillsComp);
// if (skillComp) {
// const beforeCount = Object.keys(skillComp.skills).length;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Skill Before: Count=${beforeCount}, Skills=${JSON.stringify(skillComp.skills)}`);
// skillComp.addSkill(selectedData.uuid);
// const afterCount = Object.keys(skillComp.skills).length;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Skill After: Count=${afterCount}, Added=${selectedData.uuid}, Skills=${JSON.stringify(skillComp.skills)}`);
// }
// break;
// case CardType.Partner:
// // 伙伴是召唤新实体,依然适合用事件,或者直接调用 summon 方法
// oops.message.dispatchEvent(GameEvent.CallFriend, { uuid: selectedData.uuid });
// break;
// case CardType.Potion:
// // 药水直接作用于 HeroAttrsComp
// const attrsComp = role.get(HeroAttrsComp);
// if (attrsComp) {
// const potion = PotionCards[selectedData.uuid];
// if (potion) {
// const beforeVal = attrsComp.Attrs[potion.attr] || 0;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Potion Before: Attr[${potion.attr}]=${beforeVal}, Attrs=${JSON.stringify(attrsComp.Attrs)}`);
const buffConf: BuffConf = {
buff: potion.attr,
value: potion.value,
BType: BType.RATIO,
time: potion.duration,
chance: 1,
};
attrsComp.addBuff(buffConf);
smc.updateHeroInfo(attrsComp);
// const buffConf: BuffConf = {
// buff: potion.attr,
// value: potion.value,
// BType: BType.RATIO,
// time: potion.duration,
// chance: 1,
// };
// attrsComp.addBuff(buffConf);
// smc.updateHeroInfo(attrsComp);
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Potion Applied: ${potion.desc}, Value=${potion.value}, Attrs=${JSON.stringify(attrsComp.Attrs)}`);
oops.gui.toast(potion.desc);
}
}
break;
case CardType.Attr:
// 属性卡:使用 addBuff 添加永久属性加成
const attrCard = AttrCards[selectedData.uuid];
if (attrCard) {
const attrsComp = role.get(HeroAttrsComp);
if (attrsComp) {
// 记录变更前状态
const roleBefore = attrsComp.Attrs[attrCard.attr] || 0;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Potion Applied: ${potion.desc}, Value=${potion.value}, Attrs=${JSON.stringify(attrsComp.Attrs)}`);
// oops.gui.toast(potion.desc);
// }
// }
// break;
// case CardType.Attr:
// // 属性卡:使用 addBuff 添加永久属性加成
// const attrCard = AttrCards[selectedData.uuid];
// if (attrCard) {
// const attrsComp = role.get(HeroAttrsComp);
// if (attrsComp) {
// // 记录变更前状态
// const roleBefore = attrsComp.Attrs[attrCard.attr] || 0;
// 根据属性类型决定 Buff 类型
// 如果属性本身是 RATIO 型如暴击率AttrCards 中的值如2应该作为 VALUE 添加(因为 recalculateSingleAttr 会把 VALUE 和 RATIO 相加)
// 但如果属性本身是 VALUE 型如攻击力AttrCards 中的值是直接加数值,也应该作为 VALUE 添加
// 结论无论属性类型如何AttrCards 中的配置都是"增加的点数",所以统一使用 BType.VALUE
// 修正:虽然 AttrsType 定义了属性本身的类型,但在 addBuff 中BType.VALUE 表示"加法叠加"BType.RATIO 表示"乘法叠加"
// 对于数值型属性如攻击力BType.VALUE 是 +10BType.RATIO 是 +10%
// 对于百分比型属性如暴击率BType.VALUE 是 +2(%)BType.RATIO 是 +2%(即 *1.02,通常不这么用)
// 所以AttrCards 配置的值应当被视为"绝对值增量",对应 BType.VALUE
// // 根据属性类型决定 Buff 类型
// // 如果属性本身是 RATIO 型如暴击率AttrCards 中的值如2应该作为 VALUE 添加(因为 recalculateSingleAttr 会把 VALUE 和 RATIO 相加)
// // 但如果属性本身是 VALUE 型如攻击力AttrCards 中的值是直接加数值,也应该作为 VALUE 添加
// // 结论无论属性类型如何AttrCards 中的配置都是"增加的点数",所以统一使用 BType.VALUE
// // 修正:虽然 AttrsType 定义了属性本身的类型,但在 addBuff 中BType.VALUE 表示"加法叠加"BType.RATIO 表示"乘法叠加"
// // 对于数值型属性如攻击力BType.VALUE 是 +10BType.RATIO 是 +10%
// // 对于百分比型属性如暴击率BType.VALUE 是 +2(%)BType.RATIO 是 +2%(即 *1.02,通常不这么用)
// // 所以AttrCards 配置的值应当被视为"绝对值增量",对应 BType.VALUE
// 构造永久 Buff (time: 0)
const buffConf: BuffConf = {
buff: attrCard.attr,
value: attrCard.value,
BType: BType.RATIO, // 始终使用 VALUE 类型,代表数值/点数叠加
time: 0,
chance: 1,
};
// // 构造永久 Buff (time: 0)
// const buffConf: BuffConf = {
// buff: attrCard.attr,
// value: attrCard.value,
// BType: BType.RATIO, // 始终使用 VALUE 类型,代表数值/点数叠加
// time: 0,
// chance: 1,
// };
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Adding Buff: Attr=${attrCard.attr}, Val=${attrCard.value}, Type=VALUE`);
attrsComp.addBuff(buffConf);
// addBuff 内部会自动调用 recalculateSingleAttr 和 updateHeroInfo
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Adding Buff: Attr=${attrCard.attr}, Val=${attrCard.value}, Type=VALUE`);
// attrsComp.addBuff(buffConf);
// // addBuff 内部会自动调用 recalculateSingleAttr 和 updateHeroInfo
const roleAfter = attrsComp.Attrs[attrCard.attr] || 0;
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Attr After: Hero=${roleAfter} (Change: ${roleAfter - roleBefore})`);
// const roleAfter = attrsComp.Attrs[attrCard.attr] || 0;
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] Attr After: Hero=${roleAfter} (Change: ${roleAfter - roleBefore})`);
oops.gui.toast(attrCard.desc);
}
} else {
mLogger.warn(this.debugMode, 'MissionCard', `[MissionCard] 未找到属性卡配置: UUID=${selectedData.uuid}`);
}
break;
}
} else {
mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 主角实体无效,无法应用卡牌效果`);
}
// oops.gui.toast(attrCard.desc);
// }
// } else {
// mLogger.warn(this.debugMode, 'MissionCard', `[MissionCard] 未找到属性卡配置: UUID=${selectedData.uuid}`);
// }
// break;
// }
// } else {
// mLogger.log(this.debugMode, 'MissionCard', `[MissionCard] 主角实体无效,无法应用卡牌效果`);
// }
// 记录已获取的卡牌
oops.message.dispatchEvent(GameEvent.UpdateMissionGet, {
uuid: selectedData.uuid,
icon: selectedData.icon,
kind: selectedData.kind
});
// // 记录已获取的卡牌
// oops.message.dispatchEvent(GameEvent.UpdateMissionGet, {
// uuid: selectedData.uuid,
// icon: selectedData.icon,
// kind: selectedData.kind
// });
this.close();
})
// this.close();
// })
.start();
}
}

View File

@@ -17,7 +17,6 @@ export class MissionHomeComp extends CCComp {
protected onLoad(): void {
this.on(GameEvent.MissionEnd,this.mission_end,this)
this.on(GameEvent.MissionStart,this.mission_start,this)
}
/** 视图层逻辑代码分离演示 */
start() {
@@ -29,15 +28,17 @@ export class MissionHomeComp extends CCComp {
}
start_mission() {
mLogger.log(this.debugMode, 'MissionHomeComp', "start_mission")
oops.message.dispatchEvent(GameEvent.MissionStart, {})
this.node.active=false;
}
mission_end(){
mLogger.log(this.debugMode, 'MissionHomeComp', "[MissionHomeComp]=>mission_end")
this.home_active()
}
mission_start(){
this.node.active=false
}
home_active(){
this.uodate_data()
this.node.active=true