// initialize _nodes and _clusters public void InitializeGraph() { _nodes = new Node[Volume]; _clusters = new Cluster[Area * 4]; for (int node_idx = 0; node_idx < Volume; ++node_idx) { _nodes[node_idx] = new Node(UTL.GetX(node_idx), UTL.GetY(node_idx), UTL.GetZ(node_idx), GameManager.Instance.GetTileButtons()[node_idx % Area].GetComponent <TileButton>()); } for (int cl_idx = 0; cl_idx < Area * 4; ++cl_idx) { _clusters[cl_idx] = new Cluster(); } for (int cl_idx = 0; cl_idx < Area; ++cl_idx) { _clusters[cl_idx].InitializeXCluster(cl_idx % Length, cl_idx / Length); _clusters[cl_idx + Area].InitializeYCluster(cl_idx % Length, cl_idx / Length); _clusters[cl_idx + Area * 2].InitializeZCluster(cl_idx % Length, cl_idx / Length); _clusters[cl_idx + Area * 3].InitializeSquareCluster(cl_idx % RootLength, (cl_idx % Length) / RootLength, cl_idx / Length); } }
// create and initialize _tile_buttons private void CreateTileButtons() { _tile_buttons = new Button[_GridArea]; for (int tile_idx = 0; tile_idx < _GridArea; tile_idx++) { _tile_buttons[tile_idx] = Instantiate(tileButtonPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity) as Button; _tile_buttons[tile_idx].transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform, false); _tile_buttons[tile_idx].GetComponent <TileButton>().Initialize(UTL.GetX(tile_idx), UTL.GetY(tile_idx)); } }