public void ClickUseButton(PointerEventData evt) { Debug.Log(evt); if (m_Item == null) { return; } m_Item.Use(); Managers.UI.GetSceneUI <UI_Inventory>().DestroyItem(); }
// The void that lowers the stats and change the need of the ai based on that. private void Live() { StatDecrease(); Needs _need = FindLowestNeed(); // Checks if the need is different, if so then change the desired item/location. if (need != _need) { need = _need; item = null; switch (need) { case Needs.Energy: item = Manager.GetItem(transform, Manager.energyItems); break; case Needs.Fullness: item = Manager.GetItem(transform, Manager.fullnessItems); break; case Needs.Hygiene: item = Manager.GetItem(transform, Manager.hygieneItems); break; case Needs.EmptyBladder: item = Manager.GetItem(transform, Manager.emptyBladderItems); break; case Needs.Fun: item = Manager.GetItem(transform, Manager.funItems); break; } // Tell the NavMeshAgent to move to it's desired location. agent.SetDestination(item.gameObject.transform.position); } // Check if the NavMeshAgent reached it's destination, and if so use the item. if (!agent.pathPending) { if (agent.remainingDistance <= agent.stoppingDistance) { if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f) { // Check if the item isn't already being used, to prevent using the item multiple times. if (!item.inUse) { item.Use(this); } } } } }