void ManageObjects() { for (int i = 0; i < ObjectsToManage.Length; i++) { if (currentDisplay.GetComponent <SpriteRenderer>() != null && currentDisplay.GetComponent <SpriteRenderer>().sprite != null) { if (ObjectsToManage[i].name == ("Room" + currentDisplay.CurrentRoom)) { ObjectsToManage[i].SetActive(true); } else { ObjectsToManage[i].SetActive(false); } } } }
IEnumerator Waiter() { char num = currentDisplay.GetComponent <SpriteRenderer>().sprite.name[currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Length - 1]; int key = num - '0'; foreach (char c in codes_screen[key]) { image.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("General/White_square"); if (c == 'D') { yield return(new WaitForSeconds(0.25f)); } else { yield return(new WaitForSeconds(0.75f)); } image.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); yield return(new WaitForSeconds(0.5f)); } }
public void onClickUnlock() { Boolean solutionMatch = true; morseCodeInputObjects = GameObject.FindGameObjectsWithTag("MorseCodeInput-" + currentDisplay.CurrentRoom); foreach (GameObject morseCodeInput in morseCodeInputObjects) { int currentRowInput = morseCodeInput.GetComponent <MorseCodeInputController>().CurrentInput; string rowCol = morseCodeInput.name.Split('-')[1]; char[] rowColArr = rowCol.ToCharArray(); int row = (int)Char.GetNumericValue(rowColArr[1]) - 1; int col = (int)Char.GetNumericValue(rowColArr[3]) - 1; if (currentDisplay.CurrentRoom == 1) { if (solutionRoom1[row, col] != currentRowInput) { solutionMatch = false; } } else if (currentDisplay.CurrentRoom == 2) { if (solutionRoom2[row, col] != currentRowInput) { solutionMatch = false; } } else if (currentDisplay.CurrentRoom == 3) { if (solutionRoom3[row, col] != currentRowInput) { solutionMatch = false; } } else if (currentDisplay.CurrentRoom == 4) { if (solutionRoom4[row, col] != currentRowInput) { solutionMatch = false; } } } if (currentDisplay.CurrentRoom == 3) { if (currentDisplay.CurrentWall == 1) { var zoomInObject = FindObjectOfType <ZoomInObject>(); char num = zoomInObject.zoomedInImageName[zoomInObject.zoomedInImageName.Length - 1]; Debug.Log("num:" + num); int next = num - '0'; if (zoomInObject.zoomedInImageName != "Switches_screen_END") { if (currentDisplay.InsertedPassword_W1 == solutionRoom4_1[num]) { currentDisplay.InsertedPassword_W1 = ""; if (next != 4) { zoomInObject.zoomedInImageName = "Switches_screen_" + (next + 1); onClickZoomReturn(); } else { zoomInObject.zoomedInImageName = "Switches_screen_END"; currentDisplay.completedWalls.Add(currentDisplay.CurrentWall); onClickZoomReturn(); currentDisplay.showImage("solved"); } } //else solutionMatch = false; } else { onClickZoomReturn(); currentDisplay.showImage("solved"); } } else if (currentDisplay.CurrentWall == 2) { if (currentDisplay.completedWalls.Count == 3) { Debug.Log(currentDisplay.InsertedPassword_W2); if (currentDisplay.InsertedPassword_W2 == solutionRoom4_2) { var dialPadLights = GameObject.FindGameObjectsWithTag("DialPadLight"); foreach (var light in dialPadLights) { light.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("General/Light_Green"); } currentDisplay.onLevelComplete(); } else { currentDisplay.InsertedPassword_W2 = ""; currentDisplay.Counter_W2 = 0; var dialPadLights = GameObject.FindGameObjectsWithTag("DialPadLight"); foreach (var light in dialPadLights) { light.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("General/Light_OFF"); } } } else { onClickZoomReturn(); } } else if (currentDisplay.CurrentWall == 3) { Debug.Log(currentDisplay.InsertedPassword_W3); Debug.Log("Toto" + currentDisplay.GetComponent <SpriteRenderer>().sprite.name); char num = currentDisplay.GetComponent <SpriteRenderer>().sprite.name[currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Length - 1]; int key = num - '0'; var zoomInObjects = FindObjectsOfType <ZoomInObject>(); ZoomInObject zoomInObject = null; foreach (var zoomObj in zoomInObjects) { if (currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains(zoomObj.zoomedInImageName)) { Debug.Log(zoomObj.zoomedInImageName); zoomInObject = zoomObj; } } if (currentDisplay.InsertedPassword_W3 == solutionRoom4_3[key]) { Debug.Log("Kurva" + key); zoomInObject.zoomedInImageName = "Screen_wall_mini_screen_solution_" + key; var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput2"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); } currentDisplay.showImage(zoomInObject.zoomedInImageName); currentDisplay.completedScreens.Add(key); if (key == 4) { currentDisplay.completedWalls.Add(currentDisplay.CurrentWall); } } } else if (currentDisplay.CurrentWall == 4) { var zoomInObjects = FindObjectsOfType <ZoomInObject>(); Debug.Log("ContinueWall4 "); ZoomInObject zoomInObject = null; foreach (var zoomObj in zoomInObjects) { if (zoomObj.zoomedInImageName.Contains("screen")) { zoomInObject = zoomObj; } } char num = zoomInObject.zoomedInImageName[zoomInObject.zoomedInImageName.Length - 1]; int next = num - '0'; if (zoomInObject.zoomedInImageName != "screen_Solution") { Debug.Log("ContinueWall4_1 "); if (zoomInObject.zoomedInImageName.Contains("screen_ABJURE_")) { Debug.Log("ContinueWall4_2 "); if (next == 6) { //ActivateObjects(); zoomInObject.zoomedInImageName = "screen_VEX_0"; currentDisplay.showImage(zoomInObject.zoomedInImageName); var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); } } else if (currentDisplay.InsertedPassword_W4 == solutionRoom4_4_1[num]) { Debug.Log("ContinueWall4_3 "); //if (next == 5) //{ // DeactivateObjects(); TODO? WHY SETACTIVE(TRUE) NOT WORKING??? //} currentDisplay.InsertedPassword_W4 = ""; zoomInObject.zoomedInImageName = "screen_ABJURE_" + (next + 1); currentDisplay.showImage(zoomInObject.zoomedInImageName); var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); } } //else solutionMatch = false; } else if (zoomInObject.zoomedInImageName.Contains("screen_VEX_")) { if (next == 3) { zoomInObject.zoomedInImageName = "screen_ZEPHYR_0"; currentDisplay.showImage(zoomInObject.zoomedInImageName); var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); } } else if (currentDisplay.InsertedPassword_W4 == solutionRoom4_4_2[num]) { currentDisplay.InsertedPassword_W4 = ""; zoomInObject.zoomedInImageName = "screen_VEX_" + (next + 1); currentDisplay.showImage(zoomInObject.zoomedInImageName); var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); } } //else solutionMatch = false; } else if (zoomInObject.zoomedInImageName.Contains("screen_ZEPHYR_")) { if (next == 6) { zoomInObject.zoomedInImageName = "screen_Solution"; currentDisplay.completedWalls.Add(currentDisplay.CurrentWall); currentDisplay.showImage(zoomInObject.zoomedInImageName); var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); input.SetActive(false); } } else if (currentDisplay.InsertedPassword_W4 == solutionRoom4_4_3[num]) { currentDisplay.InsertedPassword_W4 = ""; zoomInObject.zoomedInImageName = "screen_ZEPHYR_" + (next + 1); currentDisplay.showImage(zoomInObject.zoomedInImageName); var screenInputs = GameObject.FindGameObjectsWithTag("ScreenInput"); foreach (var input in screenInputs) { input.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("None"); } } //else solutionMatch = false; } } else { onClickZoomReturn(); currentDisplay.showImage("solved"); } } } //else if (currentDisplay.CurrentRoom == 4) //{ // if (solutionRoom4[row, col] != currentRowInput) // { // solutionMatch = false; // } //} if (currentDisplay.CurrentRoom != 3) { if (solutionMatch) { Debug.Log("Solution matched"); currentDisplay.PlayPuzzleSuccess(); currentDisplay.onLevelComplete(); } else { currentDisplay.PlayPuzzleFail(); Debug.Log("Solution Not matched"); } } }
void ManageObjects() { for (int i = 0; i < ObjectsToManage.Length; i++) { if (currentDisplay.GetComponent <SpriteRenderer>() != null && currentDisplay.GetComponent <SpriteRenderer>().sprite != null) { string[] words; if (currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("Wall1_solved") && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 1) { words = currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Split('_'); if (ObjectsToManage[i].name == words[0]) { ObjectsToManage[i].SetActive(true); } } else if (ObjectsToManage[i].name == currentDisplay.GetComponent <SpriteRenderer>().sprite.name) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "Wall4_screen_ABJURE_0" && currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("Wall4_screen_")) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "Wall3_Screen_wall_0" && currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("Wall3_Screen_")) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W1_Switches_screen_1" && currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("Wall1_Switches_screen_")) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "Wall1_zoom" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 1) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "Wall4_zoom" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 4) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W3_Screen0" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W3_Screen1" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.completedScreens.Contains(0)) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W3_Screen2" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.completedScreens.Contains(1)) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W3_Screen3" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.completedScreens.Contains(1)) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W3_Screen4" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.completedScreens.Contains(2) && currentDisplay.completedScreens.Contains(3)) { ObjectsToManage[i].SetActive(true); } else if (ObjectsToManage[i].name == "W3_MainScreen" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.completedWalls.Contains(3)) { ObjectsToManage[i].SetActive(true); } else { ObjectsToManage[i].SetActive(false); } if (ObjectsToManage[i].name == "W3_Screen0" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.CurrentState == DisplayController.State.zoom && !currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("screen_0")) { ObjectsToManage[i].SetActive(false); } else if (ObjectsToManage[i].name == "W3_Screen1" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.CurrentState == DisplayController.State.zoom && !currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("screen_1")) { ObjectsToManage[i].SetActive(false); } else if (ObjectsToManage[i].name == "W3_Screen2" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.CurrentState == DisplayController.State.zoom && !currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("screen_2")) { ObjectsToManage[i].SetActive(false); } else if (ObjectsToManage[i].name == "W3_Screen3" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.CurrentState == DisplayController.State.zoom && !currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("screen_3")) { ObjectsToManage[i].SetActive(false); } else if (ObjectsToManage[i].name == "W3_Screen4" && currentDisplay.CurrentRoom == 3 && currentDisplay.CurrentWall == 3 && currentDisplay.CurrentState == DisplayController.State.zoom && !currentDisplay.GetComponent <SpriteRenderer>().sprite.name.Contains("screen_4")) { ObjectsToManage[i].SetActive(false); } } } }