IEnumerator GoToBag() { // Queries currently held gameobject and its location Vector3 location = _ObjectManager.WhatsOffShelf().Value; heldObject = _ObjectManager.WhatsOffShelf().Key; // Creates at copy of held gameobject at the same location GameObject purchased = Instantiate(heldObject, heldObject.transform.position, Quaternion.Euler(new Vector3(0, 0, 0))); heldObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); heldObject.GetComponent <IFruit>().AddToCart(); // Calls the AddToCart() function from IFRUIT, which increase the amount purchased of the held object by one (+1) _ShoppingBag.FlashGreen(); // Moves duplicated gameobject over the bag LeanTween.move(purchased, shoppingBag.transform.position + new Vector3(0, 0.6f, 0), 1.5f).setEase(LeanTweenType.easeOutQuad); LeanTween.rotate(heldObject, new Vector3(90, 0, 0), 1.5f).setEase(LeanTweenType.easeOutQuad); yield return(new WaitForSeconds(1.5f)); // Wait for object to reach desired location purchased.GetComponent <Collider>().enabled = true; // Turn on the duplicated gameobjects collider. // This allows its to collide with the Shopping bag, which destroys it. Look at ShoppingBag class for more Details _ObjectState.Free(purchased); // Drops gameobject into bag by enabling gravity, look at class ObjectState for more details }
IEnumerator PutBack() { busy = true; Vector3 location = _ObjectManager.WhatsOffShelf().Value; heldObject = _ObjectManager.WhatsOffShelf().Key; _ObjectManager.AddToShelf(heldObject); _StateManager.ChangeUserState(StateManager.UserState.busy); _PileGrab.NotHolding(); DestroyGUI(); _UIController.Clear(); //heldObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); LeanTween.move(heldObject, location + new Vector3(0, 1.0f, 0), 1.5f).setEase(LeanTweenType.easeOutQuad);//.setEase(LeanTweenType.easeOutBack); LeanTween.rotate(heldObject, new Vector3(-90, 0, 0), 1.5f).setEase(LeanTweenType.easeOutQuad); yield return(new WaitForSeconds(1.5f)); _StateManager.ChangeUserState(StateManager.UserState.browesing); _ObjectState.Free(heldObject); yield return(new WaitForSeconds(0.5f)); Destroy(heldObject); //heldObject.GetComponent<Collider>().enabled = true; busy = false; }
IEnumerator FlyBehind() { //busy = true; Vector3 location = _ObjectManager.WhatsOffShelf().Value; heldObject = _ObjectManager.WhatsOffShelf().Key; GameObject purchased = Instantiate(heldObject, heldObject.transform.position, Quaternion.Euler(new Vector3(0, 0, 0))); heldObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); //heldObject.transform.rotation = Quaternion.Euler(new Vector3(0, -90, 0)); //LeanTween.move(purchased, controller.transform.position + controller.transform.forward, 1.5f).setEase(LeanTweenType.easeOutQuad);//.setEase(LeanTweenType.easeOutBack); LeanTween.move(purchased, new Vector3(-0.713f, 1.5f, 0.441f), 1.5f).setEase(LeanTweenType.easeOutQuad);//.setEase(LeanTweenType.easeOutBack); LeanTween.rotate(heldObject, new Vector3(90, 0, 0), 1.5f).setEase(LeanTweenType.easeOutQuad); heldObject.GetComponent <Collider>().enabled = true; yield return(new WaitForSeconds(1.5f)); _ObjectState.Free(purchased); //busy = false; }