Example #1
0
 IEnumerator ShootContinuously()
 {
     while (true)
     {
         GameObject bullet = Instantiate(bulletPrefab, transform.position + GetOffset(gunDirection, gameObject), Quaternion.identity);
         bullet.transform.SetParent(gameSpace);
         PlayerBullet bulletScript = bullet.GetComponent <PlayerBullet>();
         bulletScript.Create(bulletSpeed, bulletDamage, gunDirection);
         yield return(new WaitForSeconds(fireRate));
     }
 }
Example #2
0
    public void Shoot(AudioSource GunSound)
    {
        PlayerBullet bullet    = PlayerBullet.Create();
        float        speed     = 1.0f;
        Vector3      PlayerDir = new Vector3(transform.position.x + (int)dxBuf1 * 6, transform.position.y + (int)dyBuf1 * 6, transform.position.z);
        Vector3      BulletDir = new Vector3(transform.position.x + (dxBuf1 * 3 / 4), transform.position.y + (dyBuf1 * 3 / 4), transform.position.z);

        bullet.Shoot(BulletDir, PlayerDir);
        GunSound.Play();
        if (Count > Interval)
        {
            Count = 0;
        }
        MuzzleFlash();
    }