示例#1
0
 public void SetNonNullWeaponsFromInventory()
 {
     if (isLocalPlayer)
     {
         weaponsEquipped.Clear();
         weapons.Clear();
         foreach (string slotName in inventorySlotStrings)
         {
             if (inventory.GetWeapon(slotName) != null)
             {
                 weaponsEquipped.Add(slotName);
                 weapons.Add(inventory.GetWeapon(slotName));
             }
         }
         currentWeaponIndex = 0;
         SetupWeapons();
         amidstInventoryStuff = false;
     }
 }
示例#2
0
 /// <summary>
 /// Sets state of the sell buttons to be interactable or not
 /// depending on if the player has an item equipped in that slot.
 /// </summary>
 private void SetInteractableStateOfSellButtons()
 {
     for (int i = 0; i < personalSellObj.transform.childCount; i++)
     {
         GameObject sellSlotMenuObj = personalSellObj.transform.GetChild(i).gameObject;
         Button     sellButton      = sellSlotMenuObj.GetComponent <Button>();
         //this will be the grenade object
         if (sellSlotMenuObj.transform.childCount > 1)
         {
             sellButton.interactable = false; // TODO: change this once grenades are ready and this menu obj functions as expected
         }
         else
         {
             if (playerInventory.GetWeapon(sellSlotMenuObj.GetComponent <SellWeaponButtonScript>().sellSlotName) == null)
             {
                 sellButton.interactable = false;
             }
             else
             {
                 sellButton.interactable = true;
             }
         }
     }
 }
示例#3
0
 /// <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();
 }