|
|
@@ -2,6 +2,7 @@ import { _decorator, Component, Node, Prefab, instantiate, Vec3, EventTouch, Vec
|
|
|
import { ConfigManager, WeaponConfig } from '../Core/ConfigManager';
|
|
|
import { SaveDataManager } from '../LevelSystem/SaveDataManager';
|
|
|
import { LevelSessionManager } from '../Core/LevelSessionManager';
|
|
|
+import { BlockTag } from './BlockSelection/BlockTag';
|
|
|
import { sp } from 'cc';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@@ -231,6 +232,7 @@ export class BlockManager extends Component {
|
|
|
|
|
|
// 在kuang下随机生成三个方块
|
|
|
private generateRandomBlocksInKuang() {
|
|
|
+ // 清除kuang区域中的旧方块,但不清除已放置在网格中的方块的标签
|
|
|
this.clearBlocks();
|
|
|
|
|
|
// 检查配置管理器是否可用
|
|
|
@@ -316,6 +318,9 @@ export class BlockManager extends Component {
|
|
|
this.setupBlockWeaponVisual(block, weaponConfig);
|
|
|
|
|
|
this.setupDragEvents(block);
|
|
|
+
|
|
|
+ // 为新生成的方块添加标签
|
|
|
+ BlockTag.addTag(block);
|
|
|
}
|
|
|
|
|
|
this.updateCoinDisplay();
|
|
|
@@ -477,7 +482,14 @@ export class BlockManager extends Component {
|
|
|
const startLocation = this.currentDragBlock['startLocation'];
|
|
|
|
|
|
if (this.isInKuangArea(touchPos)) {
|
|
|
- this.returnBlockToKuang(startLocation);
|
|
|
+ // 检查是否有标签,只有有标签的方块才能放回kuang
|
|
|
+ if (BlockTag.hasTag(this.currentDragBlock)) {
|
|
|
+ this.returnBlockToKuang(startLocation);
|
|
|
+ } else {
|
|
|
+ // 没有标签的方块不能放回kuang,返回原位置
|
|
|
+ console.log(`[BlockManager] 方块 ${this.currentDragBlock.name} 没有标签,不能放回kuang区域`);
|
|
|
+ this.returnBlockToOriginalPosition();
|
|
|
+ }
|
|
|
} else if (this.tryPlaceBlockToGrid(this.currentDragBlock)) {
|
|
|
this.handleSuccessfulPlacement(startLocation);
|
|
|
} else {
|
|
|
@@ -545,6 +557,9 @@ export class BlockManager extends Component {
|
|
|
// 如果游戏已开始,添加锁定视觉提示
|
|
|
if (this.gameStarted) {
|
|
|
this.addLockedVisualHint(this.currentDragBlock);
|
|
|
+
|
|
|
+ // 游戏开始后放置的方块移除标签,不能再放回kuang
|
|
|
+ BlockTag.removeTag(this.currentDragBlock);
|
|
|
}
|
|
|
|
|
|
// 检查并执行合成
|
|
|
@@ -568,6 +583,9 @@ export class BlockManager extends Component {
|
|
|
// 如果游戏已开始,添加锁定视觉提示
|
|
|
if (this.gameStarted) {
|
|
|
this.addLockedVisualHint(this.currentDragBlock);
|
|
|
+
|
|
|
+ // 游戏开始后放置的方块移除标签,不能再放回kuang
|
|
|
+ BlockTag.removeTag(this.currentDragBlock);
|
|
|
}
|
|
|
|
|
|
// 检查并执行合成
|
|
|
@@ -928,6 +946,9 @@ export class BlockManager extends Component {
|
|
|
|
|
|
this.moveBlockToPlacedBlocks(block);
|
|
|
this.addLockedVisualHint(block);
|
|
|
+
|
|
|
+ // 游戏开始后放置的方块移除标签,不能再放回kuang
|
|
|
+ BlockTag.removeTag(block);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -989,7 +1010,6 @@ export class BlockManager extends Component {
|
|
|
}
|
|
|
|
|
|
// 根据武器类型或稀有度选择预制体
|
|
|
- // 这里可以根据实际需求来选择不同的预制体
|
|
|
// 目前简单地随机选择一个预制体
|
|
|
const randomIndex = Math.floor(Math.random() * this.blockPrefabs.length);
|
|
|
return this.blockPrefabs[randomIndex];
|
|
|
@@ -1140,6 +1160,12 @@ export class BlockManager extends Component {
|
|
|
|
|
|
// 刷新方块 - 重新生成三个新的武器方块
|
|
|
public refreshBlocks() {
|
|
|
+ // 移除PlacedBlocks容器中所有方块的标签
|
|
|
+ if (this.placedBlocksContainer && this.placedBlocksContainer.isValid) {
|
|
|
+ BlockTag.removeTagsInContainer(this.placedBlocksContainer);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 生成新的方块
|
|
|
this.generateRandomBlocksInKuang();
|
|
|
}
|
|
|
|