refactor: 拆分技能卡配置到独立文件,优化抽卡逻辑
1. 新建SCardSet.ts单独管理技能卡池配置,将原CardSet.ts中的技能卡数据迁移 2. 重构多处业务代码,从SkillCardList而非CardPoolList获取技能卡配置 3. 简化技能卡抽卡逻辑,新增drawSkillCards工具函数统一处理抽卡 4. 修复TalentsComp中计算contentHeight的小语法问题 5. 新增技能卡商店显隐控制功能
This commit is contained in:
@@ -15,7 +15,8 @@ import { _decorator, instantiate, Node, Prefab, UITransform } 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 { mLogger } from "../common/Logger";
|
||||
import { CardPoolList, CardType, CardConfig } from "../common/config/CardSet";
|
||||
import { CardConfig } from "../common/config/CardSet";
|
||||
import { SkillCardList } from "../common/config/SCardSet";
|
||||
import { TalentItemComp } from "./TalentItemComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -51,7 +52,7 @@ export class TalentsComp extends CCComp {
|
||||
// 第一次:实例化所有子节点
|
||||
if (!this.rendered) {
|
||||
// 获取所有天赋(技能卡)并按 wave 和 uuid 排序
|
||||
this.cachedConfigs = CardPoolList.filter(card => card.type === CardType.Skill)
|
||||
this.cachedConfigs = [...SkillCardList]
|
||||
.sort((a, b) => {
|
||||
const waveA = a.wave || 1;
|
||||
const waveB = b.wave || 1;
|
||||
@@ -73,8 +74,8 @@ export class TalentsComp extends CCComp {
|
||||
// 默认底高 1000,每行 3 个天赋信息卡,每张卡高 270,行间距 15
|
||||
const totalCount = this.cachedConfigs.length;
|
||||
const rows = Math.ceil(totalCount / 3);
|
||||
const contentHeight = Math.max(1000, rows * 270 + (rows > 0 ? (rows - 1) * 15 : 0+50));
|
||||
|
||||
const contentHeight = Math.max(1000, rows * 270 + (rows > 0 ? (rows - 1) * 15 : 0 + 50));
|
||||
|
||||
const uiTransform = this.talents_content.getComponent(UITransform);
|
||||
if (uiTransform) {
|
||||
uiTransform.height = contentHeight;
|
||||
|
||||
Reference in New Issue
Block a user