IEnumerator CorDragonAttack() { corAttack = true; //날기 시작 if (!corFly) { StartCoroutine("CorFly"); yield return(new WaitForEndOfFrame()); } while (corFly) { yield return(new WaitForEndOfFrame()); } //날기 끝 //dragonAttack 시작 anim.SetTrigger("Glide"); dragonAttack.Reset(); dragonAttack.MovePlay(dragon.position, dragon.rotation); Quaternion rot = dragon.rotation; while (!dragonAttack.GetisEnd()) { dragon.position = dragonAttack.GetCurrentPos(); dragon.rotation = rot * dragonAttack.GetCurrentRotation(); yield return(new WaitForEndOfFrame()); } anim.SetTrigger("Hover"); //dragonAttack 끝 float distance = Vector3.Distance(dragon.position, player.transform.position); Vector3 dragonDir = ((player.transform.position - new Vector3(0, 15, 0)) - dragon.position).normalized; //플레이어한테 돌격 while (distance > 100) { dragonDir = ((player.transform.position - new Vector3(0, 15, 0)) - dragon.position).normalized; dragon.rotation = Quaternion.Lerp(dragon.rotation, Quaternion.LookRotation(dragonDir, dragon.up), 0.05f); dragon.position += dragonDir * Time.deltaTime * GlidSpeed; distance = Vector3.Distance(dragon.position, player.transform.position); yield return(new WaitForEndOfFrame()); } Time.timeScale = 0.1f; //Rigidbody //방향변환 없이 돌격 bool ExplosionParticle = true; while (dragon.position.y > -50) { dragon.position += dragonDir * Time.deltaTime * GlidSpeed; if (dragon.position.y < 0 && ExplosionParticle) { Time.timeScale = 1.0f; Time.fixedDeltaTime = Time.deltaTime; Instantiate(bigExplosionParticle, dragon.position + dragon.forward * 20, Quaternion.identity); ExplosionParticle = false; } yield return(new WaitForEndOfFrame()); } Vector3 lookDir = player.transform.position - dragon.position; lookDir.y = 0; dragon.rotation = Quaternion.LookRotation(lookDir.normalized, Vector3.up); //anim.SetTrigger("Hover"); //착륙 시작 if (!corUp) { StartCoroutine("CorUp"); yield return(new WaitForEndOfFrame()); } while (corUp) { yield return(new WaitForEndOfFrame()); } //착륙 끝 corAttack = false; yield return(null); }
IEnumerator CorDragonFlame() { corFlame = true; //날기 시작 if (!corFly) { StartCoroutine("CorFly"); yield return(new WaitForEndOfFrame()); } while (corFly) { yield return(new WaitForEndOfFrame()); } //날기 끝 //Debug.Log("endFly"); //flame움직임 시작 dragonFlame.Reset(); dragonFlame.MovePlay(dragon.position, dragon.rotation); Quaternion rot = dragon.rotation; while (!dragonFlame.GetisEnd()) { dragon.position = dragonFlame.GetCurrentPos(); dragon.rotation = rot * dragonFlame.GetCurrentRotation(); yield return(new WaitForEndOfFrame()); } Vector3 flameDir = (player.transform.position - flameParticle.transform.position).normalized; flameParticle.transform.rotation = Quaternion.LookRotation(flameDir, Vector3.up); flameParticle.GetComponent <ParticleSystem>().Play(); float Flametime = 0.0f; while (Flametime < 3) { Flametime += Time.deltaTime; flameDir = (player.transform.position - flameParticle.transform.position).normalized; flameParticle.transform.rotation = Quaternion.LookRotation(flameDir, Vector3.up); yield return(new WaitForEndOfFrame()); } flameParticle.GetComponent <ParticleSystem>().Stop(); yield return(new WaitForSeconds(0.2f)); //착륙 시작 if (!corLanding) { StartCoroutine("CorLanding"); yield return(new WaitForEndOfFrame()); } while (corLanding) { yield return(new WaitForEndOfFrame()); } //착륙 끝 corFlame = false; yield return(null); }