|
|
@@ -677,17 +677,6 @@ export class BlockManager extends Component {
|
|
|
this.blockLocations.set(block, `block${i + 1}`);
|
|
|
this.blocks.push(block);
|
|
|
|
|
|
- // 处理价格显示
|
|
|
- if (priceNodes[i]) {
|
|
|
- this.blockPriceMap.set(block, priceNodes[i]);
|
|
|
- priceNodes[i].active = true;
|
|
|
-
|
|
|
- // 根据武器配置和方块形状设置价格
|
|
|
- this.setBlockPriceByWeaponConfig(block, priceNodes[i]);
|
|
|
- } else {
|
|
|
- console.warn(`Block${i + 1}容器下找不到Price节点`);
|
|
|
- }
|
|
|
-
|
|
|
// 关联Block容器与方块(替代原来的dbNode关联)
|
|
|
this.associateBlockContainerWithBlock(block, blockContainers[i]);
|
|
|
|
|
|
@@ -701,6 +690,17 @@ export class BlockManager extends Component {
|
|
|
// 设置BlockInfo组件信息,传入容器位置信息
|
|
|
this.setupBlockInfo(block, weaponConfig, targetShapeId, blockLocation);
|
|
|
|
|
|
+ // 处理价格显示 - 在BlockInfo设置完成后调用,确保能正确读取shapePrice
|
|
|
+ if (priceNodes[i]) {
|
|
|
+ this.blockPriceMap.set(block, priceNodes[i]);
|
|
|
+ priceNodes[i].active = true;
|
|
|
+
|
|
|
+ // 根据武器配置和方块形状设置价格
|
|
|
+ this.setBlockPriceByWeaponConfig(block, priceNodes[i]);
|
|
|
+ } else {
|
|
|
+ console.warn(`Block${i + 1}容器下找不到Price节点`);
|
|
|
+ }
|
|
|
+
|
|
|
// 为新生成的方块添加标签
|
|
|
BlockTag.addTag(block);
|
|
|
console.log(`[BlockManager] 为方块 ${block.name} 添加标签,UUID: ${block.uuid}`);
|
|
|
@@ -1406,7 +1406,7 @@ export class BlockManager extends Component {
|
|
|
let basePrice: number;
|
|
|
switch (rarity) {
|
|
|
case 'common':
|
|
|
- basePrice = 10;
|
|
|
+ basePrice = 0;
|
|
|
break;
|
|
|
case 'uncommon':
|
|
|
basePrice = 20;
|
|
|
@@ -1419,7 +1419,7 @@ export class BlockManager extends Component {
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- basePrice = 20;
|
|
|
+ basePrice = 0;
|
|
|
}
|
|
|
|
|
|
// 应用便宜技能效果
|
|
|
@@ -1440,36 +1440,17 @@ export class BlockManager extends Component {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 获取方块的武器配置
|
|
|
- const weaponConfig = this.getBlockWeaponConfig(block);
|
|
|
- if (!weaponConfig) {
|
|
|
- // 如果没有武器配置,使用原有的稀有度定价方式
|
|
|
- this.setBlockPriceByRarity(priceNode, 'common');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取方块形状
|
|
|
- const shapeId = this.getBlockShape(block);
|
|
|
- if (!shapeId) {
|
|
|
- // 如果无法获取形状,使用基础价格
|
|
|
- this.setBlockPriceByRarity(priceNode, weaponConfig.rarity || 'common');
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 从武器配置中获取局内金币花费配置
|
|
|
- const inGameCostConfig = weaponConfig.inGameCostConfig;
|
|
|
- if (!inGameCostConfig) {
|
|
|
- // 如果没有局内金币配置,使用原有的稀有度定价方式
|
|
|
- this.setBlockPriceByRarity(priceNode, weaponConfig.rarity || 'common');
|
|
|
+ // 从Node子节点获取BlockInfo组件(新预制体结构)
|
|
|
+ const nodeChild = block.getChildByName('Node');
|
|
|
+ const blockInfo = nodeChild ? nodeChild.getComponent(BlockInfo) : null;
|
|
|
+
|
|
|
+ if (!blockInfo) {
|
|
|
+ label.string = "10";
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- // 根据形状获取价格
|
|
|
- let basePrice = inGameCostConfig.shapeCosts[shapeId];
|
|
|
- if (basePrice === undefined) {
|
|
|
- // 如果没有找到对应形状的价格,使用基础价格
|
|
|
- basePrice = inGameCostConfig.baseCost * this.getBlockGridCount(block);
|
|
|
- }
|
|
|
+
|
|
|
+ // 直接使用BlockInfo的shapePrice,如果为0则使用默认价格10
|
|
|
+ let basePrice = blockInfo.shapePrice > 0 ? blockInfo.shapePrice : 10;
|
|
|
|
|
|
// 应用便宜技能效果
|
|
|
const skillManager = SkillManager.getInstance();
|
|
|
@@ -1483,10 +1464,7 @@ export class BlockManager extends Component {
|
|
|
}
|
|
|
|
|
|
// 计算方块占用的格子数量
|
|
|
- private getBlockGridCount(block: Node): number {
|
|
|
- const parts = this.getBlockParts(block);
|
|
|
- return parts.length;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
// 设置方块的武器外观
|
|
|
private setupBlockWeaponVisual(block: Node, weaponConfig: WeaponConfig, targetShapeId?: string) {
|
|
|
@@ -1525,9 +1503,6 @@ export class BlockManager extends Component {
|
|
|
blockInfo.blockName = weaponConfig.name || block.name;
|
|
|
blockInfo.blockId = weaponConfig.id || weaponConfig.name;
|
|
|
|
|
|
- // 设置武器配置
|
|
|
- blockInfo.setWeaponConfig(weaponConfig);
|
|
|
-
|
|
|
// 设置稀有度
|
|
|
const rarityMap = { 'common': 0, 'uncommon': 1, 'rare': 2, 'epic': 3 };
|
|
|
blockInfo.rarity = rarityMap[weaponConfig.rarity] || 0;
|
|
|
@@ -1547,6 +1522,9 @@ export class BlockManager extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 设置武器配置(在形状ID设置之后,这样可以正确计算形状价格)
|
|
|
+ blockInfo.setWeaponConfig(weaponConfig);
|
|
|
+
|
|
|
// 设置位置信息
|
|
|
blockInfo.currentLocation = blockLocation || 'kuang';
|
|
|
blockInfo.gridPosition = new cc.Vec2(-1, -1);
|
|
|
@@ -2065,28 +2043,37 @@ export class BlockManager extends Component {
|
|
|
if (!weaponConfig) return null;
|
|
|
|
|
|
// 从方块结构推断形状
|
|
|
- return this.inferBlockShapeFromStructure(block);
|
|
|
+ const shapeInfo = this.getBlockShapeInfo(block);
|
|
|
+ return shapeInfo ? shapeInfo.id : 'I';
|
|
|
}
|
|
|
|
|
|
// 获取方块的详细形状信息(包括形状ID和名称)
|
|
|
public getBlockShapeInfo(block: Node): { id: string, name: string, shape: number[][] } | null {
|
|
|
const actualShape = this.extractShapeFromBlock(block);
|
|
|
+ console.log(`[BlockManager] 提取的实际形状矩阵:`, actualShape);
|
|
|
|
|
|
let blockShapes = null;
|
|
|
|
|
|
// 优先使用预加载的配置
|
|
|
if (this.isWeaponsConfigPreloaded && this.preloadedWeaponsConfig) {
|
|
|
blockShapes = this.preloadedWeaponsConfig.blockSizes;
|
|
|
+ console.log(`[BlockManager] 使用预加载配置,形状数量: ${blockShapes ? blockShapes.length : 0}`);
|
|
|
} else {
|
|
|
// 回退到ConfigManager
|
|
|
blockShapes = this.configManager.getBlockShapes();
|
|
|
+ console.log(`[BlockManager] 使用ConfigManager,形状数量: ${blockShapes ? blockShapes.length : 0}`);
|
|
|
}
|
|
|
|
|
|
- if (!blockShapes) return null;
|
|
|
+ if (!blockShapes) {
|
|
|
+ console.log(`[BlockManager] 警告:无法获取形状配置`);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
// 寻找匹配的形状配置
|
|
|
for (const shapeConfig of blockShapes) {
|
|
|
+ console.log(`[BlockManager] 比较形状 ${shapeConfig.id}:`, shapeConfig.shape);
|
|
|
if (this.compareShapeMatrices(actualShape, shapeConfig.shape)) {
|
|
|
+ console.log(`[BlockManager] 找到匹配形状: ${shapeConfig.id}`);
|
|
|
return {
|
|
|
id: shapeConfig.id,
|
|
|
name: shapeConfig.name,
|
|
|
@@ -2095,6 +2082,7 @@ export class BlockManager extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ console.log(`[BlockManager] 警告:未找到匹配的形状,使用默认形状 I`);
|
|
|
return null;
|
|
|
}
|
|
|
|