Exemplo n.º 1
0
    private void OnMouseDown()
    {
        if (!_flag)
        {
            _flag = true;
            GetComponent <Text>().text = "";
            StartButton.GetComponent <ScrollButtons>().Speed    = -1f;
            StartButton.GetComponent <ScrollButtons>().CheckPos = -160f;
            Sphere.GetComponent <Animation>().Play("StartGame");
            StartCoroutine(RespawnFigure());
            StartCoroutine(SphereAddRigidbody());
            InvokeRepeating("ScoreIncrement", 0, 1f);
        }
        IEnumerator RespawnFigure()
        {
            yield return(new WaitForSeconds(1f));

            SpawnBlocks.GetComponent <SpawnBlocks>().enabled = true;
        }

        IEnumerator SphereAddRigidbody()
        {
            yield return(new WaitForSeconds(Sphere.GetComponent <Animation>().clip.length + 1f));

            Sphere.AddComponent <Rigidbody>();
            Sphere.GetComponent <Rigidbody>().drag = 6f;
            ControlButtons.SetActive(true);                                                       //Делаем активными кнопки управления
            Sphere.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionZ; //Добавляем Rigidbody здесь чтобы отыграла анимация подъема
            Sphere.GetComponent <SphereMove>().enabled    = true;                                 //включаем управление чтобы не ругался на отсутствие Rigidbody
        }
    }