This commit is contained in:
allylikesfrogs 2023-05-03 00:35:59 -07:00
parent ed72a093fb
commit 3aa0823bbe
2 changed files with 25 additions and 11 deletions

View File

@ -21,9 +21,10 @@ public class PlayerBehavior : MonoBehaviour
[Header("Clarinet:")] [Header("Clarinet:")]
bool unlockedClarinet; bool unlockedClarinet;
[SerializeField] private float dashMult = 2; [SerializeField] private float dashMult = 2;
[SerializeField] private float maxDashTime = 1.0f; [SerializeField] private float maxDashTime = 10.0f;
[SerializeField] private float dashStopSpeed = 0.1f; [SerializeField] private float dashStopSpeed = 0.1f;
private float currentDashTime; private float currentDashTime;
public bool isDash = false;
[Header("Grappling:")] [Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun; [SerializeField] public Tutorial_GrapplingGun grapplingGun;
@ -98,19 +99,24 @@ public class PlayerBehavior : MonoBehaviour
{ {
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame()) if (playerInput.actions["ClarinetDive"].WasPressedThisFrame())
{ {
isDash = true;
currentDashTime = 0.0f; currentDashTime = 0.0f;
} }
if (!playerController.IsGrounded()) if (!playerController.IsGrounded())
{
Vector3 dashSpeed = new Vector3(1f,1f,1f) * dashMult;
if (currentDashTime < maxDashTime)
{ {
Vector2 dashSpeed = new Vector2(1f,1f) * dashMult; _rb.AddForce(dashSpeed, ForceMode2D.Force);
if (currentDashTime < maxDashTime) currentDashTime += dashStopSpeed;
{ print("cdt " + currentDashTime);
_rb.AddForce(dashSpeed, ForceMode2D.Force);
currentDashTime += dashStopSpeed;
print("cdt " + currentDashTime);
}
// print("Clarinet pressed!");
} }
else
{
isDash = false;
}
}
else{isDash = false;}
} }
} }

View File

@ -50,6 +50,9 @@ public class PlayerMovement : MonoBehaviour
bool wasGrappling = false; bool wasGrappling = false;
bool unlockedTrumpet; bool unlockedTrumpet;
//clarinet
public bool isDashing = false;
//Set all of these up in the inspector //Set all of these up in the inspector
[Header("Checks")] [Header("Checks")]
//Size of groundCheck depends on the size of your character generally you want them slightly small than width (for ground) and height (for the wall check) //Size of groundCheck depends on the size of your character generally you want them slightly small than width (for ground) and height (for the wall check)
@ -88,7 +91,7 @@ public class PlayerMovement : MonoBehaviour
void OnMove(InputValue value) void OnMove(InputValue value)
{ {
if (playerBehavior.playerIsAlive) { if (playerBehavior.playerIsAlive && !isDashing) {
this._moveInput = value.Get<Vector2>(); this._moveInput = value.Get<Vector2>();
} else { } else {
this._moveInput = Vector2.zero; this._moveInput = Vector2.zero;
@ -97,13 +100,15 @@ public class PlayerMovement : MonoBehaviour
void OnJump() void OnJump()
{ {
if (playerBehavior.playerIsAlive) { if (playerBehavior.playerIsAlive && !isDashing) {
OnJumpInput(); OnJumpInput();
} }
} }
private void Update() private void Update()
{ {
isDashing = playerBehavior.isDash;
if(!isDashing){
unlockedTrumpet = stateController.unlockedTrumpet; unlockedTrumpet = stateController.unlockedTrumpet;
#region TIMERS #region TIMERS
LastOnGroundTime -= Time.deltaTime; LastOnGroundTime -= Time.deltaTime;
@ -313,10 +318,12 @@ public class PlayerMovement : MonoBehaviour
gameUI.ToggleTrumpet(false); gameUI.ToggleTrumpet(false);
} }
#endregion #endregion
}
} }
private void FixedUpdate() private void FixedUpdate()
{ {
if(!isDashing){
//Handle Run //Handle Run
if (IsWallJumping) if (IsWallJumping)
Run(Data.wallJumpRunLerp); Run(Data.wallJumpRunLerp);
@ -326,6 +333,7 @@ public class PlayerMovement : MonoBehaviour
//Handle Slide //Handle Slide
if (IsSliding) if (IsSliding)
Slide(); Slide();
}
} }
#region INPUT CALLBACKS #region INPUT CALLBACKS