public PickupItemAction(AIAgent agent, PickableItem item) : base(agent) { Name = "PickupItem"; BaseUtility = 9; _item = item; }
//TODO - сделать интерфейс для контейнеров(игровых) public bool AddItem(PickableItem newItem) { if (_items.Count >= MaxItemsCount) return false; var previousItem = _items.LastOrDefault(); _items.Add(newItem); newItem.transform.SetParent(transform); Vector3 previousSize = Vector3.zero; if(previousItem != null) previousSize = previousItem.GetComponentInChildren<BoxCollider>().size; newItem.transform.position = transform.position + (Vector3.up * (previousSize.y * 0.5f + 0.15f)) *(_items.Count-1); return true; }
public virtual void Eat(PickableItem food, Action callback) { StartCoroutine(EatProcess(food, callback)); }
protected virtual IEnumerator EatProcess(PickableItem food, Action callback) { Debug.Log("Eating the" + food.Name); yield return new WaitForSeconds(3); if(BackPack.IsEmpty) Debug.LogError("Can't eat. Backpack is empty!"); Stats.Hunger = 0; Destroy(food.gameObject); callback(); }