IEnumerator DunkWait_C() { dunkFreezeDurationBonus = 0; passController.EnableBallReception(); ChangeState(DunkState.Waiting); SnapController.SetSnappable(SnapType.Pass, this.gameObject, dunkSnapTreshold, dunkJumpFreezeDuration); float forwardDistanceTravelled = 0; for (float i = 0; i < dunkJumpFreezeDuration + dunkFreezeDurationBonus; i += Time.deltaTime) { if (playerController) { //Check if ball is coming if (BallBehaviour.instance.GetState() == BallState.Flying && BallBehaviour.instance.HasTarget()) { dunkFreezeDurationBonus += Time.deltaTime; } Vector3 camForwardNormalized = GameManager.mainCamera.transform.forward; camForwardNormalized.y = 0; camForwardNormalized = camForwardNormalized.normalized; Vector3 camRightNormalized = GameManager.mainCamera.transform.right; camRightNormalized.y = 0; camRightNormalized = camRightNormalized.normalized; GamePadState state = GamePad.GetState(playerController.playerIndex); Vector3 moveInput = (state.ThumbSticks.Left.X * camRightNormalized) + (state.ThumbSticks.Left.Y * camForwardNormalized); if (moveInput.magnitude > 0.5f && forwardDistanceTravelled < dunkMaxForwardDistance && Vector3.SignedAngle(pawnController.transform.forward, moveInput, Vector3.up) < dunkForwardAngleTreshold) { pawnController.transform.position += pawnController.transform.forward * Time.deltaTime * dunkForwardSpeed * moveInput.magnitude; forwardDistanceTravelled += Time.deltaTime * dunkForwardSpeed * moveInput.magnitude; } } yield return(new WaitForEndOfFrame()); } }
public override void OnLevelUnloading() { try { Debug.Log("OnLevelUnloading"); FakeRoadAI.Revert(); SnapController.Revert(); AltKeyFix.Revert(); Manager.OnLevelUnloaded(); } catch (Exception e) { Debug.LogError("Error during OnLevelUnloading callback"); Debug.LogError(e.ToString()); } base.OnLevelUnloading(); }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); try { Debug.Log("OnLevelLoaded"); Manager.OnLevelLoaded(); FakeRoadAI.Deploy(); SnapController.Deploy(); AltKeyFix.Deploy(); } catch (Exception e) { Debug.LogError("Error during OnLevelLoaded callback"); Debug.LogError(e.ToString()); } }