public void CreateGrid(int n, GameObject btn, GameObject parent) { Algorithm.Node[,] nodes = new Algorithm.Node[n, n]; cell[,] clls = new cell[n, n]; for (int y = 0; y < n; y++) { for (int x = 0; x < n; x++) { nodes [y, x] = new Algorithm.Node(); nodes [y, x].y = y; nodes [y, x].x = x; GameObject go = Spawn(btn); go.GetComponent <cell> ().assiggnedNode = nodes [y, x]; clls [y, x] = go.GetComponent <cell> (); go.transform.SetParent(parent.transform, false); go.GetComponent <RectTransform> ().localPosition = new Vector3(go.GetComponent <RectTransform> ().localPosition.x + x * 100, go.GetComponent <RectTransform> ().localPosition.y - y * 100, go.GetComponent <RectTransform> ().localPosition.z); go.GetComponent <cell> ().Init(); go.GetComponent <cell> ().gm = this; } } Nodes = nodes; cells = clls; }
public int IsCellWithNode(Algorithm.Node nd) { int ans = -1; if (nd == assiggnedNode) { ans = 1; } else { ans = -1; } return(ans); }