Пример #1
0
    /// <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>
    /// Sets up the aiming reticle image.
    /// </summary>
    private void RefreshAimReticle()
    {
        // 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)
                {
                    // load the aiming reticle associated with equipped weapon
                    Sprite loadedAimReticle = AssetRefMethods.
                                              LoadBundleAssetWeaponTypeReticle(equippedWep.weaponType);

                    // if a reticle was found
                    if (loadedAimReticle != null)
                    {
                        // set reticle image to loaded sprite
                        reticle.sprite = loadedAimReticle;

                        // activate aim reticle
                        reticle.gameObject.SetActive(true);

                        // DONT continue code
                        return;
                    }
                    // else NO reticle was loaded
                    else
                    {
                        // print warning to console
                        Debug.LogWarning("No aiming reticle assoicated with weapon " +
                                         $"type: {equippedWep.weaponType.ToString()}");
                    }
                }
            }
        }

        // deactivate aim reticle
        reticle.gameObject.SetActive(false);
    }
Пример #3
0
    /// <summary>
    /// Returns the currently equipped weapon.
    /// </summary>
    /// <returns></returns>
    public WeaponData GetEquippedWeapon()
    {
        // get currently equipped weapon slot
        WeaponSlotData equippedWepSlot = GetEquippedWeaponSlot();

        // if no weapon slot found
        if (equippedWepSlot == null)
        {
            // return a null weapon
            return(null);
        }

        // return found weapon slot's weapon
        return(equippedWepSlot.slotWeapon);
    }
Пример #4
0
    public AmmoPouch GetEquippedAmmoPouch()
    {
        // get currently equipped weapon slot
        WeaponSlotData equippedWepSlot = GetEquippedWeaponSlot();

        // if no weapon slot found
        if (equippedWepSlot == null)
        {
            // return a null weapon pouch
            return(null);
        }

        InventoryAmmo invAmmo = charData.characterInventory.inventoryAmmo;

        return(invAmmo.GetAmmoPouchFromAmmoType(equippedWepSlot.requiredWeaponTypeSet));
    }
Пример #5
0
 private void Setup(WeaponSlotData templateArg)
 {
     slotWeapon            = new WeaponData(templateArg.slotWeapon);
     requiredWeaponTypeSet = new WeaponTypeSet(templateArg.requiredWeaponTypeSet);
 }
Пример #6
0
 public WeaponSlotData(WeaponSlotData templateArg)
 {
     Setup(templateArg);
 }