void FindName(string brickname) { for (int i = 0; i < BrickDS.transform.childCount; i++) { if (BrickDS.transform.GetChild(i).name == ("DS_" + brickname)) { DS_data scp = BrickDS.transform.GetChild(i).GetComponent <DS_data>(); leftname = scp.left; rightname = scp.right; } } }
void FindYuzuBrick() { float distance = 10000; int index = -1; int DS_length = BrickDS.transform.childCount; for (int i = 0; i < DS_length; i++) //how many Chilhren of DS_Structure { DS_data loc = BrickDS.transform.GetChild(i).GetComponent <DS_data>(); GameObject tempobject = GameObject.Find(loc.DSname); //Find the name(loc.DSname) of gameobject in this project float dd = Vector3.Distance(transform.position, tempobject.transform.position); if (distance > dd) { distance = dd; index = i; } } locDS = BrickDS.transform.GetChild(index).GetComponent <DS_data>(); locobject = GameObject.Find(locDS.DSname); }
void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { FindYuzuBrick(); //Find the brick under yuzu destname = hit.collider.gameObject.name; for (int i = 0; i < BrickDS.transform.childCount; i++) { DS_data tempD = BrickDS.transform.GetChild(i).GetComponent <DS_data>(); if (tempD.DSname == destname) { destobject = GameObject.Find(destname); } } } } FindNode(); }
/*void FindYuzu(){ * for (int i = 0; i<BrickDS.transform.childCount; i++) { * DS_data loc = BrickDS.transform.GetChild (i).GetComponent<DS_data>(); * * for(int j=0; j<pathdata.transform.childCount; j++){ * Transform pathChild = pathdata.transform.GetChild(j); * for(int k=0; k<pathChild.transform.childCount; k++){ * if (loc.DSname == pathChild.name) * loctran = pathChild.transform; * else if (loc.DSname == pathChild.transform.GetChild(k).name) * loctran = pathChild.transform.GetChild(k).transform; * } * } * } * }*/ void FindYuzu() { int DS_length = BrickDS.transform.childCount; float[] dis = new float[DS_length]; for (int i = 0; i < DS_length; i++) //how many Chilhren of DS_Structure { DS_data loc = BrickDS.transform.GetChild(i).GetComponent <DS_data>(); tempobject = GameObject.Find(loc.DSname); //Find the name(loc.DSname) of gameobject in this project dis[i] = Vector3.Distance(transform.position, tempobject.transform.position); } float min = dis [0]; for (int j = 0; j < DS_length; j++) { if (dis[j] < min) { min = dis[j]; locobject = GameObject.Find(BrickDS.transform.GetChild(j).GetComponent <DS_data>().DSname); } //if(dis[j]>max) max=dis[j]; } }
string FindNext(string FromDir, string Dest, string From, string Neighbor) { GameObject ObjectNei = GameObject.Find("DS_" + Neighbor); DS_data DSNeig = ObjectNei.GetComponent <DS_data> (); if (From == Dest) { return(Dest); } else if (Neighbor == Dest) { return(From + "," + Neighbor); } else if (From == "0") { return("GG"); } else { if (FromDir == "R") { string abc, tabc; if (DSNeig.left == Dest) { return(From + "," + Neighbor + "," + Dest); } else if (DSNeig.left != "0" && DSNeig.left != From) { abc = FindNext("R", Dest, DSNeig.DSname, DSNeig.left); if (abc == "GG") { return("GG"); } else { tabc = From + "," + abc; return(tabc); } } } if (FromDir == "L") { string efg, tefg; if (DSNeig.right == Dest) { return(From + "," + Neighbor + "," + Dest); } else if (DSNeig.right != "0" && DSNeig.right != From) { efg = FindNext("L", Dest, DSNeig.DSname, DSNeig.right); if (efg == "GG") { return("GG"); } else { tefg = From + "," + efg; return(tefg); } } } } return("GG"); }
private void DetailsShow(Query.single_record record) { List <data_detailSource> result = new List <data_detailSource>(); int len = record.result.Count; if (record.test_Device == "DS_800" || record.test_Device == "DS_400") { PL_data.Visibility = Visibility.Collapsed; PL_chart.Visibility = Visibility.Collapsed; DS_data.Visibility = Visibility.Visible; DS_data.show(record); //这个函数里面是直接赋值的,非绑定 } if (record.test_Device == "PL_12" || record.test_Device == "PL_16") { DS_data.Visibility = Visibility.Collapsed; PL_data.Visibility = Visibility.Visible; PL_data.show(record); PL_chart.Visibility = Visibility.Visible; PL_chart.show(record); } else { //还是DS生化仪 PL_data.Visibility = Visibility.Collapsed; PL_chart.Visibility = Visibility.Collapsed; DS_data.Visibility = Visibility.Visible; DS_data.show(record); //这个函数里面是直接赋值的,非绑定 } foreach (var name in record.result) { if (name.item == "PAC1" || name.item == "PAC2") { continue; } if (name.item == "PAC3" || name.item == "PAC4") { continue; } if (name.item == "PAC5" || name.item == "PAC6") { continue; } if (name.item == "PAC7" || name.item == "PAC8") { continue; } if (name.item == "PACBit" || name.item == "PLTHist" || name.item == "RBCHist") { continue; } data_detailSource res = new data_detailSource(); res.item = name.item; res.full_item = name.fullname; res.result = name.result; res.unit = name.unit; res.normal_high = name.normal_high; res.normal_low = name.normal_low; res.indicate = name.indicate; result.Add(res); } this.Query_detail_datagrid.ItemsSource = result;//绑定进去 }