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

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

        _grabHandle.connectedBody = null;
    }
コード例 #2
0
    private void Drop()
    {
        if (_grabbedObject == null)
        {
            return;
        }

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

        _target.enabled = true;
        _grabbedObject  = null;
    }
コード例 #3
0
    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;
    }
コード例 #4
0
ファイル: Player.cs プロジェクト: kaikue/MagicOfTheStars
    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;
        }
    }
コード例 #5
0
ファイル: PlayerControler.cs プロジェクト: LudovicAL/Pompiers
 public void DropGrabbedObject(bool intentional)
 {
     grabbedObject.Drop(intentional);
     grabbedObject = null;
 }
コード例 #6
0
ファイル: HandBehavior.cs プロジェクト: hwaet/LD48
    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;
                }
            }
        }
    }
コード例 #7
0
 public void Drop()
 {
     heldObject.Drop();
     heldObject = null;
 }