private Vector3 GetThrowForce(ViolaController.ThrowType throwType, GameObject juggledItem) { switch (throwType) { case ViolaController.ThrowType.HighThrow: return(HighThrowForce.localPosition * throwForceMultiplier); case ViolaController.ThrowType.FloorBounce: if (juggledItem.tag == "Balloon") { return(new Vector3(0, balloonThrowDown.y * throwForceMultiplier, 0) * BalloonFloatStrength); // No X-value } else { return(FloorBounceForce.localPosition * throwForceMultiplier); } case ViolaController.ThrowType.MidThrow: if (juggledItem.tag == "Balloon") { return(ballonThrowMid * throwForceMultiplier * BalloonFloatStrength); } else { return(MidThrowForce.localPosition * throwForceMultiplier); } case ViolaController.ThrowType.None: default: return(Vector3.zero); } }
/// <summary> /// Update function. /// </summary> public void Update() { throwType = ViolaController.ThrowType.None; HandleInput(); if (throwType != ViolaController.ThrowType.None) { if (!_tutorialLevel) { ViolaController.Throw(throwType, screenSide); return; } if (_tutorialLevel && throwType == ViolaController.ThrowType.HighThrow) { if (TutorialManager._previousTutorialStage == 0) { TutorialManager.RemoveTutorialUI(0); ViolaController.Throw(throwType, screenSide); } if (TutorialManager._previousTutorialStage == 5) { TutorialManager.RemoveTutorialUI(5); ViolaController.Throw(throwType, screenSide); } } if (_tutorialLevel && throwType == ViolaController.ThrowType.FloorBounce && TutorialManager._previousTutorialStage == 1) { ViolaController.Throw(throwType, screenSide); TutorialManager.RemoveTutorialUI(1); } if (_tutorialLevel && throwType == ViolaController.ThrowType.MidThrow && TutorialManager._previousTutorialStage == 2) { ViolaController.Throw(throwType, screenSide); TutorialManager.RemoveTutorialUI(2); } if (_tutorialLevel && TutorialManager._previousTutorialStage > 3 && TutorialManager._previousTutorialStage != 5) { Debug.Log("Throw funcking ball"); ViolaController.Throw(throwType, screenSide); } } if (Input.GetKeyDown(KeyCode.Space)) { SceneController.ResetScene(); } }
// This is the consequence of derping with lerping. private void FullSpagetti(ViolaController.ThrowType throwType, ViolaController.HandType hand, GameObject ball) { Animator ballAnimator = ball.GetComponent <Animator>(); ballAnimator.enabled = true; if (hand == ViolaController.HandType.Left) { if (throwType == ViolaController.ThrowType.HighThrow) { ballAnimator.Play("rightToLeftUP", 0, 0f); } else if (throwType == ViolaController.ThrowType.MidThrow) { ballAnimator.Play("rightToLeftMIDDLE", 0, 0f); } else if (throwType == ViolaController.ThrowType.FloorBounce) { ballAnimator.Play("rightToLeftDOWN", 0, 0f); } } if (hand == ViolaController.HandType.Right) { if (throwType == ViolaController.ThrowType.HighThrow) { ballAnimator.Play("leftToRightUP", 0, 0f); } else if (throwType == ViolaController.ThrowType.MidThrow) { ballAnimator.Play("LeftToRightMiddle", 0, 0f); } else if (throwType == ViolaController.ThrowType.FloorBounce) { ballAnimator.Play("LeftToRightDown", 0, 0f); } } }
/// <summary> /// Checks how to player has swiped. /// </summary> private void CheckSwipe(int i) { Vector3 directionVector = lastPosition[i] - firstPosition[i]; if (!SwipedLongEnough(directionVector)) { return; } SwipeDirection direction; if (Mathf.Abs(directionVector.x) > Mathf.Abs(directionVector.y)) { direction = HorizontalSwipe(i); } else { direction = VerticalSwipe(i); } screenSide = SwipeLocation(i); throwType = ComputeThrowType(direction); }
IEnumerator LerpToHandAndPlayAnim(ViolaController.ThrowType throwType, ViolaController.HandType hand, GameObject ball) { Animator ballAnimator = ball.GetComponent <Animator>(); Debug.Log("Lerping"); float duration = 0.02f; if (hand == ViolaController.HandType.Left) { float journey = 0f; Vector3 currentpos = ball.transform.position; ballAnimator.enabled = false; while (journey <= duration) { journey = journey + Time.deltaTime; float percent = Mathf.Clamp01(journey / duration); ball.transform.position = Vector3.Lerp(currentpos, lerpLeftHandTarget, percent); yield return(null); } yield return(new WaitForSeconds(duration)); ballAnimator.enabled = true; if (throwType == ViolaController.ThrowType.HighThrow) { ballAnimator.Play("rightToLeftUP", 0, 0f); } else if (throwType == ViolaController.ThrowType.MidThrow) { ballAnimator.Play("rightToLeftMIDDLE", 0, 0f); } else if (throwType == ViolaController.ThrowType.FloorBounce) { ballAnimator.Play("rightToLeftDOWN", 0, 0f); } Debug.Log("gottem"); } else if (hand == ViolaController.HandType.Right) { float journey = 0f; Vector3 currentpos = ball.transform.position; ballAnimator.enabled = false; while (journey <= duration) { journey = journey + Time.deltaTime; float percent = Mathf.Clamp01(journey / duration); ball.transform.position = Vector3.Lerp(currentpos, lerpRightHandTarget, percent); yield return(null); } yield return(new WaitForSeconds(duration)); ballAnimator.enabled = true; if (throwType == ViolaController.ThrowType.HighThrow) { ballAnimator.Play("leftToRightUP", 0, 0f); } else if (throwType == ViolaController.ThrowType.MidThrow) { ballAnimator.Play("LeftToRightMiddle", 0, 0f); Debug.Log("gottem for real"); } else if (throwType == ViolaController.ThrowType.FloorBounce) { ballAnimator.Play("LeftToRightDown", 0, 0f); } Debug.Log("gottem for real"); } yield return(null); }
// These functions rely on that the two hands are at positive/negative X positions! public void Throw(ViolaController.ThrowType throwType, ViolaController.HandType hand) { var ball = GetBallToThrow(hand); if (ball == null) { return; } var anim = ball.GetComponent <Animator>(); if (anim.isActiveAndEnabled && ball.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime < 0.5) { return; } //Rigidbody ballRigidBody = ball.GetComponent<Rigidbody>(); //ball.GetComponent<Animator>().enabled = true; AkSoundEngine.SetRTPCValue("rightCollider", 0.0f); FullSpagetti(throwType, hand, ball); //IEnumerator coroutine = LerpToHandAndPlayAnim(throwType, hand, ball); //StartCoroutine(coroutine); if (hand == ViolaController.HandType.Left) { AkSoundEngine.PostEvent("ColliderLeft_event", gameObject); } else if (hand == ViolaController.HandType.Right) { AkSoundEngine.PostEvent("ColliderRight_event", gameObject); } //ballRigidBody.useGravity = false; //ballRigidBody.velocity = Vector3.zero; //ballRigidBody.isKinematic = true; ball.GetComponent <Ball>().wasPerfectlyThrown = GotPerfectCatch(ball); //bool perfect = GotPerfectCatch(ball); //ball.GetComponent<Ball>().wasPerfectlyThrown = perfect; //if (perfect) //{ // //flameMeshShader.SetActive(true); // //displacementAmounts += new Vector4(0, 0, -2, 0); // //Debug.Log("happened"); //} //Vector3 throwVector = +(throwType, ball); //SetThrowDirection(hand, ref throwVector, ballRigidBody); //ballRigidBody.isKinematic = false; //if (ballRigidBody.drag > 0) // ballRigidBody.drag = 0; //ballRigidBody.AddForce(throwVector); //BallLeavesHand(ball.GetComponent<Collider>()); throwCount++; if (throwCount >= numberOfBalls) { SceneController.IsPlaying = true; } }