示例#1
0
 public void seat(Cell cell)
 {
     if(col)col.enabled=true;
     tra.position=cell.tra.position;
     sur="set";
     pick=null;
     if(this.cell)this.cell.collider.enabled=true;
     this.cell=cell;
     cell.collider.enabled=false;
     checkCircuit();
 }
示例#2
0
 void Start()
 {
     if(gridCell){
     float ww=gridCell.cellWidth;
     float hh=gridCell.cellHeight;
     posesNeighbor=new Vector3[4];
     posesNeighbor[0]=new Vector3(0,hh,0);
     posesNeighbor[1]=new Vector3(ww,0,0);
     posesNeighbor[2]=new Vector3(0,-hh,0);
     posesNeighbor[3]=new Vector3(-ww,0,0);
     }
     pipes.Add(this);
     if(isSource)sources.Add(this);
     col=collider;
     posOrin=tra.position;
     Collider colNearest=null;
     foreach(Collider ccc in Physics.OverlapSphere(tra.position,radiusSnapToNearestCell)){
     Cell cc=ccc.GetComponent<Cell>();
     if(!cc)continue;
     if(!colNearest||(ccc.transform.position-tra.position).magnitude<(colNearest.transform.position-tra.position).magnitude){}
     else continue;
     colNearest=ccc;
     cell=cc;
     }
     if(cell){
     seat(cell);
     posOrin=tra.position;
     isFixed=true;
     }
 }