private void SetLine() { List <Transform> othercell = othercells(); for (int i = 0; i < SelectedCells.Count; i++) { foreach (Transform other in othercell) { GameObject selected = SelectedCells[i]; PuzzleCellData data = selected.GetComponent <PuzzleCellData>(); PuzzleCellData newdata = other.GetComponent <PuzzleCellData>(); if (data.ground_X + 1 == newdata.ground_X && data.ground_Y == newdata.ground_Y) { CreateLineVertical(GameData.Blocksize / 2, 0, selected, data); } if (data.ground_X == newdata.ground_X + 1 && data.ground_Y == newdata.ground_Y) { CreateLineVertical(-GameData.Blocksize / 2, 0, selected, data); } if (data.ground_X == newdata.ground_X && data.ground_Y + 1 == newdata.ground_Y) { CreateLineHorizantal(0, -GameData.Blocksize / 2, selected, data); } if (data.ground_X == newdata.ground_X && data.ground_Y == newdata.ground_Y + 1) { CreateLineHorizantal(0, GameData.Blocksize / 2, selected, data); } } } }
private List <char> FindVerticalWord(GameObject selected, List <Transform> Allcells, List <char> a) { a.Add(selected.GetComponent <PuzzleCellData>().c); if (!PuzzleCellParents.Contains(selected.transform.parent.gameObject)) { PuzzleCellParents.Add(selected.transform.parent.gameObject); } foreach (Transform other in Allcells) { PuzzleCellData data = selected.GetComponent <PuzzleCellData>(); PuzzleCellData newdata = other.GetComponent <PuzzleCellData>(); if (data.ground_X == newdata.ground_X && data.ground_Y + 1 == newdata.ground_Y && data.Cell_x == newdata.Cell_x && data.Cell_y + 1 == newdata.Cell_y ) { if (!PuzzleCellParents.Contains(other.parent.gameObject)) { // print("the other id : "+ other.parent.gameObject.GetComponent<PuzzleparentData>().id); PuzzleCellParents.Add(other.parent.gameObject); } return(FindVerticalWord(other.gameObject, Allcells, a)); } } return(a); }
private List <char> FindHorizantalWord(GameObject selected, List <Transform> Allcells, List <char> a) { a.Add(selected.GetComponent <PuzzleCellData>().c); if (!PuzzleCellParents.Contains(selected.transform.parent.gameObject)) { PuzzleCellParents.Add(selected.transform.parent.gameObject); } foreach (Transform other in Allcells) { PuzzleCellData data = selected.GetComponent <PuzzleCellData>(); PuzzleCellData newdata = other.GetComponent <PuzzleCellData>(); if (data.ground_X + 1 == newdata.ground_X && data.ground_Y == newdata.ground_Y && data.Cell_x + 1 == newdata.Cell_x && data.Cell_y == newdata.Cell_y ) { return(FindHorizantalWord(other.gameObject, Allcells, a)); } } return(a); }
private void FitOnGround() { foreach (Transform puzzleparent in PuzzleCellContainer.transform) { foreach (Transform child in puzzleparent.transform) { PuzzleCellData data = child.GetComponent <PuzzleCellData>(); child.transform.position = GroundMatrix[data.ground_X, data.ground_Y].transform.position; } } }
private void CreateLineVertical(float v1, float v2, GameObject selected, PuzzleCellData data) { GameObject child = new GameObject(); child.tag = "line"; child.transform.position = selected.transform.position + new Vector3(v1, v2, 0); child.AddComponent <RectTransform>(); child.GetComponent <RectTransform>().sizeDelta = new Vector2(ReagentSize, GameData.Blocksize); child.AddComponent <Image>(); child.GetComponent <Image>().color = GroundMatrix[data.ground_X, data.ground_Y].GetComponent <Image>().color; child.transform.SetParent(selected.transform); }
private GameObject FindHeadHorizantal(GameObject selected, List <Transform> Allcells) { foreach (Transform other in Allcells) { PuzzleCellData data = selected.GetComponent <PuzzleCellData>(); PuzzleCellData newdata = other.GetComponent <PuzzleCellData>(); if (data.ground_X == newdata.ground_X + 1 && data.ground_Y == newdata.ground_Y && data.Cell_x == newdata.Cell_x + 1 && data.Cell_y == newdata.Cell_y) { // print("searcinggg...........new head " +other.GetComponent<PuzzleCellData>().c); return(FindHeadHorizantal(other.gameObject, Allcells)); } } return(selected); }