|
@@ -1,15 +1,15 @@
|
|
|
import { _decorator, BoxCollider, Component, find, instantiate, Node, NodePool, Prefab, Quat, random, RigidBody } from 'cc';
|
|
|
-import ch_util from '../ch/ch_util';
|
|
|
-
|
|
|
+import ch_util from '../../ch/ch_util';
|
|
|
+import { gui } from '../../core/ui/ui';
|
|
|
+import { table_idiom } from '../../module_extra/table_ts/table_idiom';
|
|
|
+import { table_level } from '../../module_extra/table_ts/table_level';
|
|
|
+import { Hall } from '../hall/Hall';
|
|
|
+import { UI_Idioms } from '../ui/UI_Idioms/UI_Idioms';
|
|
|
+import { UI_Main } from '../ui/UI_Main/UI_Main';
|
|
|
import { CreateIdiom } from './CreateIdiom';
|
|
|
import { Cube_Infor, Cube_State } from './Cube_Infor';
|
|
|
-import { UI_Idioms } from '../module_game/ui/UI_Idioms/UI_Idioms';
|
|
|
-import { gui } from '../core/ui/ui';
|
|
|
import { GameCtl } from './GameCtl';
|
|
|
-import { UI_Main } from '../module_game/ui/UI_Main/UI_Main';
|
|
|
-import { table_level } from '../module_extra/table_ts/table_level';
|
|
|
-import { Hall } from './Hall';
|
|
|
-import { table_idiom } from '../module_extra/table_ts/table_idiom';
|
|
|
+
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('Container_Manager')
|
|
@@ -36,11 +36,12 @@ export class Container_Manager extends Component {
|
|
|
Cube_Pool: NodePool = new NodePool();
|
|
|
nodeReferences: Node[] = []; // 额外维护的节点引用数组
|
|
|
|
|
|
+ count:number=0;
|
|
|
+
|
|
|
private instantiateCube() {
|
|
|
for (let i = 0; i < this.idioms.length * 2; i++) {
|
|
|
const newCube = instantiate(this.prefab);
|
|
|
newCube.active = true; // 初始时设置为非激活状态
|
|
|
-
|
|
|
// 按顺序为节点赋值文字内容
|
|
|
let idiomIndex = Math.floor(i / 2);
|
|
|
let isPiece1 = i % 2 === 0;
|
|
@@ -49,7 +50,6 @@ export class Container_Manager extends Component {
|
|
|
: this.idioms[idiomIndex].piece_2_word;
|
|
|
|
|
|
console.log("生成第" + i + "个节点:" + newCube.getComponent(Cube_Infor).Text);
|
|
|
-
|
|
|
this.Cube_Pool.put(newCube);
|
|
|
}
|
|
|
}
|
|
@@ -232,7 +232,7 @@ export class Container_Manager extends Component {
|
|
|
|
|
|
console.log("最终选中的成语:", this.idioms); // 打印最终的成语数组
|
|
|
}
|
|
|
-
|
|
|
+ this.count=this.level_config[level].count;
|
|
|
|
|
|
|
|
|
await this.instantiateCube();
|
|
@@ -343,7 +343,7 @@ export class Container_Manager extends Component {
|
|
|
this.recycleCube(node); // 回收到池中
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ this.shufflePool();
|
|
|
// 等待节点移动完成后执行后续逻辑
|
|
|
await this.create_node.nodeMoving();
|
|
|
}
|
|
@@ -362,6 +362,27 @@ export class Container_Manager extends Component {
|
|
|
|
|
|
gui.get(UI_Idioms).all_light_Hide();
|
|
|
}
|
|
|
+
|
|
|
+ private shufflePool() {
|
|
|
+ const poolSize = this.Cube_Pool.size();
|
|
|
+ const tempArray = [];
|
|
|
+
|
|
|
+ // 从池中取出所有节点到临时数组
|
|
|
+ for (let i = 0; i < poolSize; i++) {
|
|
|
+ tempArray.push(this.Cube_Pool.get());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 只打乱部分节点(以 50% 为例,可调整比例)
|
|
|
+ const shuffleCount = Math.ceil(poolSize * 0.5); // 只打乱前 50%
|
|
|
+ for (let i = 0; i < shuffleCount; i++) {
|
|
|
+ const randomIndex = Math.floor(Math.random() * poolSize);
|
|
|
+ [tempArray[i], tempArray[randomIndex]] = [tempArray[randomIndex], tempArray[i]];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 将打乱的节点放回池中
|
|
|
+ tempArray.forEach(cube => this.Cube_Pool.put(cube));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|