示例#1
0
    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);
    }
示例#2
0
    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);
    }
示例#3
0
 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);
 }
示例#4
0
    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));
    }
示例#5
0
    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);
    }
示例#6
0
    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;
            }
        }
    }
示例#7
0
    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);
    }
示例#8
0
 public bool TryDepositItem(IDepositable itemToDeposite)
 {
     return(false);
 }
示例#9
0
 public override bool TryWithdrawItem(IDepositable depositableToWithdraw, Vector3?withdrawPosition = null)
 {
     return(false);
 }
示例#10
0
 public override bool TryDepositItem(IDepositable itemToDeposit)
 {
     return(Price.ContainsKey(itemToDeposit.Type) &&
            base.TryDepositItem(itemToDeposit));
 }