Commit 18642d0e authored by unknown's avatar unknown

邻接数组块好了

parent a4390be3
......@@ -49,7 +49,7 @@ export class AdjacentArrayCtr extends Component {
private itemSpaceY = 10;
private itemPosIfoArr: ItemPosIfo[] = [];
private row = 5;
private column = 5;
private column = 6;
private gridIfoArr: GridIfo[] = [];
......@@ -70,12 +70,34 @@ export class AdjacentArrayCtr extends Component {
console.log(`grid被点击`);
console.log(event.target)
let grid = this.findGridInGridArr(<Node>event.target)!;
grid.active = true;
grid.gridItem.active = true;
console.log(`选中格子`);
console.log(grid.gridItem);
grid.pairItem[0].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToSel();
grid.pairItem[1].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToSel();
grid.active = !grid.active;
if (grid.active) {
console.log(`选中格子`);
console.log(grid.gridItem);
//先去掉
let o_gridArr = this.findGridInGridArrWithItem(grid.pairItem[0]);
o_gridArr = o_gridArr.concat(this.findGridInGridArrWithItem(grid.pairItem[1]));
for (let i = 0; i < o_gridArr.length; ++i) {
if(!o_gridArr[i].active) continue;
o_gridArr[i].active = false;
o_gridArr[i].gridItem.active = false;
o_gridArr[i].pairItem[0].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToNor();
o_gridArr[i].pairItem[1].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToNor();
}
grid.gridItem.active = true;
grid.active = true;
grid.pairItem[0].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToSel();
grid.pairItem[1].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToSel();
}
else {
grid.gridItem.active = false;
grid.active = false;
console.log(`选中格子`);
console.log(grid.gridItem);
grid.pairItem[0].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToNor();
grid.pairItem[1].target.getComponent(AdjacentArrayItemCtr)?.setBgSprToNor();
}
}
creAllItem() {
......@@ -158,7 +180,6 @@ export class AdjacentArrayCtr extends Component {
let gridSpr = instantiate(this.gridPre).getComponent(Sprite)!;
gridSpr.node.getComponent(UITransform)!.width = this.itemWidth * 2 + this.itemSpaceX;
gridSpr.node.getComponent(UITransform)!.height = this.itemHeight;
gridSpr.node.layer = 1 << 25;
this.gridArrNode.addChild(gridSpr.node);
gridSpr.node.active = false;
gridSpr.node.setPosition((s_pos.x + e_pos.x) / 2, (s_pos.y + e_pos.y) / 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment