IEnumerator IReproduceEgg() { //Cause of Error? Not yet known, but when called outside it doesnt work, so do smth with processing inside. Debug.Log("Reproducing Egg"); float duration = 2.0f; float elapsedTime = 0; while (elapsedTime < duration) { Debug.Log(elapsedTime); Lid.transform.localPosition = Vector3.Lerp(Vector3.zero, new Vector3(0, 0, -0.4f), elapsedTime / duration); elapsedTime += Time.deltaTime; yield return(null); } yield return(new WaitForSeconds(1)); Debug.Log("Dropping New Egg!"); Egg.transform.position = new Vector3(0, 0, 0.5f); eggMovement.ShowCleanEgg(); eggParameter.Initialize(); rg.isKinematic = false; eggParameter.isNew = true; StartCoroutine(CountDown()); yield return(null); }
IEnumerator Hatch(bool good) { //Microphone dialogueHandler.Narrate("Hatch", 2); isListening = false; eggPhysicalAI.isBusy = true; Vector3 initPos = tf.position; rg.isKinematic = true; float duration = 2.0f; float elapsedTime = 0; gameController.SpotLight.GetComponent <Animator>().SetBool("isOn", false); while (elapsedTime < duration) { tf.position = Vector3.Lerp(initPos, new Vector3(0, 0, 0.5f), elapsedTime / duration); elapsedTime += Time.deltaTime; yield return(null); } yield return(new WaitForSeconds(1)); eggShattered = Instantiate(EggShattered, transform.position, transform.rotation, transform.parent); eggParameter.TotalParPass = eggParameter.TotalParameter; for (int i = 0; i < eggShattered.transform.childCount; i++) { if (eggShattered.transform.GetChild(i).GetComponent <MeshRenderer>() == null) { continue; } Material eggShard = eggShattered.transform.GetChild(i).GetComponent <MeshRenderer>().material; shaderHandler.changeShatteredEggColor(eggShard, eggParameter.ParSpecColor(eggParameter.SoundParameter), eggParameter.ParSpecColor(eggParameter.KnockParameter), eggParameter.ParSpecColor(eggParameter.StareParameter), 1); } eggParameter.inhColor = new Color( eggParameter.ParSpecColor(eggParameter.SoundParameter), eggParameter.ParSpecColor(eggParameter.KnockParameter), eggParameter.ParSpecColor(eggParameter.StareParameter), 1 ); eggParameter.Initialize(); HideCleanEgg(); if (good) { } else { } yield return(new WaitForSeconds(0.5f)); eggShattered.transform.parent = GameObject.Find("Shells").transform; gameController.ReproduceEgg(); yield return(null); }