IEnumerator delayBullet1() { int count = 20; float angle = -count / 2f * 5f; for (int i = 0; i < count; i++) { GameObject obj = GameObject.Instantiate(ultimateBullet); PosBullet bullet = obj.GetComponent <PosBullet>(); bullet.player = transform; bullet.tarPos = MathUtil.calcTargetPosByRotation(transform, angle + i * 10f, 10f); bullet.effectObj = damageEffect1; bullet.bulleting(); yield return(new WaitForSeconds(0.1f)); if (i % 9 == 0) { AttackedController c = GameObject.Find("bigzhangjiao (1)").GetComponent <AttackedController>(); c.attacked(); if (damageEffect2 != null) { GameObject obj1 = GameObject.Instantiate(damageEffect2); ParticlesEffect effect = obj1.AddComponent <ParticlesEffect>(); Transform target = GameObject.Find("bigzhangjiao (1)").transform; effect.transform.position = MathUtil.findChild(target, "attackedPivot").position; effect.play(); } } } }
IEnumerator delayBullet() { int count = 10; AttackedController c = GameObject.Find("bigzhangjiao (1)").GetComponent <AttackedController>(); for (int i = 0; i < count; i++) { GameObject obj = GameObject.Instantiate(attackBullet); PosBullet bullet = obj.GetComponent <PosBullet>(); bullet.player = transform; Vector3 newPos = c.transform.position + new Vector3(Random.Range(-5f, 5f), Random.Range(2f, 5f), Random.Range(-5f, 5f)); Vector3 attackedPos = MathUtil.findChild(c.transform, "attackedPivot").position; bullet.startPos = MathUtil.calcTargetPosByRotation(attackedPos, Quaternion.LookRotation(newPos - c.transform.position), 0f, 5f); bullet.tarPos = attackedPos - bullet.startPos + attackedPos; bullet.effectObj = damageEffect1; bullet.bulleting(); yield return(null); if (i % 9 == 0) { c.attacked(); if (damageEffect2 != null) { GameObject obj1 = GameObject.Instantiate(damageEffect2); ParticlesEffect effect = obj1.AddComponent <ParticlesEffect>(); Transform target = GameObject.Find("bigzhangjiao (1)").transform; effect.transform.position = MathUtil.findChild(target, "attackedPivot").position; effect.play(); } } } }
IEnumerator delayBullet() { int count = 30; for (int i = 0; i < count; i++) { GameObject obj = GameObject.Instantiate(ultimateBullet); PosBullet bullet = obj.GetComponent <PosBullet>(); bullet.player = transform; AttackedController c = GameObject.Find("bigzhangjiao (1)").GetComponent <AttackedController>(); Vector3 basePos = transform.position + c.transform.position; basePos /= 2f; basePos.y -= 3f; bullet.startPos = basePos; float padding = 5f; basePos += new Vector3(Random.Range(-padding, padding), 0f, Random.Range(-padding, padding)); bullet.tarPos = basePos += new Vector3(0f, 10f, 0f); bullet.effectObj = damageEffect1; bullet.bulleting(); yield return(null); if (i % 9 == 0) { c.attacked(); if (damageEffect2 != null) { GameObject obj1 = GameObject.Instantiate(damageEffect2); ParticlesEffect effect = obj1.AddComponent <ParticlesEffect>(); Transform target = GameObject.Find("bigzhangjiao (1)").transform; effect.transform.position = MathUtil.findChild(target, "attackedPivot").position; effect.play(); } } } }