Beispiel #1
0
    public override void Shoot(bool firstDown)
    {
        if (!automatic && !firstDown)
        {
            return;
        }

        if (canShoot)
        {
            timeSinceLastShot = 0;
            canShoot          = false;
            canReload         = false;
            reloading         = false;

            if (bulletsInClip > 0)
            {
                ///
                /// Create the bullets
                ///
                player.AudioSource.PlayOneShot(shoot);
                bulletsInClip -= 1;

                for (int i = 0; i < pelletCount; i++)
                {
                    ShotgunPellet bullet = ((GameObject)Instantiate(shotgunPelletPrefab.gameObject)).GetComponent <ShotgunPellet>();
                    bullet.transform.position = bulletSpawnPoint.position;
                    bullet.transform.rotation = bulletSpawnPoint.rotation;
                    bullet.SetHitMarkerCallBack(hitMarkerCallback);
                    bullet.InitBulletTrail(bullet.transform.position);
                    bullet.SetupBulletVelocity(i == 0);

                    //Align(bullet.transform, bulletSpawnPoint.rotation.eulerAngles);
                }

                muzzleFlash.ShowFlash();

                ///
                /// Create the shell
                ///
                Shell_Base shell = (Shell_Base)Instantiate(shellPrefab, shellSpawnPoint.position, transform.rotation * shellSpawnPoint.localRotation);
                shell.AddVelocity(player.Rigidbody.velocity);
            }
            else
            {
                player.AudioSource.PlayOneShot(outOfAmmo);
            }
        }
    }
Beispiel #2
0
    public override void Shoot(bool firstDown)
    {
        if (!automatic && !firstDown)
        {
            return;
        }

        if (timeSinceLastShot >= timeBetweenShoots)
        {
            timeSinceLastShot = 0;

            if (bulletsInClip > 0)
            {
                ///
                /// Create the bullet
                ///
                player.AudioSource.PlayOneShot(shoot);
                bulletsInClip -= 1;

                Bullet bullet = ((GameObject)Instantiate(bulletPrefab)).GetComponent <Bullet>();
                bullet.transform.position = bulletSpawnPoint.position;
                bullet.SetHitMarkerCallBack(hitMarkerCallback);
                bullet.InitBulletTrail(bullet.transform.position);

                Align(bullet.transform, new Vector3(0, 0, 0));

                /*Transform t = ((ParticleSystem)Instantiate(muzzleFlash)).GetComponent<Transform>();
                 * t.position = bulletSpawnPoint.position;
                 * t.rotation = bulletSpawnPoint.rotation;
                 * t.parent = bulletSpawnPoint;*/

                muzzleFlash.ShowFlash();

                ///
                /// Create the shell
                ///
                Shell_Base shell = (Shell_Base)Instantiate(shellPrefab, shellSpawnPoint.position, transform.rotation * shellSpawnPoint.localRotation);
                shell.AddVelocity(player.Rigidbody.velocity);
            }
            else
            {
                player.AudioSource.PlayOneShot(outOfAmmo);
            }
        }
    }