private bool HandlePlayerKeyboardInput() { // About APM calc keyboardInputLength += Time.deltaTime; if (isNoInput) { keyboardNoInputLength += Time.deltaTime; } keyboardInputPerSec = (float)keyboardInputCount / keyboardInputLength; if (keyboardNoInputLength > keyboardRestInputSpeedInterval) { keyboardNoInputLength = 0.0f; keyboardInputCount = 0; keyboardInputLength = 0.0f; } isNoInput = true; playerKeyboardInputSpeed = keyboardInputPerSec * keyboardInflateAniSpeedMultiplier; player.SetInflateAnimationSpeed(playerKeyboardInputSpeed); if (!PlayerBalloon) { return(false); } // When inflating balloon if (Input.GetButtonDown(inflateButton)) { keyboardNoInputLength = 0.0f; // Calc ani speed and set it isNoInput = false; keyboardInputCount++; if (PlayerBalloon.Inflate(keyboardInflateSpeed, keyboardInputPerSec * keyboardInputPitchMultiplier)) { PlayerBalloon = null; player.StartDizzy(); player.ResetInflateAnimationSpeed(); Invoke("SpawnPlayerBalloon", failFreezeTime); IsPlayerFreezing = true; } } if (Input.GetButtonDown(releaseButton)) { ReleaseBalloon(true); } return(true); }
/// <summary> /// /// </summary> /// <returns>Is used joyCon for input?</returns> private bool HandlePlayerJoyConInput() { if (!PlayerBalloon) { return(false); } if (!isUseLeftJoycon && !JoyConInputManager.IsUsingRightJoyCon()) { return(false); } else if (isUseLeftJoycon && !JoyConInputManager.IsUsingLeftJoyCon()) { return(false); } /// Handle release balloon var gyroInfo = JoyConInputManager.GetJoyConGyro(isUseLeftJoycon); if (gyroInfo.y < joyConReleaseSensitivity || JoyConInputManager.GetJoyConButtonDown(Joycon.Button.SHOULDER_2)) { if (PlayerBalloon.State != Balloon.BalloonStatus.Normal) { JoyConInputManager.TriggerRumble(false, 180.0f, 360.0f, 0.3f, 200); ReleaseBalloon(true); } return(true); } /// Handle inflate balloon and animation if (Mathf.Abs(gyroInfo.y) > Mathf.Abs(joyConReleaseSensitivity)) { return(false); } Vector3 joyAccel = JoyConInputManager.GetJoyConAccel(isUseLeftJoycon); float accelDelta = joyAccel.sqrMagnitude - joyConInputSensitivity; if (accelDelta < 0.0f) { player.ResetInflateAnimationSpeed(); return(false); } float newAir = accelDelta * joyConInflateSpeed * Time.deltaTime; if (newAir == 0.0f) { return(false); } playerJoyConInputSpeed = newAir * joyConInflateAniSpeedMultiplier; player.SetInflateAnimationSpeed(playerJoyConInputSpeed); inflatedAirVolume += newAir; if (PlayerBalloon.Inflate(newAir, newAir * joyConInputPitchMultiplier)) { // Process after balloon boomed JoyConInputManager.TriggerRumble(false, 360.0f, 180.0f, 0.7f, 400); PlayerBalloon = null; Invoke("SpawnPlayerBalloon", failFreezeTime); IsPlayerFreezing = true; player.StartDizzy(); player.ResetInflateAnimationSpeed(); } return(true); }