/// <summary> /// Sets up the ammo type image based on ammo being used. /// </summary> private void RefreshAmmoTypeImage() { // get currently equipped ammo pouch AmmoPouch equippedAmmoPouch = _uiManager.UiPlayerCharacter.GetEquippedAmmoPouch(); // if pouch found if (equippedAmmoPouch != null) { // load sprite icon associated with type of ammo being used Sprite ammoTypeIcon = AssetRefMethods.LoadBundleAssetWeaponTypeSetIcon( equippedAmmoPouch.ammoType.setId); // if sprite successfully loaded if (ammoTypeIcon != null) { // set ammo type image to loaded sprite imageAmmoType.sprite = ammoTypeIcon; // turn ON ammo type image object imageAmmoType.gameObject.SetActive(true); // DONT continue code return; } } // getting here means that ammo type image should NOT be used, so turn OFF the image object imageAmmoType.gameObject.SetActive(false); }
private void Setup(AmmoPouch templateArg) { ammoType = new WeaponTypeSet(templateArg.ammoType); currentAmmo = templateArg.currentAmmo; maxAmmo = templateArg.maxAmmo; }
/// <summary> /// Refreshes the current ammo bar's fill. /// </summary> private void RefreshAmmoBarCount() { // get currently equipped ammo pouch AmmoPouch equippedAmmoPouch = _uiManager.UiPlayerCharacter.GetEquippedAmmoPouch(); // if pouch found if (equippedAmmoPouch != null) { // refresh ammo bar based on ammo pouch RefreshBarValue(equippedAmmoPouch.currentAmmo); } }
/// <summary> /// Fully sets up the ammo bar properties. /// </summary> private void RefreshAmmoBarFull() { // get player char the UI is associated with PlayerCharacterMasterController playerChar = _uiManager.UiPlayerCharacter; // if player char found if (playerChar != null) { // get weapon slot currently being used WeaponSlotData equippedWepSlot = playerChar.GetEquippedWeaponSlot(); // if weapon slot found if (equippedWepSlot != null) { // get currently equipped weapon WeaponData equippedWep = playerChar.GetEquippedWeapon(); // if a weapon IS equipped if (equippedWep != null) { // if wep slot's wep type set DOES need ammo to be used (i.e. NOT infinite ammo) if (equippedWepSlot.requiredWeaponTypeSet.doesNeedAmmo) { // get currently equipped ammo pouch AmmoPouch equippedAmmoPouch = playerChar.GetEquippedAmmoPouch(); // if pouch found if (equippedAmmoPouch != null) { // turn ON the ammo bar SetBarActivation(true); // refresh ammo bar based on ammo pouch RefreshBarDimensions(equippedAmmoPouch.currentAmmo, equippedAmmoPouch.maxAmmo); // setup the ammo type image based on ammo being used RefreshAmmoTypeImage(); // DONT continue code return; } } } } } // getting here means that ammo bar should NOT be used, so turn OFF the ammo bar SetBarActivation(false); // turn OFF ammo type icon image imageAmmoType.gameObject.SetActive(false); }
/// <summary> /// Reduces amount of ammo currently held based on equipped weapon. /// Reutrns bool that denotes if action successful. /// </summary> /// <returns></returns> public bool ReduceEquippedAmmoByEquippedWeapon() { // get currently equipped ammo pouch AmmoPouch ammoPouch = GetEquippedAmmoPouch(); // if no ammo pouch found if (ammoPouch == null) { // print warning to console Debug.LogWarning("No ammo pouch found to reduce ammo from!"); // return that action failed return(false); } // reduce ammo based on equipped weapon ammoPouch.ReduceCurrentAmmo(GetEquippedWeapon().weaponStats.ammoPerUse); // return that action succeeded return(true); }
public AmmoPouch(AmmoPouch templateArg) { Setup(templateArg); }