Exemple #1
0
    public void Drop(object sender, HandController.GrabData data)
    {
        if (!_grabbed)
        {
            return;
        }

        _grabbed.Drop(data.Cell, data.Position);
        _grabbed = null;

        _grabHandle.connectedBody = null;
    }
Exemple #2
0
    private void Drop()
    {
        if (_grabbedObject == null)
        {
            return;
        }

        _grabbedObject.transform.parent = _grabbedObject.OriginalParent;
        _grabbedObject.Drop();

        _target.enabled = true;
        _grabbedObject  = null;
    }
    private void ThrowObject(float p_strength)
    {
        if (p_strength > 0)
        {
            ThrowEvent.Invoke();
        }
        else
        {
            DropEvent.Invoke();
        }

        m_grabbedObjectScript.Drop(gameObject);
        m_grabbedObjectScript.Throw(p_strength);

        m_grabbedObject       = null;
        m_grabbedObjectScript = null;
    }
Exemple #4
0
    public void ThrowHeldObject(Vector2 velocity)
    {
        float dropX = grabZone.transform.position.x;
        float side  = Mathf.Sign(grabZone.transform.localPosition.x);

        dropX += side * heldObject.GetSize().x / 2;
        Vector2 dropPos = new Vector2(dropX, holdSpot.transform.position.y);

        if (CanMoveGrabbable(heldObject, dropPos))
        {
            heldObject.transform.parent = null;
            heldObject.Drop(dropPos);
            if (velocity.x != 0)
            {
                Vector2 force = new Vector2(velocity.x * THROW_X_FACTOR, velocity.y + THROW_Y_SPEED);
                heldObject.AddForce(force);
            }
            heldObject = null;
        }
    }
 public void DropGrabbedObject(bool intentional)
 {
     grabbedObject.Drop(intentional);
     grabbedObject = null;
 }
Exemple #6
0
    void InteractPressed()
    {
        if (Animating)
        {
            return;
        }
        if (HoldingSomething)
        {
            switch (holding.tag)
            {
            case "food":
                holding.Drop(this);
                holding = null;
                break;

            case "plate":
                holding.Drop(this);
                holding.rigidbody.AddForce(rigidbody.velocity, ForceMode.Impulse);
                holding = null;
                break;

            case "fryBasket":
                if (zone == Zone.Frier)
                {
                    holding.Drop(this);
                    holding = null;
                    break;
                }
                else
                {
                    StartCoroutine(DumpBasket());
                }
                break;
            }
        }
        else
        {
            RaycastHit[] hits;
            int          layerMask = frierMask | trashMask;
            string[]     tagPriority;
            switch (zone)
            {
            case Zone.Cooler:
                layerMask  |= coolerMask;
                tagPriority = new string[] { "fryBasket", "cooler", "trash" };
                break;

            case Zone.Platting:
                layerMask  |= plateMask | foodMask;
                tagPriority = new string[] { "fryBasket", "food", "trash", "plate" };
                break;

            case Zone.Breading:
            case Zone.Prep:
                layerMask  |= foodMask;
                tagPriority = new string[] { "food", "fryBasket", "trash" };
                break;

            case Zone.Frier:
                tagPriority = new string[] { "fryBasket", "trash" };
                break;

            default:
                layerMask  |= foodMask;
                tagPriority = new string[] { "fryBasket", "trash", "food" };
                break;
            }
            Debug.Log("SphereCasting!");
            hits = Physics.SphereCastAll(this.transform.position, 1, -this.transform.up, 10, layerMask);
            Debug.LogFormat("We hit:{0}", string.Join(",", hits));
            foreach (string checkTag in tagPriority)
            {
                foreach (RaycastHit hit in hits)
                {
                    if (hit.transform.CompareTag(checkTag))
                    {
                        StartCoroutine(PickupAnimation(hit.transform.gameObject));
                        break;
                    }
                }
                if (pickupState == PickupState.Seeking)
                {
                    break;
                }
            }
        }
    }
Exemple #7
0
 public void Drop()
 {
     heldObject.Drop();
     heldObject = null;
 }