Пример #1
0
 public void Shot(bool firstShot, bool isCutAnimPlaying, GameTime gameTime)
 {
     if (_weaponPossessed[_selectedWeapon]._wepType != 2)
     {
         if (firstShot)
         {
             _dryFirePlayed = false;
         }
         if (firstShot && !_weaponPossessed[_selectedWeapon]._isAutomatic)
         {
             InternFire();
         }
         else if (_weaponPossessed[_selectedWeapon]._isAutomatic)
         {
             if (gameTime.TotalGameTime.TotalMilliseconds - _lastShotMs >= _weaponPossessed[_selectedWeapon]._shotPerSeconds)
             {
                 InternFire();
                 _lastShotMs = gameTime.TotalGameTime.TotalMilliseconds;
             }
         }
     }
     else
     {
         if (isCutAnimPlaying)
         {
             CSoundManager.PlayInstance("WEP." + _weaponPossessed[_selectedWeapon]._shotSound);
         }
     }
 }
Пример #2
0
        public void LoadContent(ContentManager content, Dictionary <string, Model> modelsList, Dictionary <string, Texture2D> weapTexture, List <object[]> weaponsInfo, List <string[]> weaponsSounds, List <string[]> weapAnim,
                                List <float[]> animVelocity)
        {
            if ((modelsList.Count != weaponsInfo.Count || modelsList.Count != weaponsSounds.Count) && weapAnim.Count != modelsList.Count)
            {
                throw new Exception("Weapons Loading Error - Arrays of different lengths");
            }

            _weaponsAmount = modelsList.Count;
            _weaponsArray  = new List <WeaponData>();

            // Initializing sounds
            for (int i = 0; i < weaponsSounds.Count; i++)
            {
                for (int x = 0; x < weaponsSounds[i].Length; x++)
                {
                    if (weaponsSounds[i][x] != "")
                    {
                        CSoundManager.AddSound("WEP." + weaponsSounds[i][x], content.Load <SoundEffect>(weaponsSounds[i][x]), (bool)weaponsInfo[i][5], (float)weaponsInfo[i][11]);
                        CSoundManager.AddSound("WEP.MULTI." + weaponsSounds[i][x], content.Load <SoundEffect>(weaponsSounds[i][x]), (bool)weaponsInfo[i][5], (float)weaponsInfo[i][11], new AudioListener(), new AudioEmitter());
                    }
                }
            }
            for (int i = 0; i < _weaponsAmount; i++)
            {
                _weaponsArray.Add(new WeaponData(modelsList[(string)weaponsInfo[i][12]], weaponsInfo[i], weaponsSounds[i], weapAnim[i], animVelocity[i], weapTexture[(string)weaponsInfo[i][12]]));
            }

            // We add the switching sounds
            SoundEffect changeWeapSound, changeWeapSound2, changeWeapSound3, pickup;

            changeWeapSound  = content.Load <SoundEffect>("Sounds\\Weapons\\CHANGEWEAPON1");
            changeWeapSound2 = content.Load <SoundEffect>("Sounds\\Weapons\\CHANGEWEAPON2");
            changeWeapSound3 = content.Load <SoundEffect>("Sounds\\Weapons\\SWITCH_MACHETE");
            pickup           = content.Load <SoundEffect>("Sounds\\Weapons\\PICKUPWEAPON");
            CSoundManager.AddSound("SWITCHWEAPON1", changeWeapSound, false, 0.0f);
            CSoundManager.AddSound("SWITCHWEAPON2", changeWeapSound2, false, 0.0f);
            CSoundManager.AddSound("PICKUPWEAPON", pickup, false, 0.0f);
            CSoundManager.AddSound("SWITCH_MACHETE", changeWeapSound3, false, 0.0f);

            // Initialize the weapon possessed
            _weaponPossessed = new List <WeaponData>();
            _weaponPossessed.Add(_weaponsArray[0]);
        }
Пример #3
0
 private void InternFire()
 {
     if (_weaponPossessed[_selectedWeapon]._actualClip > 0)
     {
         _weaponPossessed[_selectedWeapon]._actualClip--;
         CSoundManager.PlaySound("WEP." + _weaponPossessed[_selectedWeapon]._shotSound);
     }
     else
     {
         // DO not play the dry fire if the weapon is a bow
         if (_weaponPossessed[_selectedWeapon]._wepType != 3)
         {
             if (!_dryFirePlayed)
             {
                 CSoundManager.PlaySound("WEP." + _weaponPossessed[_selectedWeapon]._dryShotSound);
                 _dryFirePlayed = true;
             }
         }
     }
     //Console.WriteLine("Weapon : " + _weaponPossessed[_selectedWeapon]._name + " Bullet avaible : " + _weaponPossessed[_selectedWeapon]._bulletsAvailable + " \n ActualClip : " + _weaponPossessed[_selectedWeapon]._actualClip);
 }