//After each move the puzzle strings should be checked for completed words void GetPuzzleStrings() { string letterAtSlot; int cs = PuzzleConfig.cellSize; //interate through the cellslots and see which letters are there. Make vertical and horizontal strings and check for words string [] horizontalWords = new string[cs]; BrickArray[] horizontalBricks = new BrickArray[cs]; for (int x = 0; x < cs; x++) { horizontalBricks[x].brickWord = new Transform[cs]; } string[] verticalWords = new string[cs]; BrickArray[] verticalBricks = new BrickArray[cs]; for (int y = 0; y < cs; y++) { verticalBricks[y].brickWord = new Transform[cs]; } //Analyze row for (int i = 0; i < cs; i++) { for (int k = 0; k < cs; k++) { //Get cell Transform brickAtSlot = CellFactory.cellPositions[(cs * i) + k].FindChild("brick"); //If there is a brick only look for a letter or else put an asterix instead if (brickAtSlot == null) { letterAtSlot = "*"; } else { horizontalBricks [i].brickWord [k] = brickAtSlot; letterAtSlot = brickAtSlot.FindChild("letter").GetComponent <TextMesh>().text; } //Debug.Log (letterAtSlot); horizontalWords [i] += letterAtSlot; } Debug.Log(horizontalWords[i]); string[] Arr = GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig> ().puzzleWords; foreach (string ar in Arr) { if (horizontalWords [i].Contains(ar)) { if (Application.loadedLevelName == "Stage4" || Application.loadedLevelName == "Stage5" || Application.loadedLevelName == "Room for 2") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w4").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w5").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w5").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w6").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w6").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w7").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w7").GetComponent <Button> ().interactable = false; } } } if (horizontalWords [i].Contains(ar)) { if (Application.loadedLevelName == "Stage1") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w4").GetComponent <Button> ().interactable = false; } } } if (horizontalWords [i].Contains(ar)) { if (Application.loadedLevelName == "Stage2") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w4").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w5").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w5").GetComponent <Button> ().interactable = false; } } } if (horizontalWords [i].Contains(ar)) { if (Application.loadedLevelName == "Stage3") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { // GameObject.Find ("w1").GetComponentInChildren<Text> ().text = strengz[1]; GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); // GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; //Debug.Log("Trying again baby"); GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[1] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[2] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[3] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w4").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w5").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[4] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w5").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w6").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[5] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w6").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w7").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[5] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w7").GetComponent <Button> ().interactable = false; } } } } } //Now we have the horizontal words, look for the actual words inside StringSearch(horizontalWords, PuzzleConfig.searchWords, horizontalBricks); //Analyze column for (int m = 0; m < cs; m++) { for (int n = cs - 1; n >= 0; n--) { //Get cell Transform brickAtSlot = CellFactory.cellPositions[m + (cs * n)].FindChild("brick"); //If there is a brick only look for a letter or else put an asterix instead if (brickAtSlot == null) { letterAtSlot = "*"; } else { //Debug.Log ("Loop : " + ((cs - 1)-n).ToString()+"--"+m.ToString()+"--"+n.ToString()); letterAtSlot = brickAtSlot.FindChild("letter").GetComponent <TextMesh>().text; //Debug.Log ("Letter at :" + letterAtSlot); verticalBricks [m].brickWord [(cs - 1) - n] = brickAtSlot; } verticalWords [m] += letterAtSlot; } string[] Arr = GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig> ().puzzleWords; foreach (string ar in Arr) { if (verticalWords [m].Contains(ar)) { if (Application.loadedLevelName == "Stage4" || Application.loadedLevelName == "Stage5" || Application.loadedLevelName == "Room for 2") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w4").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w5").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w5").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w6").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w6").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w7").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w7").GetComponent <Button> ().interactable = false; } } } if (verticalWords [m].Contains(ar)) { if (Application.loadedLevelName == "Stage1") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w4").GetComponent <Button> ().interactable = false; } } } if (verticalWords [m].Contains(ar)) { if (Application.loadedLevelName == "Stage2") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w4").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w5").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("w5").GetComponent <Button> ().interactable = false; } } } if (verticalWords [m].Contains(ar)) { if (Application.loadedLevelName == "Stage3") { if (GameObject.Find("w1").GetComponentInChildren <Text> ().text == ar) { // GameObject.Find ("w1").GetComponentInChildren<Text> ().text = strengz[1]; GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); // GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; //Debug.Log("Trying again baby"); GameObject.Find("w1").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w2").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[1] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w2").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w3").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[2] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w3").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w4").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[3] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w4").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w5").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[4] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w5").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w6").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[5] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w6").GetComponent <Button> ().interactable = false; } if (GameObject.Find("w7").GetComponentInChildren <Text> ().text == ar) { GameObject.Find("PuzzleConfig").GetComponent <PuzzleConfig>().ArrayW.Remove(ar); //strengz[5] = ar; //GameObject.Find("Main Camera").GetComponent<Times>().num += 5f; GameObject.Find("w7").GetComponent <Button> ().interactable = false; } } } } } for (int h = 0; h < PuzzleConfig.cellSize; h++) { //Debug.Log ("vertical word : " + verticalWords [h]); } StringSearch(verticalWords, PuzzleConfig.searchWords, verticalBricks); }
//After each move the puzzle strings should be checked for completed words void GetPuzzleStrings() { string letterAtSlot; int cs = PuzzleConfig.cellSize; //interate through the cellslots and see which letters are there. Make vertical and horizontal strings and check for words string [] horizontalWords = new string[cs]; BrickArray[] horizontalBricks = new BrickArray[cs]; for (int x = 0; x < cs; x++) { horizontalBricks[x].brickWord = new Transform[cs]; } string[] verticalWords = new string[cs]; BrickArray[] verticalBricks = new BrickArray[cs]; for (int y = 0; y < cs; y++) { verticalBricks[y].brickWord = new Transform[cs]; } //Analyze row for (int i = 0; i < cs; i++) { for (int k = 0; k < cs; k++) { //Get cell Transform brickAtSlot = CellFactory.cellPositions[(cs * i) + k].FindChild("brick"); //If there is a brick only look for a letter or else put an asterix instead if (brickAtSlot == null) { letterAtSlot = "*"; } else { horizontalBricks [i].brickWord [k] = brickAtSlot; letterAtSlot = brickAtSlot.FindChild("letter").GetComponent <TextMesh>().text; } horizontalWords [i] += letterAtSlot; } } //Now we have the horizontal words, look for the actual words inside StringSearch(horizontalWords, PuzzleConfig.searchWords, horizontalBricks); //Analyze column for (int m = 0; m < cs; m++) { for (int n = cs - 1; n >= 0; n--) { //Get cell Transform brickAtSlot = CellFactory.cellPositions[m + (cs * n)].FindChild("brick"); //If there is a brick only look for a letter or else put an asterix instead if (brickAtSlot == null) { letterAtSlot = "*"; } else { Debug.Log("Loop : " + ((cs - 1) - n).ToString() + "--" + m.ToString() + "--" + n.ToString()); letterAtSlot = brickAtSlot.FindChild("letter").GetComponent <TextMesh>().text; Debug.Log("Letter at :" + letterAtSlot); verticalBricks [m].brickWord [(cs - 1) - n] = brickAtSlot; } verticalWords [m] += letterAtSlot; } } for (int h = 0; h < PuzzleConfig.cellSize; h++) { //Debug.Log ("vertical word : " + verticalWords [h]); } StringSearch(verticalWords, PuzzleConfig.searchWords, verticalBricks); }
public void BrickArrayTest() { var array = new BrickArray(); Assert.AreEqual(30, array.Bricks.Count); }