private void SuicideShots() { int max = 8; for (int i = 0; i < max; i++) { GameObject bulletObject = pool.Get(); BulletLine bullet = bulletObject.GetComponent <BulletLine>(); if (bullet) { bulletObject.SetActive(true); Vector2 direction = RaposUtil.RotateVector(Vector2.up, (360 / max) * i); bullet.Launch(direction * bulletSpeed); bulletObject.transform.position = transform.position; } } }
void Fire() { //TODO: 부하 감소를 위해 IEnumerator으로 구현하기 //TODO: 무기 종류&탄약 종류에 따라 다양한 총알 발사하기 var bullet = Instantiate(BulletPool.Get("bullet"), firingPosition.position, firingPosition.rotation); bullet.GetComponent <Bullet>().Initialize(gameObject.tag, bulletSpeed); firingPosition.gameObject.GetComponent <AudioSource>().Play(); }
public void Shoot() { if (Time.time - lastFired > fireRate) { Bullet bullet = pool.Get(); bullet.transform.position = muzzleTransform.position; bullet.transform.rotation = Quaternion.Euler(0, muzzleTransform.eulerAngles.y, 0); lastFired = Time.time; } }
private void ShootControl(IPeer peer) { if (boxes.TryGetValue(peer.Id, out ServerSimpleBox box)) { Bullet bullet = bulletPool.Get(bulletIdPool.NewID()); bullet.direction = box.Direction; bullet.transform.position = box.transform.position + box.Direction; bullets.Add(bullet); } }
public void Shoot() { if (Time.time < _lastShotTime + _shotCooldown) { return; } var bullet = _bulletPool.Get(); bullet.Setup(FiringPoint, _currentColor, _shotSpeed, _shotExpirationTime); _lastShotTime = Time.time; }
private void Shoot() { m_animator.SetTrigger("Shoot"); shotFX.Play(); GameObject bulletObject = pool.Get(); bulletObject.transform.position = transform.position; bulletObject.SetActive(true); CannonBall bulletScript = bulletObject.GetComponent <CannonBall>(); bulletScript.Launch(RaposUtil.RotateVector(Vector2.up, transform.rotation.eulerAngles.z) * bulletSpeed); }
private IEnumerator ShootAction() { while (true) { BulletLine bullet; if (!spreadShotsUpgrade) { bullet = bulletPool.Get().GetComponent <BulletLine>(); if (bullet) { Shoot(bullet); } } else { float offsetY = .2f; bullet = bulletPool.Get().GetComponent <BulletLine>(); if (bullet) { Shoot(bullet, offsetY); } bullet = bulletPool.Get().GetComponent <BulletLine>(); if (bullet) { Shoot(bullet, -offsetY); } } for (int i = 0; i < shotDelay; i++) { yield return(new WaitForFixedUpdate()); } } }
public bool Shoot(Vector3 origin, Vector3 direction) { GameObject bullet = BulletPool.Get(); if (bullet == null) { return(false); } Bullet bulletProperties = bullet.GetComponent <Bullet>(); bullet.transform.position = origin; bulletProperties.SetOwner(this.gameObject); bulletProperties.SetProperties(this.damage, this.bulletSpeed, direction); bullet.SetActive(true); return(true); }
public static GameObject LoadBullet(string bulletName) { GameObject bullet = null; //先从对象池中取出 bullet = BulletPool.Get(bulletName); if (bullet == null) { //Debug.Log("强行生成子弹"); Object b = Resources.Load("Bullet/" + bulletName); bullet = GameObject.Instantiate((GameObject)b); } return(bullet); }
protected override IEnumerator AttackCicle() { yield return(new WaitForSeconds(.5f)); offsetCicle = false; while (true) { spawnedBullets = new List <Bullet>(); m_animator.SetInteger("State", 1); for (int i = 0; i < bulletsPerCicle; i++) { GameObject bulletObject = pool.Get(); BulletLine bullet = bulletObject.GetComponent <BulletLine>(); if (bullet) { bulletObject.SetActive(true); Vector2 direction = RaposUtil.RotateVector(Vector3.up, i * (360 / bulletsPerCicle) + (offsetCicle ? (180 / bulletsPerCicle) : 0)); bulletObject.transform.rotation = Quaternion.Euler(Vector3.forward * (Vector2.SignedAngle(Vector2.up, direction) + 90)); bulletObject.transform.position = transform.position; InheritAnchorMovement inheritAnchorMovement = bullet.GetComponent <InheritAnchorMovement>(); if (inheritAnchorMovement != null) { inheritAnchorMovement.enabled = true; inheritAnchorMovement.Set(transform); } bullet.StartCoroutine(PositionBullet(bulletObject.transform, (Vector3)(direction * 1f))); spawnedBullets.Add(bullet); yield return(new WaitForSeconds(.03f)); } } yield return(new WaitForSeconds(.5f)); ReleaseBullets(); m_animator.SetInteger("State", 2); yield return(new WaitForSeconds(1)); offsetCicle = !offsetCicle; } }
public virtual void Shoot() { if (OnFireDistance()) { var bullet = bp.Get(); if (bullet == null) { return; } bullet.Spawn(firePosition.position, firePosition.forward, damage, false); bp.AddBullet(bullet); canShoot = false; fireTime = Random.Range(minFireTime, maxFireTime); enem.audioSource.clip = shootAudio; enem.audioSource.Play(); } }