void Update_node_colors() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; Brick cScript = T_Cell_in_grid.GetComponent <Brick>(); //keepfor color //if(cScript.IsLegitPath)GridArra[x,z].renderer.material.color=Color.cyan; if (cScript.isStart) { GridArra[x, z].GetComponent <Renderer>().material.color = Color.white; } if (cScript.isEnd) { GridArra[x, z].GetComponent <Renderer>().material.color = Color.black; } if (!cScript.IsLegitPath) { GridArra[x, z].GetComponent <Renderer>().material.color = Color.yellow; } //if(cScript.isStart)GridArra[x,z].renderer.material.color=Color.white; //if(cScript.isStart)GridArra[x,z].renderer.material.color=Color.white; } } }
void populate_template() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; NavMazeBlock cScript = T_Cell_in_grid.GetComponent <NavMazeBlock>(); //cScript._F = cScript._H+ cScript._G ; T_Cell_in_grid.name = "(" + cScript.MyStupid__X + "," + cScript.MyStupid__Z + ")" + "g." + cScript._G + "h." + cScript._H + "f." + cScript._F; } } }
void Update_node_colors() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; NavMazeBlock cScript = T_Cell_in_grid.GetComponent <NavMazeBlock>(); //keepfor color //if (cScript.IsLegitPath) GridArra[x, z].GetComponent<Renderer>().material.color = Color.cyan; //if (cScript.isStart) GridArra[x, z].GetComponent<Renderer>().material.color = Color.white; //if (cScript.isEnd) GridArra[x, z].GetComponent<Renderer>().material.color = Color.black; //if (!cScript.IsLegitPath) GridArra[x, z].GetComponent<Renderer>().material.color = Color.yellow; if (cScript.isfound) { GridArra[x, z].GetComponent <NavMazeBlock>().UpdateTileMAterial(LightTiles[1]); } else { GridArra[x, z].GetComponent <NavMazeBlock>().UpdateTileMAterial(DarkTiles[1]); } if (cScript.isStart) { GridArra[x, z].GetComponent <NavMazeBlock>().UpdateTileMAterial(GreenMatDark); } if (cScript.isEnd) { GridArra[x, z].GetComponent <NavMazeBlock>().UpdateTileMAterial(RedMAt); } // if (!cScript.isfound) { GridArra[x, z].GetComponent<NavMazeBlock>().UpdateBlockText("X"); } //if (Grid_end_ptr.GetComponent<NavMazeBlock>().isfound) //{ // Grid_end_ptr.GetComponent<NavMazeBlock>().UpdateTileMAterial(LightTiles[1]); //} //else //{ // Grid_end_ptr.GetComponent<NavMazeBlock>().UpdateTileMAterial(DarkTiles[1]); //} //if(cScript.isStart)GridArra[x,z].GetComponent<Renderer>().material.color=Color.white; //if(cScript.isStart)GridArra[x,z].GetComponent<Renderer>().material.color=Color.white; } } }
void resetALL_G_H_F() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; NavMazeBlock cScript = T_Cell_in_grid.GetComponent <NavMazeBlock>(); cScript._g = 0; cScript._H = 0; cScript._F = 0; } } }
void populate_H() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; NavMazeBlock cScript = T_Cell_in_grid.GetComponent <NavMazeBlock>(); cScript._H = (Mathf.Abs(cScript.MyStupid__X - (int)EndNodeV3.x)) + (Mathf.Abs(cScript.MyStupid__Z - (int)EndNodeV3.z)); // cScript._H= myx-_endNodeX + myy- endy } } }
void makeAdjList_and_Actualparent_AFTER_WALLSELECTION() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; if (T_Cell_in_grid.GetComponent <NavMazeBlock>().IsLegitPath) { NavMazeBlock cScript = T_Cell_in_grid.GetComponent <NavMazeBlock>(); //CHECK BOT if (x - 1 >= 0) { cScript.Adjacent_list_Transforms.Add(GridArra[x - 1, z]); //GridArra[x-1,z].GetComponent<NavMazeBlock>().ptrT_Parent=T_Cell_in_grid; GridArra[x - 1, z].GetComponent <NavMazeBlock>().ptrT_ActualParent = T_Cell_in_grid; } //CHECK TOP if (x + 1 < Matrix_Size.x) { cScript.Adjacent_list_Transforms.Add(GridArra[x + 1, z]); //GridArra[x+1,z].GetComponent<NavMazeBlock>().ptrT_Parent=T_Cell_in_grid; GridArra[x + 1, z].GetComponent <NavMazeBlock>().ptrT_ActualParent = T_Cell_in_grid; } //CHECK BRIGHT if (z - 1 >= 0) { cScript.Adjacent_list_Transforms.Add(GridArra[x, z - 1]); //GridArra[x,z-1].GetComponent<NavMazeBlock>().ptrT_Parent=T_Cell_in_grid; GridArra[x, z - 1].GetComponent <NavMazeBlock>().ptrT_ActualParent = T_Cell_in_grid; } //CHECK LEFT if (z + 1 < Matrix_Size.z) { cScript.Adjacent_list_Transforms.Add(GridArra[x, z + 1]); //GridArra[x,z+1].GetComponent<NavMazeBlock>().ptrT_Parent=T_Cell_in_grid; GridArra[x, z + 1].GetComponent <NavMazeBlock>().ptrT_ActualParent = T_Cell_in_grid; } } } //Xforz } //Xforx } //XSetAdj
void clearListOfAdjascent() { for (int x = 0; x < Matrix_Size.x; x++) { for (int z = 0; z < Matrix_Size.z; z++) { Transform T_Cell_in_grid; T_Cell_in_grid = GridArra[x, z]; NavMazeBlock cScript = T_Cell_in_grid.GetComponent <NavMazeBlock>(); if (cScript.ptrT_ActualParent != null) { cScript.ptrT_ActualParent = null; } //cScript.ptrT_Parent_PATH=null; //cScript.ptrT_Parent=null; cScript.isfound = false; cScript.Adjacent_list_Transforms.Clear(); // T_Cell_in_grid.GetComponent<Renderer>().material.color=Color.cyan; //cScript._F = cScript._H+ cScript._G ; //T_Cell_in_grid.name= "("+ cScript.MyStupid__X + "," + cScript.MyStupid__Z+ ")" + "g."+ cScript._G + "h."+cScript._H + "f." + cScript._F; } } }