/// <summary> /// Function called anytime the full inventory and money UI need to be displayed for the player. /// </summary> public void InventoryActionPerformed() { inventoryAndMoneyPanel.SetActive(true); overallInventoryUI.SetActive(true); disappearTimer = inventoryDisappearTime; startDisappearingTimer = timeBeforeStartDisappearing; uiOpacity = 1.0f; playerMoneyText.text = "$" + playerManager.GetCurrentPlayerMoney(); foreach (string slot in inventorySlotNames) { if (slot == InventoryScript.GRENADES) { GameObject[] grenades = playerInventory.GetGrenades(); for (int i = 0; i < InventoryScript.GRENADE_COUNT; i++) { if (grenades[i] == null) { grenadePanelObj.transform.GetChild(i).gameObject.SetActive(false); } else { Grenades grenade = grenades[i].GetComponent <Grenades>(); grenadePanelObj.transform.GetChild(i).gameObject.SetActive(true); grenadePanelObj.transform.GetChild(i).gameObject.GetComponent <Image>().sprite = grenade.uiIcon; grenadePanelObj.transform.GetChild(i).gameObject.GetComponentInChildren <Text>().text = grenade.weaponName; } } } else { GameObject wepToGrabObj = playerInventory.GetWeapon(slot); if (slot == InventoryScript.PRIMARY) { //there is no weapon in that slot so turn it off if (wepToGrabObj == null) { primaryWepImageObj.SetActive(false); } else { Weapon wepToGrab = wepToGrabObj.GetComponent <Weapon>(); primaryWepImageObj.SetActive(true); primaryWepImageObj.GetComponent <Image>().sprite = wepToGrab.uiIcon; primaryWepImageObj.GetComponentInChildren <Text>().text = wepToGrab.weaponName; } } else if (slot == InventoryScript.SECONDARY) { //there is no weapon in that slot so turn it off if (wepToGrabObj == null) { secondaryWepImageObj.SetActive(false); } else { Weapon wepToGrab = wepToGrabObj.GetComponent <Weapon>(); secondaryWepImageObj.SetActive(true); secondaryWepImageObj.GetComponent <Image>().sprite = wepToGrab.uiIcon; secondaryWepImageObj.GetComponentInChildren <Text>().text = wepToGrab.weaponName; } } else if (slot == InventoryScript.KNIFE) { //there is no weapon in that slot so turn it off if (wepToGrabObj == null) { knifeImageObj.SetActive(false); } else { Weapon wepToGrab = wepToGrabObj.GetComponent <Weapon>(); knifeImageObj.SetActive(true); knifeImageObj.GetComponent <Image>().sprite = wepToGrab.uiIcon; knifeImageObj.GetComponentInChildren <Text>().text = wepToGrab.weaponName; } } else if (slot == InventoryScript.BOMB) { //there is no weapon in that slot so turn it off if (wepToGrabObj == null) { objectiveBombImageObj.SetActive(false); } else { Weapon wepToGrab = wepToGrabObj.GetComponent <Weapon>(); objectiveBombImageObj.SetActive(true); objectiveBombImageObj.GetComponent <Image>().sprite = wepToGrab.uiIcon; objectiveBombImageObj.GetComponentInChildren <Text>().text = wepToGrab.weaponName; } } } } SetUIOpacity(); }