Ejemplo n.º 1
0
 // Reloading
 internal virtual void StartReloading()
 {
     if (!isReloading && currentSlot.currentAmmo < maxAmmo && !AmmoBackpack.IsEmpty(currentSlot.ammoIndex))
     {
         StartCoroutine(PlayReload());
     }
 }
Ejemplo n.º 2
0
        // FinalStage Shooting
        protected override void FinalStageShooting()
        {
            if (currentSlot.projectileObject != null)
            {
                if (projectilesPerShot > 1)
                {
                    for (int i = 0; i < projectilesPerShot; i++)
                    {
                        MuzzleToCameraPoint();
                        Projectile.SpawnFromWeapon(this);
                        projectileOuter.localEulerAngles = nativeOuterAngles;
                    }
                }
                else
                {
                    Projectile.SpawnFromWeapon(this);
                    projectileOuter.localEulerAngles = nativeOuterAngles;
                }

                Shell.SpawnFromWeapon(this);
            }
            else
            {
                Debug.LogError("ERROR: Projectile is not setup! Error in: " + this.name);
            }

            base.FinalStageShooting();

            if (owner.isPlayer && isEmpty && AmmoBackpack.IsEmpty(currentSlot.ammoIndex) == false)
            {
                StartReloading();
            }
        }
Ejemplo n.º 3
0
 // FirstStage Shooting
 protected override void FirstStageShooting()
 {
     if (owner.isPlayer)
     {
         if (isEmpty)
         {
             if (AmmoBackpack.IsEmpty(currentSlot.ammoIndex))
             {
                 m_Audio.pitch = Time.timeScale;
                 m_Audio.PlayOneShot(emptySFX);
                 StartCoroutine(FireRate(.75f));
             }
             else
             {
                 StartReloading();
             }
         }
         else if (!isEmpty && !isReloading)
         {
             base.FirstStageShooting();
         }
     }
     else if (owner.isNPC)
     {
         SecondStageShooting();
     }
 }
Ejemplo n.º 4
0
        // Start
        void Start()
        {
            for (int i = 0; i < weapons.Length; i++)
            {
                WeaponSlot currentSlot = weapons[i];
                GameObject currentGO   = currentSlot.weapon.gameObject;

                currentGO.SetActive(true);

                if (currentSlot.type == EWeaponType.Thrown)
                {
                    Firearms tmpFA = currentSlot.weapon as Firearms;

                    if (!tmpFA.isEmpty || !AmmoBackpack.IsEmpty(tmpFA.currentSlot.ammoIndex))
                    {
                        currentSlot.available = true;
                    }
                    else if (AmmoBackpack.IsEmpty(tmpFA.currentSlot.ammoIndex) && tmpFA.isEmpty)
                    {
                        currentSlot.available = false;
                    }
                }

                if (weaponsCount >= maxWeapons && currentSlot.type == EWeaponType.Standart)
                {
                    DropWeapon(i);
                }
                else if (currentSlot.available && currentSlot.type == EWeaponType.Standart)
                {
                    weaponsCount++;
                }

                currentGO.SetActive(false);
            }

            for (int i = weaponIndex; i < weapons.Length; i++)
            {
                if (i != weaponIndex && weapons[i].available)
                {
                    weaponIndex = i;
                    StartCoroutine(ChangeWeapon());
                    break;
                }
            }

            UpdateHud();
            UpdateInformerAndCrosshair();
        }
Ejemplo n.º 5
0
 // ChangeEmpty to FirstAvaliable
 internal static void ChangeEmptyToFirstAvaliable()
 {
     if (!FirstPersonWeaponSway.isChanging && AmmoBackpack.IsEmpty(m_Firearm.currentSlot.ammoIndex))
     {
         if (m_Instance.weapons[weaponIndex].type == EWeaponType.Thrown)
         {
             m_Instance.weapons[weaponIndex].available = false;
             FindFirstAvailableWeapon();
             CalculateWeaponsCount();
             m_Instance.StartCoroutine(ChangeWeapon());
         }
         else
         {
             if (FindFirstAvailableWeapon())
             {
                 m_Instance.StartCoroutine(ChangeWeapon());
             }
         }
     }
 }