示例#1
0
    IEnumerator Waiter()
    {
        IDictionary <char, string> currentCodes;
        var          zoomInObjects = FindObjectsOfType <ZoomInObject>();
        ZoomInObject zoomInObject  = null;

        foreach (var zoomObj in zoomInObjects)
        {
            Debug.Log("Hm? " + zoomObj.zoomedInImageName);
            if (zoomObj.zoomedInImageName.Contains("screen"))
            {
                zoomInObject = zoomObj;
            }
        }
        char key = zoomInObject.zoomedInImageName[zoomInObject.zoomedInImageName.Length - 1];

        Debug.Log("Hm? " + zoomInObject.zoomedInImageName);
        if (zoomInObject.zoomedInImageName.Contains("ABJURE"))
        {
            currentCodes = codes_screen_1;
        }
        else if (zoomInObject.zoomedInImageName.Contains("VEX"))
        {
            currentCodes = codes_screen_2;
        }
        else
        {
            currentCodes = codes_screen_3;
        }

        foreach (char c in currentCodes[key])
        {
            AudioClip a;
            if (c == 'D')
            {
                audioo.PlayOneShot((AudioClip)Resources.Load("dot"));
                a = (AudioClip)Resources.Load("dot");
                yield return(new WaitForSeconds(a.length + .5f));
            }
            else if (c == 'L')
            {
                audioo.PlayOneShot((AudioClip)Resources.Load("dash"));
                a = (AudioClip)Resources.Load("dash");
                yield return(new WaitForSeconds(a.length + .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");
            }
        }
    }