change: Added cymbal functionality to player behavior and added some adjustment to jump pads

This commit is contained in:
Nicholas Novak 2023-05-05 02:51:53 -07:00
parent 8b773f0119
commit 00e9682040
2 changed files with 30 additions and 6 deletions

View File

@ -15,6 +15,8 @@ public class Bouncepad : MonoBehaviour
[SerializeField] [SerializeField]
public float bounceForce = 20f; public float bounceForce = 20f;
[SerializeField]
public float verticalModifier = 1.0f;
public Facing Direction() public Facing Direction()
{ {

View File

@ -31,6 +31,9 @@ public class PlayerBehavior : MonoBehaviour
Vector2 dashVec; Vector2 dashVec;
private bool lowSpeed = false; private bool lowSpeed = false;
[Header("Cymbals:")]
private float cymbalActiveTime = 0f;
[Header("Grappling:")] [Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun; [SerializeField] public Tutorial_GrapplingGun grapplingGun;
[SerializeField] public Tutorial_GrapplingRope grapplingRope; [SerializeField] public Tutorial_GrapplingRope grapplingRope;
@ -72,6 +75,8 @@ public class PlayerBehavior : MonoBehaviour
void Update() void Update()
{ {
this.cymbalActiveTime -= Time.deltaTime;
unlockedTambourine = StateController.Instance.HasTambourine(); unlockedTambourine = StateController.Instance.HasTambourine();
if (playerIsAlive) if (playerIsAlive)
{ {
@ -123,6 +128,7 @@ public class PlayerBehavior : MonoBehaviour
else if (!isInWater) else if (!isInWater)
{ {
isDash = false; isDash = false;
currentDash = 0.0f; currentDash = 0.0f;
_rb.AddForce(-(dashVec), ForceMode2D.Impulse); _rb.AddForce(-(dashVec), ForceMode2D.Impulse);
dashVec = Vector2.zero; dashVec = Vector2.zero;
@ -134,6 +140,14 @@ public class PlayerBehavior : MonoBehaviour
dashVec = Vector2.zero; dashVec = Vector2.zero;
} }
} }
if (StateController.Instance.HasCymbal())
{
if (this.playerInput.actions["CymbalCrash"].WasPressedThisFrame())
{
this.cymbalActiveTime = 1;
}
}
} }
void Animate() void Animate()
@ -296,20 +310,21 @@ public class PlayerBehavior : MonoBehaviour
{ {
// Assign the player's velocity to zero so that the player can // Assign the player's velocity to zero so that the player can
// bounce on the same jump pad // bounce on the same jump pad
this.playerController.RB.velocity = new Vector2( this.playerController.RB.velocity = Vector2.zero;
this.playerController.RB.velocity.x,
0
);
Bouncepad pad = col.GetComponent<Bouncepad>(); Bouncepad pad = col.GetComponent<Bouncepad>();
switch (pad.Direction()) switch (pad.Direction())
{ {
case Bouncepad.Facing.Left: case Bouncepad.Facing.Left:
this.playerController.RB.AddForce( this.playerController.RB.AddForce(
new Vector2(-pad.bounceForce, pad.bounceForce), new Vector2(-pad.bounceForce, pad.verticalModifier * pad.bounceForce),
ForceMode2D.Impulse ForceMode2D.Impulse
); );
break; break;
case Bouncepad.Facing.Right: case Bouncepad.Facing.Right:
this.playerController.RB.AddForce(
new Vector2(pad.bounceForce, pad.verticalModifier * pad.bounceForce),
ForceMode2D.Impulse
);
break; break;
} }
} }
@ -353,8 +368,15 @@ public class PlayerBehavior : MonoBehaviour
else if (collision.gameObject.tag == "Projectile") else if (collision.gameObject.tag == "Projectile")
{ {
Destroy(collision.gameObject); Destroy(collision.gameObject);
if (this.cymbalActiveTime > 0)
{
Debug.Log("Reflected!");
}
else
{
StartCoroutine(DestroyPlayer()); StartCoroutine(DestroyPlayer());
} }
}
//stupid stuff for claude's house //stupid stuff for claude's house
else if (collision.gameObject.tag == "SirJacques") else if (collision.gameObject.tag == "SirJacques")
{ {