IEnumerator ZZShotgun() { for (int i = 0; i >= 0; i++) { Vector3 vec = new Vector3(0, 0, 1); int tj = Random.Range(-8, 20); for (int j = -8; j < 28; j++) { GameObject bullet; if (i % 2 == 1) { bullet = BulletUtil.LoadBullet("红边圆"); } else { bullet = BulletUtil.LoadBullet("蓝边圆"); } bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(10 * j, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 1.0f; bulletInfo.Fire(); } Vector3 flowerVec = new Vector3(0, 0, 1); flowerVec = Quaternion.AngleAxis(Random.Range(0, 36) * 10, Vector3.up) * vec; for (int j = 0; j < 7; j++) { GameObject bullet; if (i % 2 == 1) { bullet = BulletUtil.LoadBullet("红花"); } else { bullet = BulletUtil.LoadBullet("蓝花"); } bullet.transform.position = shooter.GetPos() + new Vector3(0, 0.3f, 0);; bullet.transform.forward = Quaternion.AngleAxis(10 * j, Vector3.up) * flowerVec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 1.0f; bulletInfo.Fire(); } yield return(new WaitForSeconds(3.5f)); } }
IEnumerator ZZShotgun() { Vector3[] bulletsPos = new Vector3[20]; float distance = 0.4f; Vector3 vec = new Vector3(0, 0, 1); for (int a = 0; a < 1; a++) { for (int i = 0; i < 20; i++) { bulletsPos[i] = shooter.GetPos() + Quaternion.AngleAxis(18 * i, Vector3.up) * vec * distance; distance += 0.2f; } for (int i = 0; i < 20; i++) { for (int j = -8; j < 29; j++) { GameObject bullet2 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet2.transform.position = bulletsPos[i]; bullet2.transform.forward = Quaternion.AngleAxis(10 * j, Vector3.up) * vec; IBullet bulletInfo2 = bullet2.GetComponent <IBullet>(); bulletInfo2.shooter = shooter; bulletInfo2.Fire(); bulletInfo2.speed = 3.0f; } yield return(new WaitForSeconds(0.1f)); } } }
private IEnumerator FireCoroutine(Transform target, GameObject bulletPrefab) { if (target != null && bulletPrefab != null) { if (anim != null && anim.runtimeAnimatorController != null) { foreach (AnimationClip clip in anim.runtimeAnimatorController.animationClips) { if (clip.name == "Attack") { anim.SetTrigger("attack"); break; } } } // Chờ hết thời gian chờ thì đánh tiếp yield return(new WaitForSeconds(fireDelay)); if (target != null) { GameObject arrow = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); IBullet bullet = arrow.GetComponent <IBullet>(); bullet.SetDamage(damage); bullet.Fire(target); if (sfx != null && AudioManager.instance != null) { AudioManager.instance.PlayAttack(sfx); } } } }
void ZZShotgun() { IBullet[] bullets = new IBullet[40]; Vector3 vec = new Vector3(0, 0, 1); for (int i = 0; i < 18; i++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(20 * i, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.Fire(); bullets[i] = bulletInfo; bulletInfo.speed = 5.0f; } if (count % 2 == 0) { for (int j = 0; j < 18; j++) { GameObject bullet = BulletUtil.LoadBullet("米粒"); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(20 * j, Vector3.up) * vec1; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 5; bulletInfo.Fire(); } vec1 = Quaternion.AngleAxis(10, Vector3.up) * vec1; } }
IEnumerator ZZShotgun() { for (int i = 0; i < 4; i++) { Vector3 vec = new Vector3(0, 0, 1); Vector3 flowerVec = new Vector3(0, 0, 1); flowerVec = Quaternion.AngleAxis(Random.Range(0, 36) * 10, Vector3.up) * vec; for (int j = 0; j < 7; j++) { GameObject bullet; bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(10 * j, Vector3.up) * flowerVec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 1.5f; bulletInfo.Fire(); } yield return(new WaitForSeconds(2.0f)); } }
IEnumerator ZZShotgun() { Vector3 vec = GetVec(); for (int i = -9; i < 36; i++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(20 * i, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 5; bulletInfo.delay = 0; bulletInfo.Fire(); GameObject bullet2 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet2.transform.position = shooter.GetPos(); bullet2.transform.forward = Quaternion.AngleAxis(20 * i, Vector3.down) * vec; IBullet bulletInfo2 = bullet2.GetComponent <IBullet>(); bulletInfo2.shooter = shooter; bulletInfo2.speed = 5; bulletInfo2.delay = 0; bulletInfo2.Fire(); yield return(new WaitForSeconds(0.1f)); } }
public string Fire(IBullet Bullet) { if (Bullet.Caliber == Caliber) { return(Bullet.Fire()); } return("improper caliber"); }
public void Fire() { animator.Play("fire"); IBullet bullet = BulletManager.Instance.Spawn(BarrelEnd.position, transform.rotation, bulletPrefab); bullet.Fire(); GunFireParticles.ForEach(p => p.Play()); }
void GhRing() { for (int j = 0; j < 18; j++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(20 * j, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 5; bulletInfo.Fire(); } vec = Quaternion.AngleAxis(10, Vector3.up) * vec; }
/// <summary> /// Make ranged attack /// </summary> /// <param name="target">Target.</param> private void Fire(Transform target) { if (target != null) { // Create arrow GameObject arrow = Instantiate(arrowPrefab, firePoint.position, firePoint.rotation); IBullet bullet = arrow.GetComponent <IBullet>(); bullet.SetDamage(damage); bullet.Fire(target); if (anim != null) { anim.SetTrigger("attackRanged"); } } }
IEnumerator ZZShotgun() { Vector3 vec = new Vector3(0, 0, 1); for (int j = -8; j < 1; j++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(45 * j, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.Fire(); } yield return(new WaitForSeconds(0.5f)); }
public void DropPoint() { //随机掉落点数 int count = UnityEngine.Random.Range(-2, 5); if (count <= 0) { return; } GameObject bullet = BulletUtil.LoadBullet(UnityEngine.Random.Range(0, 2) == 0?"ppt":"hpt"); IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = this; bullet.transform.position = transform.position; bulletInfo.Fire(); }
//射击方法,需要重写 public override void Fire() { Vector3 vec = GetVec(); for (int i = -1 * count; i < count; i++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(20 * i, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.speed = 10; bulletInfo.delay = 3; bulletInfo.Fire(); } }
//射击方法,需要重写 public override void Fire() { Vector3 vec = new Vector3(0, 0, 1); for (int i = -1; i < 2; i++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos() + new Vector3(i * 0.5f, 0, 0); // bullet.transform.forward = Quaternion.AngleAxis(30 * i, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.Fire(); } }
IEnumerator ZZShotgun() { IBullet[] bullets = new IBullet[20]; Vector3 vec = new Vector3(0, 0, 1); for (int a = 0; a < 1; a++) { for (int i = 0; i < 12; i++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = Quaternion.AngleAxis(30 * i, Vector3.up) * vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.Fire(); bullets[i] = bulletInfo; bulletInfo.speed = 3.0f; yield return(new WaitForSeconds(0.1f)); } yield return(new WaitForSeconds(1.0f)); for (int i = 0; i < 12; i++) { bullets[i].Recycle(); for (int j = -8; j < 29; j++) { GameObject bullet2 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet2.transform.position = bullets[i].transform.position; bullet2.transform.forward = Quaternion.AngleAxis(10 * j, Vector3.up) * vec; IBullet bulletInfo2 = bullet2.GetComponent <IBullet>(); bulletInfo2.shooter = shooter; bulletInfo2.Fire(); bulletInfo2.speed = 3.0f; } } } }
IEnumerator ZZShotgun() { Vector3 vec = new Vector3(0, 0, -1); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.Fire(); yield return(new WaitForSeconds(0.3f)); } yield return(new WaitForSeconds(1f)); } }
/// <summary> /// Make ranged attack /// </summary> /// <param name="target">Target.</param> public void Fire(Transform target) { if (target != null) { // Create arrow GameObject arrow = Instantiate(arrowPrefab, firePoint.position, firePoint.rotation); IBullet bullet = arrow.GetComponent <IBullet> (); bullet.SetDamage(damage); bullet.Fire(target); if (target.position.x < transform.position.x) { anim.SetBool("shootleft", true); anim.SetBool("shootright", false); anim.SetBool("idle", false); } else { anim.SetBool("shootright", true); anim.SetBool("shootleft", false); anim.SetBool("idle", false); } } }
private IEnumerator FireCoroutine(Transform target, GameObject bulletPrefab) { if (target != null && bulletPrefab != null) { // If unit has animator if (anim != null && anim.runtimeAnimatorController != null) { // Search for clip foreach (AnimationClip clip in anim.runtimeAnimatorController.animationClips) { if (clip.name == "Attack") { // Play animation anim.SetTrigger("attack"); break; } } } // Delay to synchronize with animation yield return(new WaitForSeconds(fireDelay)); if (target != null) { // Create arrow GameObject arrow = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); IBullet bullet = arrow.GetComponent <IBullet>(); bullet.SetDamage(damage); bullet.Fire(target); // Play sound effect if (sfx != null && AudioManager.instance != null) { AudioManager.instance.PlayAttack(sfx); } } } }
public void Reload(IBullet bulletChange) { bulletChange.Fire(); }
IEnumerator ZZShotgun() { Vector3 vec = new Vector3(0, 0, -1); Quaternion leftrota = Quaternion.AngleAxis(-10, Vector3.up); Quaternion rightrota = Quaternion.AngleAxis(10, Vector3.up); for (int i = 0; i < 3; i++) { for (int j = 9; j < 14; j++) { switch (j) { case 9: GameObject bullet = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet.transform.position = shooter.GetPos(); bullet.transform.forward = vec; IBullet bulletInfo = bullet.GetComponent <IBullet>(); bulletInfo.shooter = shooter; bulletInfo.Fire(); break; case 10: GameObject bullet2 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet2.transform.position = shooter.GetPos(); bullet2.transform.forward = leftrota * vec; IBullet bulletInfo2 = bullet2.GetComponent <IBullet>(); bulletInfo2.shooter = shooter; bulletInfo2.Fire(); break; case 11: GameObject bullet3 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet3.transform.position = shooter.GetPos(); bullet3.transform.forward = rightrota * vec; IBullet bulletInfo3 = bullet3.GetComponent <IBullet>(); bulletInfo3.shooter = shooter; bulletInfo3.Fire(); break; case 12: GameObject bullet4 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet4.transform.position = shooter.GetPos(); bullet4.transform.forward = rightrota * rightrota * vec; IBullet bulletInfo4 = bullet4.GetComponent <IBullet>(); bulletInfo4.shooter = shooter; bulletInfo4.Fire(); break; case 13: GameObject bullet5 = BulletUtil.LoadBullet(shooter.GetBulletName()); bullet5.transform.position = shooter.GetPos(); bullet5.transform.forward = leftrota * leftrota * vec; IBullet bulletInfo5 = bullet5.GetComponent <IBullet>(); bulletInfo5.shooter = shooter; bulletInfo5.Fire(); break; } } yield return(new WaitForSeconds(0.5f)); } }