void Shoot() { //RaycastHit hit; //Ray ray = new Ray(transform.position, transform.forward); shotCounter -= Time.deltaTime; if (shotCounter <= 0) { shotCounter = timeBetweenShots; BulletController newBullet = Instantiate(bullet, firePoint.position, firePoint.rotation) as BulletController; //newBullet.bSpeed = bulletSpeed; newBullet.Fire(transform.forward); } //if (Physics.Raycast(ray, out hit, 100f)) //{ // Debug.Log("Skrat skrat"); // if (hit.collider.gameObject.tag == "Enemy") // { // enemy = GameObject.FindGameObjectWithTag("Enemy"); // enemyH = enemy.GetComponentInChildren<EnemyHealth>(); // enemyH.TakeDamage(bDamage); // } //} //else //{ // shotCounter = 0; //} }
private void Fire() { if (m_BulletController.IsAvailable) { Bullet.transform.position = transform.position + transform.forward; Bullet.transform.rotation = transform.rotation; m_BulletController.Fire(); } }
protected void ShootBullet() { if (!bulletCooldownFlag) { BulletController bullet = BulletService.Instance.CreateBullet(); bullet.transform.position = bulletSpawnPosition.position; bullet.SetDamage(bulletDamage); bullet.Fire(turret.transform.eulerAngles, bulletSpeed); bulletCooldownFlag = true; StartCoroutine(StartBulletCooldown()); } }
void Shoot() { if (WaveController.instance.waveNumber == 2 || WaveController.instance.waveNumber == 4) { if (countTimeBtwShoot <= 0) { BulletController.Fire(firePos, WaveController.instance.poolPlayerBullet); countTimeBtwShoot = timeBtwShoot; } countTimeBtwShoot -= Time.deltaTime; } }
void Shoot() { if (countTimeBtwShoot < 0 && !defeated) { BulletController.Fire(firePos, WaveController.instance.poolEnemyBullet); countTimeBtwShoot = DifficultyController.instance.shooterTimeBtwShoots; } else { countTimeBtwShoot -= Time.deltaTime; } }
//=================================== // Attack patern //=================================== public void SingleShot() { GameObject aBullet = Instantiate(Resources.Load(PATH_BULLETS)) as GameObject; BulletController aBulletControllerComponent = aBullet.AddComponent <BulletController>(); Bullet aBulletComponent = aBullet.AddComponent <Bullet>(); aBulletComponent.SetUp(100, 20, 50, Bullet.BulletType.NORMAL); aBullet.transform.parent = mInjectionPoint.transform; aBullet.transform.position = mInjectionPoint.transform.position; Vector3 aInjectionPointPosition = new Vector3(mInjectionPoint.transform.position.x, mInjectionPoint.transform.position.y, mInjectionPoint.transform.position.z); aBulletControllerComponent.SetMyTransform(aBullet.transform); Vector3 aTarget = new Vector3(transform.position.x, transform.position.y, transform.position.z + aBulletComponent.Range); aBulletControllerComponent.SetTarget(aTarget); aBulletControllerComponent.Fire(); }
private void Fire() { if (fireSound) { AudioManager.PlayAtPoint(fireSound, transform.position); } CameraShaker.ShakeAt(transform.position, recoilShake); foreach (var fireOrigin in fireOrigins) { BulletController bullet = BulletManager.Get(bulletName); bullet.lifespan = lifespan; bullet.destroyDelay = destroyDelay; bullet.baseSettings = baseSettings; bullet.transform.position = transform.position + transform.right * fireOrigin.offset.x + transform.up * fireOrigin.offset.y + transform.forward * fireOrigin.offset.z; bullet.transform.rotation = transform.rotation * Quaternion.Euler(0, -fireOrigin.rotation, 0); float rad = bullet.transform.eulerAngles.y * Mathf.Deg2Rad; bullet.Fire(new Vector3(Mathf.Cos(rad) * firePower, 0, -Mathf.Sin(rad) * firePower)); } _recoilCoroutine = StartCoroutine(ExeRecoilCoroutine()); }
public void Diffusion() { for (int i = 0; i < 3; i++) { GameObject aBullet = Instantiate(Resources.Load(PATH_BULLETS)) as GameObject; BulletController aBulletController = aBullet.AddComponent <BulletController>(); Bullet aBulletComponent = aBullet.AddComponent <Bullet>(); aBulletComponent.SetUp(100, 20, 50, Bullet.BulletType.NORMAL); aBullet.transform.parent = mInjectionPoint.transform; aBullet.transform.position = mInjectionPoint.transform.position; Vector3 aTarget; switch (i) { case 0: aBullet.name = aBullet.name + "_Center"; aTarget = new Vector3(transform.position.x, transform.position.y, transform.position.z + aBulletComponent.Range); aBulletController.SetTarget(aTarget); break; case 1: aBullet.name = aBullet.name + "_Right"; aTarget = new Vector3(transform.position.x + 5, transform.position.y, transform.position.z + aBulletComponent.Range); aBulletController.SetTarget(aTarget); break; case 2: aBullet.name = aBullet.name + "_Left"; aTarget = new Vector3(transform.position.x - 5, transform.position.y, transform.position.z + aBulletComponent.Range); aBulletController.SetTarget(aTarget); break; } aBulletController.SetMyTransform(aBullet.transform); aBulletController.Fire(); } }
IEnumerator ExecFire(int time, float vx, float vy, Vector3 target) { if (isOnDander) { firedTime++; } float waitSecs = (firedTime - 1) * 0.5f; while (this.isMoving || isOnDander) { yield return(new WaitForSeconds(0.02f)); } yield return(new WaitForSeconds(waitSecs)); SoundManager.GetInstance().PlayEffect("startFire"); movingBullet = Instantiate(bulletPrefab, this.transform.position + new Vector3(0f, 0.2f, 0f), Quaternion.identity); BulletController bCtrl = movingBullet.GetComponent <BulletController>(); bCtrl.SetBall(bulletSprite); bCtrl.Fire(time, vx, vy); bCtrl.SetTarget(target); gameController.CameraToBullet(this); this.PlayAnimation("Fired"); }