/// <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); }
/// <summary> /// Sets up weapon model animator based on the equipped weapon. /// </summary> private void RefreshWeaponModel() { // get player char the UI is associated with PlayerCharacterMasterController playerChar = _uiManager.UiPlayerCharacter; // if player char found if (playerChar != null) { // get currently equipped weapon WeaponData equippedWep = playerChar.GetEquippedWeapon(); // if a weapon is equipped if (equippedWep != null) { // get equipped weapon's ID string wepId = equippedWep.itemInfo.itemId; // get equipped weapon's associated 1st person model animator AnimatorOverrideController newWepAnim = AssetRefMethods. LoadBundleAssetFirstPersonWeaponModelAnimator(equippedWep.weaponType, wepId); // if animator found if (newWepAnim != null) { // turn ON 1st person weapon object wepHeadAnim.gameObject.SetActive(true); // set weapon model animator to retreived weapon animator wepModelAnim.runtimeAnimatorController = newWepAnim; // DONT continue code return; } } } // if got here then, turn OFF 1st person weapon object wepHeadAnim.gameObject.SetActive(false); }