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 } }
IEnumerator DeleteCubes() { for (int i = 0; i < 3; i++) { yield return(new WaitForSeconds(0.3f)); AllCubes[i].GetComponent <DestroyCubeInStartGame>().enabled = true; } SpawnBlocks.GetComponent <SpawnBlocks>().enabled = true; GetComponent <CubeJump>().enabled = true; }
private void OnMouseDown() { if (clicked) { return; } clicked = true; playTxt.gameObject.SetActive(false); gameName.text = "0"; buttons.GetComponent <ScrollObjects>().speed = -5f; buttons.GetComponent <ScrollObjects>().checkPos = -150f; m_cube.GetComponent <Animation>().Play("StartGameCube"); block.GetComponent <Animation>().Play("ReturnBLock"); SpawnBlocks.GetComponent <SpawnBlocks>().enabled = true; m_cube.AddComponent <Rigidbody>(); }