public bool TryWithdrawItem(IDepositable depositableToWithdraw, Vector3?withdrawPosition) { depositableToWithdraw.Withdraw(); DepositedItems.Remove(depositableToWithdraw); var grabbable = depositableToWithdraw as BaseGrabbable; grabbable.Rigidbody.isKinematic = false; RemoveFoodItem(depositableToWithdraw); return(true); }
public virtual bool TryDepositItem(IDepositable itemToDeposite) { var itemIndex = DepositedItems.Count; var grabbable = itemToDeposite as IGrabbable; var slot = _storageSlots[itemIndex]; grabbable.Collider.enabled = false; grabbable.Transform.position = slot.position; grabbable.Rigidbody.velocity = Vector3.zero; grabbable.Rigidbody.isKinematic = true; grabbable.Transform.SetParent(slot); DepositedItems.Add(itemToDeposite); return(true); }
public bool TryWithdrawFirstItem(out IDepositable withdrawnItem, Vector3?withdrawPosition = null) { if (DepositedItems.Count <= 0) { withdrawnItem = null; return(false); } withdrawnItem = DepositedItems[0]; if (TryWithdrawItem(withdrawnItem, withdrawPosition)) { return(true); } withdrawnItem = null; return(false); }
public virtual bool TryWithdrawItem(IDepositable depositableToWithdraw, Vector3?withdrawPosition = null) { if (!DepositedItems.Contains(depositableToWithdraw)) { return(false); } var grabbable = depositableToWithdraw as IGrabbable; grabbable.Collider.enabled = true; grabbable.Rigidbody.isKinematic = false; grabbable.Transform.SetParent(null); if (withdrawPosition.HasValue) { grabbable.Transform.position = withdrawPosition.Value; } return(DepositedItems.Remove(depositableToWithdraw)); }
public bool TryDepositItem(IDepositable itemToDeposite) { var foodItem = itemToDeposite as FoodItem; if (foodItem == null) { return(false); } foodItem.Deposit(this); DepositedItems.Add(foodItem); var containerSlot = GetEmptySlot(); foodItem.Rigidbody.isKinematic = true; foodItem.Transform.position = containerSlot.Transform.position; foodItem.Transform.SetParent(containerSlot.Transform); containerSlot.IsEmpty = false; return(true); }
private void RemoveFoodItem(IDepositable depositable) { var foodItem = depositable as FoodItem; if (foodItem == null) { Debug.LogErrorFormat("Couldn't find the requested depositable in this plant's food items"); return; } for (var branchIndex = 0; branchIndex < _branches.Length; branchIndex++) { if (foodItem == _foodItems[branchIndex]) { DepositedItems.Remove(depositable); _foodItems[branchIndex] = null; } } }
public bool TryWithdrawItem(IDepositable depositableToWithdraw, Vector3?withdrawPosition) { if (depositableToWithdraw == null) { return(false); } var grabbable = depositableToWithdraw as IGrabbable; var containerSlot = GetGrabbableSlot(grabbable); depositableToWithdraw.Withdraw(); DepositedItems.Remove(depositableToWithdraw); grabbable.Rigidbody.isKinematic = true; grabbable.Transform.position = containerSlot.Transform.position; grabbable.Transform.SetParent(containerSlot.Transform); containerSlot.IsEmpty = true; return(true); }
public bool TryDepositItem(IDepositable itemToDeposite) { return(false); }
public override bool TryWithdrawItem(IDepositable depositableToWithdraw, Vector3?withdrawPosition = null) { return(false); }
public override bool TryDepositItem(IDepositable itemToDeposit) { return(Price.ContainsKey(itemToDeposit.Type) && base.TryDepositItem(itemToDeposit)); }