Exemplo n.º 1
0
 private void OnDrop(HandBehavior hand)
 {
     if (inDelivery)
     {
         DeliverMe();
     }
 }
Exemplo n.º 2
0
    IEnumerator DropCoroutine(HandBehavior hand)
    {
        OnDrop?.Invoke(hand);
        this.held                  = false;
        this.transform.parent      = null;
        this.holder                = null;
        this.gameObject.layer      = layerBak;
        this.rigidbody.isKinematic = false;
        this.rigidbody.useGravity  = true;
        yield return(new WaitForSeconds(.3f));

        foreach (Collider collider in colliders)
        {
            Physics.IgnoreCollision(collider, hand.collider, false);
        }
        Physics.IgnoreCollision(this.collider, hand.collider, false);
    }
Exemplo n.º 3
0
 IEnumerator PickupCoroutine(HandBehavior hand)
 {
     while (this.collider == null)
     {
         yield return(new WaitForEndOfFrame());
     }
     gameObject.layer = hand.gameObject.layer;
     foreach (Collider collider in colliders)
     {
         Physics.IgnoreCollision(collider, hand.collider, true);
         collider.enabled = true;
     }
     Physics.IgnoreCollision(this.collider, hand.collider, true);
     this.collider.enabled = true;
     rigidbody.isKinematic = true;
     rigidbody.useGravity  = false;
     transform.parent      = hand.transform;
     held = true;
     OnPickup?.Invoke(hand);
 }
Exemplo n.º 4
0
 public void Drop(HandBehavior hand)
 {
     StartCoroutine(DropCoroutine(hand));
 }
Exemplo n.º 5
0
 public void Pickup(HandBehavior hand)
 {
     this.holder = hand;
     StartCoroutine(PickupCoroutine(hand));
 }
Exemplo n.º 6
0
    private void OnCollisionEnter(Collision collision)
    {
        //Debug.LogFormat("{0} Hand Hit: {1}", hand, collision.gameObject.name);
        switch (pickupState)
        {
        case PickupState.Seeking:
            if (collision.gameObject == pickupTarget)
            {
                //if the target is food, basket, or plate
                switch (pickupTarget.tag)
                {
                case "food":
                case "fryBasket":
                case "plate":
                    Grabbable grab = pickupTarget.GetComponent <Grabbable>();
                    if (grab.Held)
                    {
                        break;
                    }
                    grab.Pickup(this);
                    holding      = grab;
                    pickupTarget = null;
                    //Debug.LogFormat("Hand {0} Grabbed the {1}", hand, holding.name);
                    break;
                }
            }
            break;

        case PickupState.Idle:
            if (collision.gameObject.tag == "hand" && this.HoldingSomething && this.holding.tag == "food")
            {
                //Debug.LogFormat("Hand {0} hit the other hand", hand);
                HandBehavior otherHand = collision.gameObject.GetComponent <HandBehavior>();

                if (otherHand.HoldingSomething && otherHand.holding.tag == "food")
                {
                    FoodBehavior thisFood  = holding.GetComponent <FoodBehavior>();
                    FoodBehavior otherFood = otherHand.holding.GetComponent <FoodBehavior>();
                    Debug.LogFormat("We both have food! I Have {0} They have {1}", thisFood.foodType, otherFood.foodType);
                    StageSettings_ld48 settings = (StageSettings_ld48)sceneWrangler.currentSceneContainer.stageSettings;
                    switch (thisFood.foodType, otherFood.foodType)
                    {
                    case (FoodBehavior.FoodType.Duck, FoodBehavior.FoodType.Chicken):
                        if (otherFood.doneness != FoodBehavior.Doneness.Raw)
                        {
                            //form a ducken
                            Debug.Log("Form the Ducken!");
                            GameObject ducken          = Instantiate(settings.DuckenPrefab, thisFood.transform.position, thisFood.transform.rotation) as GameObject;
                            Grabbable  duckenGrabbable = ducken.GetComponent <Grabbable>();
                            particleSystem.Play();
                            this.holding = duckenGrabbable;
                            duckenGrabbable.Pickup(this);
                            otherHand.holding = null;
                            Destroy(thisFood.gameObject);
                            Destroy(otherFood.gameObject);
                        }
                        break;

                    case (FoodBehavior.FoodType.Turkey, FoodBehavior.FoodType.Ducken):
                        if (otherFood.doneness != FoodBehavior.Doneness.Raw)
                        {
                            //form the turducken
                            Debug.Log("Form the Turducken!");
                            GameObject turducken          = Instantiate(settings.TurduckenPrefab, thisFood.transform.position, thisFood.transform.rotation) as GameObject;
                            Grabbable  turduckenGrabbable = turducken.GetComponent <Grabbable>();
                            particleSystem.Play();
                            this.holding = turduckenGrabbable;
                            turduckenGrabbable.Pickup(this);
                            otherHand.holding = null;
                            Destroy(thisFood.gameObject);
                            Destroy(otherFood.gameObject);
                        }
                        break;
                    }
                }
Exemplo n.º 7
0
    private void OnPickup(HandBehavior hand)
    {
        StageSettings_ld48 settings = (StageSettings_ld48)sceneWrangler.currentSceneContainer.stageSettings;

        Instantiate(settings.PlatePrefab, this.transform.position, this.transform.rotation);
    }