This commit is contained in:
allylikesfrogs
2023-05-05 16:19:35 -07:00
32 changed files with 24814 additions and 2405 deletions

View File

@@ -31,6 +31,10 @@ public class PlayerBehavior : MonoBehaviour
Vector2 dashVec;
private bool lowSpeed = false;
[Header("Cymbals:")]
private float cymbalActiveTime = 0f;
[SerializeField] AudioSource cymbalAudio;
[Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun;
[SerializeField] public Tutorial_GrapplingRope grapplingRope;
@@ -72,6 +76,12 @@ public class PlayerBehavior : MonoBehaviour
void Update()
{
if (this.cymbalActiveTime < 0)
{
this.gameUI.ToggleCymbal(true);
}
this.cymbalActiveTime -= Time.deltaTime;
unlockedTambourine = StateController.Instance.HasTambourine();
if (playerIsAlive)
{
@@ -123,6 +133,7 @@ public class PlayerBehavior : MonoBehaviour
else if (!isInWater)
{
isDash = false;
currentDash = 0.0f;
_rb.AddForce(-(dashVec), ForceMode2D.Impulse);
dashVec = Vector2.zero;
@@ -134,6 +145,22 @@ public class PlayerBehavior : MonoBehaviour
dashVec = Vector2.zero;
}
}
if (StateController.Instance.HasCymbal())
{
if (this.playerInput.actions["CymbalCrash"].WasPressedThisFrame())
{
// Play the sound
this.gameUI.ToggleCymbal(false);
// this.audioSource.clip = cymbalSound;
// this.audioSource.loop = false;
// this.audioSource.Play();
cymbalAudio.Play();
// Set the cymbal active for the equivalent of one second
this.cymbalActiveTime = 1;
}
}
}
void Animate()
@@ -239,13 +266,13 @@ public class PlayerBehavior : MonoBehaviour
void Bounce()
{
Vector2 reflect;
if(lowSpeed)
if (lowSpeed)
{
reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * 0.75f);
reflect = new Vector2(saveVelocity.x, -(saveVelocity.y) * 0.75f);
}
else
{
reflect = new Vector2(saveVelocity.x,-(saveVelocity.y) * bonk);
reflect = new Vector2(saveVelocity.x, -(saveVelocity.y) * bonk);
}
_rb.AddForce(reflect, ForceMode2D.Impulse);
reflect = Vector2.zero;
@@ -291,6 +318,28 @@ public class PlayerBehavior : MonoBehaviour
isInWater = true;
Water();
}
else if (col.tag == "bouncePad")
{
// Assign the player's velocity to zero so that the player can
// bounce on the same jump pad
this.playerController.RB.velocity = Vector2.zero;
Bouncepad pad = col.GetComponent<Bouncepad>();
switch (pad.Direction())
{
case Bouncepad.Facing.Left:
this.playerController.RB.AddForce(
new Vector2(-pad.bounceForce, pad.verticalModifier * pad.bounceForce),
ForceMode2D.Impulse
);
break;
case Bouncepad.Facing.Right:
this.playerController.RB.AddForce(
new Vector2(pad.bounceForce, pad.verticalModifier * pad.bounceForce),
ForceMode2D.Impulse
);
break;
}
}
}
void OnTriggerExit2D(Collider2D col)
@@ -331,7 +380,19 @@ public class PlayerBehavior : MonoBehaviour
else if (collision.gameObject.tag == "Projectile")
{
Destroy(collision.gameObject);
StartCoroutine(DestroyPlayer());
if (this.cymbalActiveTime > 0)
{
Vector2 projVel = collision.gameObject.GetComponent<Rigidbody2D>().velocity;
collision.gameObject.GetComponent<Rigidbody2D>().velocity =
new Vector2(
-projVel.x,
-projVel.y
);
}
else
{
StartCoroutine(DestroyPlayer());
}
}
//stupid stuff for claude's house
else if (collision.gameObject.tag == "SirJacques")
@@ -366,7 +427,8 @@ public class PlayerBehavior : MonoBehaviour
// this.stateController.SetDeathCanvasActive(true);
if (grapplingRope.isGrappling) {
if (grapplingRope.isGrappling)
{
LetGoOfGrapple();
}