Beispiel #1
0
    public void NumberActivator(int newNumberIndex = 0)
    {
        currentNumber = numbers[currentNumberIndex];

        currentNumberIndex = newNumberIndex;
        nextNumber         = numbers[currentNumberIndex];

        currentNumberAnimator = currentNumber.GetComponent <Animator>();
        nextNumberAnimator    = nextNumber.GetComponent <Animator>();

        currentNumberAnimator.Play(buttonFadeOut);
        nextNumberAnimator.Play(buttonFadeIn);

        if (newNumberIndex == 10) //BackspaceKey
        {
            SetDisplay();
            ResetAlert();
        }
        else if (newNumberIndex == 11) //EnterKey
        {
            if (playerCode == correctCode)
            {
                Debug.Log("Correct!");
                SetDisplay();
                ShowLanguageSelection();
                //Accediendo al método de la clase GeneralController
                GameObject        levelComplete     = generalContainerPanel;
                GeneralController generalController = GetComponent <GeneralController>();
                generalController.Invoke("OnSuccessfulAccess", 0);
            }
            else
            {
                Debug.Log("Incorrecto!");
                //playerCode = "CLAVE INCORRECTA";
                playerCode     = "";
                alertText.text = "...Incorrecto";
                SetDisplay();
            }
        }
        else
        {
            //Poner sonido a las teclas
            float randomPitch = UnityEngine.Random.Range(lowPitchRange, highPitchRange);
            //currentSound = sounds[newNumberIndex].GetComponent<AudioSource>();
            currentSound       = numbers[newNumberIndex].GetComponent <AudioSource>();
            currentSound.pitch = randomPitch;
            //currentSound.clip = clips[randomIndex];
            //rrentSound.clip = clips[UnityEngine.Random.Range(0, clips.Length)];
            currentSound.clip = clip;
            currentSound.Play();

            if (alertText.text == "...Incorrecto")
            {
                ResetAlert();
            }

            if (playerCode == "INGRESE PASSWORD")
            {
                ResetDisplay();
            }
            playerCode += newNumberIndex;
            Debug.Log(playerCode);
        }
    }