我智商爆棚
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

104 lines
3.8 KiB

import ZhuangbanBIconNode from "./ZhuangbanBIconNode";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ZhuangbanBIconList extends cc.Component {
@property(cc.Node)
zhuangbanIconNode: cc.Node = null;
@property(cc.Node)
content: cc.Node = null;
start() {
this.zhuangbanIconNode.active = false;
}
setZhuangbanData(zhuangbanList: any, checkListNode: cc.Node, targetNodeList: cc.Node[]) {
let zhuangbanData: Map<string, any> = new Map();
let checkNodeList = checkListNode.children;
let zhuangbanIconList: any[] = zhuangbanList.zhuangbanIconList;
for (let arr = 0; arr < zhuangbanIconList.length; arr++) {
let checkNodeArray = [];
if (checkNodeList[arr].children.length > 0) {
checkNodeArray = checkNodeList[arr].children;
for (let index = 0; index < checkNodeArray.length; index++) {
checkNodeArray[index].attr({
targetNode: targetNodeList[arr].children[index]
});
console.log("++++++++++++++", checkNodeArray[index].name);
}
} else {
checkNodeList[arr].attr({
targetNode: targetNodeList[arr]
});
checkNodeArray.push(checkNodeList[arr]);
}
let zhuangbanIconNode = cc.instantiate(this.zhuangbanIconNode);
zhuangbanIconNode.active = true;
this.content.addChild(zhuangbanIconNode);
let data_ = {
id: zhuangbanIconList[arr].id,
url: zhuangbanIconList[arr].url,
checkNodeArray: checkNodeArray,
hechengData: null,
zhuangbanIconNode: zhuangbanIconNode,
};
zhuangbanData.set(data_.id, data_);
}
let hechengIconList: any[] = zhuangbanList.hechengIconList;
for (let arr = 0; arr < hechengIconList.length; arr++) {
let checkNodeArray = [];
let arr1 = zhuangbanIconList.length + arr;
if (checkNodeList[arr1].children.length > 0) {
checkNodeArray = checkNodeList[arr1].children;
for (let index = 0; index < checkNodeArray.length; index++) {
checkNodeArray[index].attr({
targetNode: targetNodeList[arr1].children[index]
});
}
} else {
checkNodeList[arr1].attr({
targetNode: targetNodeList[arr1]
});
checkNodeArray.push(checkNodeList[arr1]);
}
let hechengData = {
id: hechengIconList[arr].id,
url: hechengIconList[arr].url,
checkNodeArray: checkNodeArray,
hechengData: null,
};
for (const id of hechengIconList[arr].idList) {
zhuangbanData.get(id).hechengData = hechengData;
for (const id1 of hechengIconList[arr].idList) {
if (id != id1) {
zhuangbanData.get(id).checkNodeArray.push(zhuangbanData.get(id1).zhuangbanIconNode);
}
}
}
}
zhuangbanData.forEach((value) => {
let scr: ZhuangbanBIconNode = value.zhuangbanIconNode.getComponent('ZhuangbanBIconNode')
scr.setTouchNodeIcon(value);
})
for (let index = 0; index < this.content.children.length; index++) {
let aInt = Math.trunc(Math.random() * this.content.children.length);
let random = this.content.children[aInt];
this.content.children[aInt] = this.content.children[index];
this.content.children[index] = random;
}
}
// update (dt) {}
}