Пример #1
0
    public override void Fire()
    {
        if (hasDespawnTimer == false)
        {
            Rigidbody TempRigidbody = GetComponent <Rigidbody>();
            TempRigidbody.useGravity  = false;
            TempRigidbody.isKinematic = true;
        }

        foreach (GameObject i in projectileOrigins)
        {
            for (int x = 0; x < projectilesToFire; x++)
            {
                Rigidbody clone =
                    Instantiate(projectile,
                                i.transform.position,
                                i.transform.rotation);

                Projectile_Class projectileClone = clone.GetComponent <Projectile_Class>();

                projectileClone.ProjectileDamage = projectileClone.ProjectileDamage * DamageModifer;

                clone.transform.Rotate
                    (Random.Range(-1 * projectileSpread, projectileSpread),
                    Random.Range(-1 * projectileSpread, projectileSpread),
                    0);

                clone.AddForce(clone.transform.forward * projectileSpeed);
            }
        }
    }
    public override void Fire()
    {
        if (currentWeaponState == State.Ready && currentAmmo > 0)
        {
            currentAmmo = currentAmmo - 1;
            //////////////////////////////////////////////////////////////
            if (PrimaryWeaponAudioSource.clip != Clip_Shot)
            {
                PrimaryWeaponAudioSource.clip = Clip_Shot;
            }

            StartCoroutine(ShotSound());
            ///////////////////////////////////////////////////////////////////

            // Play Shot sound ////////////////////////////////////////////////////
            //WeaponAudioSource.clip = Clip_Shot;
            //WeaponAudioSource.Play();
            ///////////////////////////////////////////////////////////////////////

            foreach (GameObject i in projectileOrigins)
            {
                Rigidbody clone =
                    Instantiate(projectile,
                                i.transform.position,
                                i.transform.rotation);

                Projectile_Class projectileClone = clone.GetComponent <Projectile_Class>();

                if (projectileClone != null)
                {
                    projectileClone.ProjectileDamage = projectileClone.ProjectileDamage * DamageModifer;
                }

                Throwable_Class throwableClone = clone.GetComponent <Throwable_Class>();

                if (throwableClone != null)
                {
                    throwableClone.SetLive();
                }

                clone.transform.Rotate
                    (Random.Range(-1 * ProjectileSpread, ProjectileSpread),
                    Random.Range(-1 * ProjectileSpread, ProjectileSpread),
                    0);

                clone.AddForce(clone.transform.forward * projectileSpeed);
            }

            StartCoroutine(FireRateCoolDown());
        }
    } /////