Example #1
0
 /// <summary>
 /// Update the top/left ammo info panel (the inventory)
 /// </summary>
 public void UpdateAmmoBagInfo(Constants.AMMO_TYPE ammoType, int ammount)
 {
     foreach (Ammo ammo in ammoList)
     {
         if (ammo.info.ammoType == ammoType)
         {
             ammo.text.text = ammount.ToString();
         }
     }
 }
Example #2
0
 public void ReloadAmmo(Constants.AMMO_TYPE ammoType, int maxClip, int actualAmmo, int perfectAmmo)
 {
     foreach (Ammo ammo in ammoList)
     {
         if (ammo.info.ammoType == ammoType)
         {
             ammo.equipedAmmoText.text = actualAmmo.ToString(); // update the ammount in the clip info
             ammo.ammoUI.Reload(perfectAmmo, actualAmmo, maxClip);
         }
     }
 }
 /// <summary>
 /// Get the info scriptable about the ammo demanded
 /// </summary>
 /// <param name="ammoType">the type of ammo asked</param>
 /// <returns></returns>
 public AmmoInfoScriptable GetAmmoInfo(Constants.AMMO_TYPE ammoType)
 {
     foreach (AmmoInfoScriptable ammo in ammoInfoList)
     {
         if (ammo.ammoType == ammoType)
         {
             return(ammo);
         }
     }
     return(null);
 }
Example #4
0
    /// <summary>
    /// Set to the equiped ammo display, start shoot animation
    /// </summary>
    /// <param name="ammoType">the kind of ammo used</param>
    /// <param name="ammountWasted">the ammount to extract</param>
    /// <param name="ammount">How much left in the clip</param>

    public void Shoot(Constants.AMMO_TYPE ammoType, int ammountWasted, int ammountLeft)
    {
        foreach (Ammo ammo in ammoList)
        {
            if (ammo.info.ammoType == ammoType)
            {
                ammo.equipedAmmoText.text = ammountLeft.ToString(); // update the ammount in the clip info
                if (ammountWasted > 0)
                {
                    ammo.ammoUI.Shoot(ammountWasted);
                }
            }
        }
    }
Example #5
0
 /// <summary>
 /// Active the UI of the ammo equiped
 /// </summary>
 /// <param name="ammoType">The ammo equiped in this moment</param>
 public void EquipAmmo(Constants.AMMO_TYPE ammoType)
 {
     foreach (Ammo ammo in ammoList)
     {
         if (ammo.info.ammoType == ammoType)
         {
             ammo.ammoUIEquiped.SetActive(true);
             actualAmmo = ammo;
         }
         else
         {
             ammo.ammoUIEquiped.SetActive(false);
         }
     }
 }
    IEnumerator CreateItem()
    {
        // create the random ammo, and heals, then the weapons

        List <Constants.AMMO_TYPE> ammos = Enum.GetValues(typeof(Constants.AMMO_TYPE))
                                           .Cast <Constants.AMMO_TYPE>()
                                           .ToList();
        List <Constants.WEAPON_TYPE> weapons = Enum.GetValues(typeof(Constants.WEAPON_TYPE))
                                               .Cast <Constants.WEAPON_TYPE>()
                                               .ToList();

        for (int i = 0; i < ammoToCreate; i++)
        {
            yield return(new WaitForSecondsRealtime(secondsBetweenSpawn));

            int randomIndex             = UnityEngine.Random.Range(0, (ammos.Count - 1));
            Constants.AMMO_TYPE newAmmo = ammos[randomIndex];
            AmmoInfoScriptable  ammo    = WeaponSpawnManager.instance.GetAmmoInfo(newAmmo);
            CreateInstance(ammo.pickableAmmoPrefab);
        }
        for (int i = 0; i < healToCreate; i++)
        {
            yield return(new WaitForSecondsRealtime(secondsBetweenSpawn));

            // only one type of heal at this point
            CreateInstance(healthPrefab);
        }
        for (int i = 0; i < weaponsToCreate; i++)
        {
            yield return(new WaitForSecondsRealtime(secondsBetweenSpawn));

            GameObject weaponToCreate = null;
            if (randomWeapon)
            {
                int randomIndex                  = UnityEngine.Random.Range(0, (weapons.Count - 1));
                Constants.WEAPON_TYPE wType      = weapons[randomIndex];
                WeaponInfoScriptable  weaponInfo = WeaponSpawnManager.instance.GetWeaponInfo(wType);
                weaponToCreate = weaponInfo.pickableWeaponPrefab;
            }
            else
            {
                weaponToCreate = prefabToCreate;
            }
            CreateInstance(weaponToCreate);
        }
    }