using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Localization; using UnityEngine.Localization.Settings; public class PlayerHealthManager : MonoBehaviour { public int pillsCollected; public bool CanCarryPills; [HideInInspector] public bool PillsCollected = false; [HideInInspector] public bool PillUsed = false; private static PlayerHealthManager _instance; public static PlayerHealthManager GetInstance() { return _instance; } public LocalizedString notHavingAnyPillsMessage; public LocalizedString pillUsedMessage; public LocalizedString pillMessage; void Awake() { if (!_instance) { _instance = this; } } void Update() { if (pillsCollected >= 3)//If the medicines that you have collected hit the maximum number you will not be able to carry any more. { CanCarryPills = false; } else { CanCarryPills = true; } if (UIManager.GetInstance().userInterfaceIsOnScreen == false) { if ((pillsCollected >= 1 && Input.GetKeyDown(KeyCode.V)) || (pillsCollected >= 1 && Input.GetKeyDown(KeyCode.JoystickButton3))) //Conntroller -> Y { UsePill(); } else { if ((pillsCollected <= 0 && Input.GetKeyDown(KeyCode.V)) || (pillsCollected <= 0 && Input.GetKeyDown(KeyCode.JoystickButton3))) //If you try to use a pill and you don't have any pills message will appear on screen. { string localizedText = LocalizationSettings.StringDatabase.GetLocalizedString("Messages", "notHavingAnyPillsMessage"); UIManager.GetInstance().StartCoroutine(UIManager.GetInstance().DisplayMessage(notHavingAnyPillsMessage)); print("You don't have any pills"); } } } } public void UsePill() { PillUsed = true; pillsCollected -= 1; // -1 pill because you used it. Sanity.GetInstance().UsePill(); string localizedText = LocalizationSettings.StringDatabase.GetLocalizedString("Messages", "pillUsed"); UIManager.GetInstance().StartCoroutine(UIManager.GetInstance().DisplayMessage(pillUsedMessage)); if (InventoryManager.GetInstance().pillsOnRingInventory.activeSelf == true && pillsCollected == 0) { RingInventory.GetInstance().RemoveItemByNameToKeysAndItemsInventory("Pills"); } } #region AXRHSTH FTWXIA METHODOS //public void collectMedicine() //{ // if (CanCarryPills)//If the inventory is not full yet: // { // if(Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton0)/*A button*/) // { // pillsCollected += 1; // PillsCollected = true; // } // } // else //If you can't carry any more medicines because your inventory is full: // { // if(Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton0)) // { // print("You can't carry any more medicines INVENTORY FULL!"); // } // } //} #endregion }