Example #1
0
    // index is used to get recoil down at the bottom, otherwise the cases use currentWeapon.weaponIndex
    void FireWeapon(int index, bool isSilent)
    {
        damageData.ResetDamageData(damageData);
        switch (currentWeapon.weaponIndex)
        {
        case 36:
            //Mark3 Assault Rifle
            FireAssault(isSilent);
            break;

        case 37:
            //ER-90 Blaster
            FireBlaster(isSilent);
            break;

        case 38:
            //SV-23 Dartgun
            FireDart(isSilent);
            break;

        case 39:
            //AM-27 Flechette
            FireFlechette(isSilent);
            break;

        case 40:
            //RW-45 Ion Beam
            FireIon(isSilent);
            break;

        case 41:
            //TS-04 Laser Rapier
            FireRapier(isSilent);
            break;

        case 42:
            //Lead Pipe
            FirePipe(isSilent);
            break;

        case 43:
            //Magnum 2100
            FireMagnum(isSilent);
            break;

        case 44:
            //SB-20 Magpulse
            FireMagpulse(isSilent);
            break;

        case 45:
            //ML-41 Pistol
            FirePistol(isSilent);
            break;

        case 46:
            //LG-XX Plasma Rifle
            FirePlasma(isSilent);
            break;

        case 47:
            //MM-76 Railgun
            FireRailgun(isSilent);
            break;

        case 48:
            //DC-05 Riotgun
            FireRiotgun(isSilent);
            break;

        case 49:
            //RF-07 Skorpion
            FireSkorpion(isSilent);
            break;

        case 50:
            //Sparq Beam
            FireSparq(isSilent);
            break;

        case 51:
            //DH-07 Stungun
            FireStungun(isSilent);
            break;
        }

        // TAKE AMMO
        // no weapons subtract more than 1 at a time in a shot, subtracting 1
        // Check weapon type before subtracting ammo or energy
        if (index == 5 || index == 6)
        {
            // Pipe or Laser Rapier
            // ammo is already 0, do nothing.  This is here to prevent subtracting ammo on the first slot of .wepAmmo[index] on the last else clause below
        }
        else
        {
            // Energy weapons so check energy level
            if (index == 1 || index == 4 || index == 10 || index == 14 || index == 15)
            {
                curEnergy.TakeEnergy(currentWeapon.weaponEnergySetting [index]);
            }
            else
            {
                if (currentWeapon.weaponIsAlternateAmmo)
                {
                    WeaponCurrent.WepInstance.currentMagazineAmount2[index]--;

                    // Update the counter
                    MFDManager.a.UpdateHUDAmmoCounts(WeaponCurrent.WepInstance.currentMagazineAmount2[index]);
                }
                else
                {
                    WeaponCurrent.WepInstance.currentMagazineAmount[index]--;

                    // Update the counter
                    MFDManager.a.UpdateHUDAmmoCounts(WeaponCurrent.WepInstance.currentMagazineAmount[index]);
                }
            }
        }



        playerCamera.GetComponent <MouseLookScript>().Recoil(index);
        if (currentWeapon.weaponIsAlternateAmmo)
        {
            waitTilNextFire = Time.time + Const.a.delayBetweenShotsForWeapon2[index];
        }
        else
        {
            waitTilNextFire = Time.time + Const.a.delayBetweenShotsForWeapon[index];
        }
    }
Example #2
0
    // index is used to get recoil down at the bottom and pass along ref for damageData,
    // otherwise the cases use currentWeapon.weaponIndex
    void FireWeapon(int index, bool isSilent)
    {
        damageData.ResetDamageData(damageData);
        switch (currentWeapon.weaponIndex)
        {
        case 36:
            //Mark3 Assault Rifle
            if (!isSilent)
            {
                SFX.clip = SFXMark3Fire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 37:
            //ER-90 Blaster
            if (!isSilent)
            {
                SFX.clip = SFXBlasterFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            if (overloadEnabled)
            {
                blasterHeat = 100f;
            }
            else
            {
                blasterHeat += blasterSetting;
            }
            if (blasterHeat > 100f)
            {
                blasterHeat = 100f;
            }
            break;

        case 38:
            //SV-23 Dartgun
            if (!isSilent)
            {
                SFX.clip = SFXDartFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 39:
            //AM-27 Flechette
            if (!isSilent)
            {
                SFX.clip = SFXFlechetteFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 40:
            //RW-45 Ion Beam
            if (!isSilent)
            {
                SFX.clip = SFXIonFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            if (overloadEnabled)
            {
                ionHeat = 100f;
            }
            else
            {
                ionHeat += ionSetting;
            }
            if (ionHeat > 100f)
            {
                ionHeat = 100f;
            }
            break;

        case 41:
            //TS-04 Laser Rapier
            FireRapier(index, isSilent);
            break;

        case 42:
            //Lead Pipe
            FirePipe(index, isSilent);
            break;

        case 43:
            //Magnum 2100
            if (!isSilent)
            {
                SFX.clip = SFXMagnumFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 44:
            //SB-20 Magpulse
            if (!isSilent)
            {
                SFX.clip = SFXMagpulseFire; SFX.Play();
            }
            FireMagpulse(index);
            break;

        case 45:
            //ML-41 Pistol
            if (!isSilent)
            {
                SFX.clip = SFXPistolFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 46:
            //LG-XX Plasma Rifle
            if (!isSilent)
            {
                SFX.clip = SFXPlasmaFire; SFX.Play();
            }
            FirePlasma(index);
            plasmaHeat += plasmaSetting;
            if (plasmaHeat > 100f)
            {
                plasmaHeat = 100f;
            }
            break;

        case 47:
            //MM-76 Railgun
            if (!isSilent)
            {
                SFX.clip = SFXRailgunFire; SFX.Play();
            }
            FireRailgun(index);
            break;

        case 48:
            //DC-05 Riotgun
            if (!isSilent)
            {
                SFX.clip = SFXRiotgunFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 49:
            //RF-07 Skorpion
            if (!isSilent)
            {
                SFX.clip = SFXSkorpionFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            break;

        case 50:
            //Sparq Beam
            if (!isSilent)
            {
                SFX.clip = SFXSparqBeamFire; SFX.Play();
            }
            if (DidRayHit())
            {
                HitScanFire(index);
            }
            if (overloadEnabled)
            {
                sparqHeat = 100f;
            }
            else
            {
                sparqHeat += sparqSetting;
            }
            if (sparqHeat > 100f)
            {
                sparqHeat = 100f;
            }
            break;

        case 51:
            //DH-07 Stungun
            if (!isSilent)
            {
                SFX.clip = SFXStungunFire; SFX.Play();
            }
            FireStungun(index);
            stungunHeat += stungunSetting;
            if (stungunHeat > 100f)
            {
                stungunHeat = 100f;
            }
            break;
        }

        // TAKE AMMO
        // no weapons subtract more than 1 at a time in a shot, subtracting 1
        // Check weapon type before subtracting ammo or energy
        if (index == 5 || index == 6)
        {
            // Pipe or Laser Rapier
            // ammo is already 0, do nothing.  This is here to prevent subtracting ammo on the first slot of .wepAmmo[index] on the last else clause below
        }
        else
        {
            // Energy weapons so check energy level
            if (index == 1 || index == 4 || index == 10 || index == 14 || index == 15)
            {
                if (overloadEnabled)
                {
                    energoverButton.OverloadFired();
                    curEnergy.TakeEnergy(Const.a.energyDrainOverloadForWeapon[index]); //take large amount
                }
                else
                {
                    float takeEnerg = (currentWeapon.weaponEnergySetting[index] / 100f) * (Const.a.energyDrainHiForWeapon[index] - Const.a.energyDrainLowForWeapon[index]);
                    curEnergy.TakeEnergy(takeEnerg);
                }
            }
            else
            {
                if (currentWeapon.weaponIsAlternateAmmo)
                {
                    WeaponCurrent.WepInstance.currentMagazineAmount2[index]--;

                    // Update the counter
                    MFDManager.a.UpdateHUDAmmoCounts(WeaponCurrent.WepInstance.currentMagazineAmount2[index]);
                }
                else
                {
                    WeaponCurrent.WepInstance.currentMagazineAmount[index]--;

                    // Update the counter
                    MFDManager.a.UpdateHUDAmmoCounts(WeaponCurrent.WepInstance.currentMagazineAmount[index]);
                }
            }
        }



        playerCamera.GetComponent <MouseLookScript>().Recoil(index);
        if (currentWeapon.weaponIsAlternateAmmo || overloadEnabled)
        {
            overloadEnabled = false;
            waitTilNextFire = Time.time + Const.a.delayBetweenShotsForWeapon2[index];
        }
        else
        {
            waitTilNextFire = Time.time + Const.a.delayBetweenShotsForWeapon[index];
        }
    }