Exemple #1
0
    private void TurnArrow()
    {
        if (timer.IsRunning)
        {
            redButton.interactable = false;
            buttonPressed.GetComponent <Button>().interactable = false;


            if (timer.Elapsed.Seconds < 1)
            {
                Vector3    nextRotation;
                GameObject currentArrow;
                for (int i = 0; i < boxesWithArrow.Count; i++)
                {
                    currentArrow = boxesWithArrow [i].transform.GetChild(0).gameObject;

//					UnityEngine.Debug.Log (i);
//					UnityEngine.Debug.Log(rotationPoints [rotationIndex [i]]);

                    UnityEngine.Debug.Log(rotationIndex.Count);
                    if (rotationIndex [i] == -1)
                    {
                        rotationIndex [i] = 0;
                    }

                    nextRotation = new Vector3(0, 0, rotationPoints [rotationIndex [i]]);

                    currentArrow.transform.rotation = Quaternion.Lerp(currentArrow.transform.rotation, Quaternion.Euler(nextRotation), 0.07f);
                }
            }
            else
            {
                timer.Stop();
                redButton.interactable = true;
                buttonPressed.GetComponent <Button>().interactable = true;
                sound.StopMusic();

                StartCoroutine("StopForSeconds");
            }
        }
        else
        {
            if (timer.Elapsed.Seconds == 0)
            {
                timer.Start();
                sound.ReStartMusic();
            }
        }
    }