Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //code brut pour evité des bug (peut etre largement amelioré juste pas le temps)
        if (Input.GetKeyDown(KeyCode.Keypad1) ||
            Input.GetKeyDown(KeyCode.Keypad2) ||
            Input.GetKeyDown(KeyCode.Keypad3) ||
            Input.GetKeyDown(KeyCode.Keypad4) ||
            Input.GetKeyDown(KeyCode.Keypad5) ||
            Input.GetKeyDown(KeyCode.Keypad6) ||
            Input.GetKeyDown(KeyCode.Keypad7) ||
            Input.GetKeyDown(KeyCode.Keypad8) ||
            Input.GetKeyDown(KeyCode.Keypad9))
        {
            // (Musique) il faudrait mettre un son de clavier ici
            GenerateRandomKeyboardSound();

            InstantiateNumberPlayer();

            if (inputPlayer.text.Length == 4)
            {
                if (winOrder == inputPlayer.text)
                {
                    //essai win
                    // (Musique) il faudrait mettre un son de win je suppose
                    Debug.Log("WIN!!");
                    GameWin();
                }
                else
                {
                    //essai raté !
                    // (Musique) il faudrait mettre un son de lose je suppose
                    audioS.PlayOneShot(errorSound);

                    objectShaker.ShakeThis(timeHighlightWrong);
                    EmptyPreviousNumber();
                    inputPlayer.text = "";
                    Debug.Log("No");
                }
            }

            if (inputPlayer.text.Length > 4)
            {
                EmptyPreviousNumber();
                inputPlayer.text = "";
            }
        }

        // Au cas où le clique fasse perdre le focus, on le récupère
        if (Input.GetButtonDown("Fire1") || Input.GetButtonDown("Fire2") || Input.GetButtonDown("Fire3") || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
        {
            AutoInputSelector();
        }
    }
Ejemplo n.º 2
0
    // Fonction qui vérifie la valididité de l'input à chaque entrée
    // Vérifie également la condition de victoire
    void CheckIfValid()
    {
        if (inputF.text == wordToCopy[wordPosition].ToString())
        {
            //Sons de claviers
            GenerateRandomKeyboardSound();

            letters[wordPosition].text = "";
            wordPosition++;
            Debug.Log("OK");

            if (wordPosition == wordToCopy.Length)
            {
                successLogosList[currentSuccess].color = Color.green;
                audioS.PlayOneShot(validSound);

                AddSuccess();
                if (currentSuccess < numberOfSuccessToWin)
                {
                    InitNewWord();
                }
                else
                {
                    win = true;
                    GameWon();
                    Debug.Log("C'est Win");
                }
            }
        }
        else
        {
            // Augmenter jauge de sel

            audioS.PlayOneShot(errorSound);

            objectShaker.ShakeThis(timeHighlightWrong);

            if (!wrongAnswer)
            {
                StartCoroutine(DisplayLetterCaseBright());
            }

            GameManager.Instance.AddAnger(addedSalt);

            Debug.Log("NOPE");
        }

        inputF.text = "";
    }