IEnumerator MagicMissileCounter(Collider2D [] colArray, Transform pP) { int i = 0; Transform enemyPos; Vector2 targetVector; foreach (Collider2D col in colArray) { if (col.tag == "Enemy" || col.tag == "BossEnemy") { enemyPos = col.transform; Vector3 enemy = (enemyPos.position + new Vector3(0f, 1.2f)); // 적 머리쪽을향해 발사하게함 targetVector = (enemy - pP.position).normalized; // Vector3 PrefabPosition; // PrefabPosition = bulletPosition.position; GameObject mm = Instantiate(SkillPrefab[5], pP.position, pP.rotation); WeaponInfo magicDamage = mm.GetComponent <WeaponInfo>(); magicDamage.minDamage += magidDamageUp.minDamage; magicDamage.maxDamage += magidDamageUp.maxDamage; polyPlay.playPoly(4); DragonBreathBullet mmBullet = mm.GetComponentInChildren <DragonBreathBullet>(); mmBullet.Init(_cState._isRightDir, targetVector); i++; if (i == colArray.Length - 1 || i == 5) { StopCoroutine("MagicMissileCounter"); } yield return(new WaitForSeconds(0.2f)); } } }
// 최초위치가 계속 적용되서 public void DragonPlayerSense() { if (_monsterState._isDie != true) { Collider2D[] colliders = Physics2D.OverlapCircleAll(gameObject.transform.position, 10f, _monsterState._targetMask); foreach (Collider2D col in colliders) { if (col.tag == "Player") { _animator.SetTrigger("AttackTrigger"); playerPos = col.transform; dragonPos = gameObject.transform; targetVector = (playerPos.position - dragonPos.position).normalized; AttackFlipper(playerPos);// 플리퍼안에서 다시구해서 쏴야할듯 GameObject db = Instantiate(dbPrefab, _breathGenPoint.position, _breathGenPoint.rotation); DragonBreathBullet dbBullet = db.GetComponentInChildren <DragonBreathBullet>(); dbBullet.Init(_monsterState._isRightDir, targetVector); // StartCoroutine(ShootBreath(targetVector)); CancelInvoke("DragonPlayerSense"); StartCoroutine(ShootAgain()); // InvokeRepeating("DragonPlayerSense", 0f, 1f); break; } } } }