working on fixing clarinet
it's all about the parameters now!
This commit is contained in:
parent
257613a4e9
commit
d703883d94
@ -545,12 +545,14 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: b0115312556794123a3cafad4b83d0a7, type: 3}
|
m_Script: {fileID: 11500000, guid: b0115312556794123a3cafad4b83d0a7, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
Data: {fileID: 11400000, guid: fec218a9d55267dedac6ebe31eab6dcd, type: 2}
|
|
||||||
playerInput: {fileID: 1407172087}
|
playerInput: {fileID: 1407172087}
|
||||||
launcher: {fileID: 6559806128767475056}
|
launcher: {fileID: 6559806128767475056}
|
||||||
hasTambourine: 1
|
hasTambourine: 1
|
||||||
dashForce: 1.2
|
dashForce: 50
|
||||||
|
dashTime: 1
|
||||||
reflectForce: 2
|
reflectForce: 2
|
||||||
|
waterGravity: 0.5
|
||||||
|
velocityCut: 1.5
|
||||||
cymbalAudio: {fileID: 264629194984044240}
|
cymbalAudio: {fileID: 264629194984044240}
|
||||||
grapplingGun: {fileID: 3465910379319867675}
|
grapplingGun: {fileID: 3465910379319867675}
|
||||||
grapplingRope: {fileID: 7648135587659148198}
|
grapplingRope: {fileID: 7648135587659148198}
|
||||||
|
@ -21,10 +21,11 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
bool unlockedClarinet;
|
bool unlockedClarinet;
|
||||||
// things for dash
|
// things for dash
|
||||||
private bool isDash = false;
|
private bool isDash = false;
|
||||||
public float dashForce = 1.3f;
|
public float dashForce = 1f;
|
||||||
private float dashTime = 1.0f;
|
public float dashTime = 1.0f;
|
||||||
private float dashInc = 0.1f;
|
private float dashInc = 0.1f;
|
||||||
private float currentDash = 0.0f;
|
private float currentDash = 0.0f;
|
||||||
|
private bool forceAdded = false;
|
||||||
Vector2 dashVec;
|
Vector2 dashVec;
|
||||||
// things for bounce
|
// things for bounce
|
||||||
public float reflectForce = 1.1f;
|
public float reflectForce = 1.1f;
|
||||||
@ -32,6 +33,7 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
private bool isInWater = false;
|
private bool isInWater = false;
|
||||||
private bool hasBounced = false;
|
private bool hasBounced = false;
|
||||||
public float waterGravity = 0.5f;
|
public float waterGravity = 0.5f;
|
||||||
|
public float velocityCut = 1f;
|
||||||
|
|
||||||
[Header("Cymbals:")]
|
[Header("Cymbals:")]
|
||||||
private float cymbalActiveTime = 0f;
|
private float cymbalActiveTime = 0f;
|
||||||
@ -78,16 +80,16 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
if (this.cymbalActiveTime < 0)
|
|
||||||
{
|
|
||||||
this.gameUI.ToggleCymbal(true);
|
|
||||||
}
|
|
||||||
this.cymbalActiveTime -= Time.deltaTime;
|
|
||||||
|
|
||||||
unlockedTambourine = StateController.Instance.HasTambourine();
|
|
||||||
if (playerIsAlive)
|
if (playerIsAlive)
|
||||||
{
|
{
|
||||||
|
if (this.cymbalActiveTime < 0)
|
||||||
|
{
|
||||||
|
this.gameUI.ToggleCymbal(true);
|
||||||
|
}
|
||||||
|
this.cymbalActiveTime -= Time.deltaTime;
|
||||||
|
|
||||||
// throw tambourine
|
// throw tambourine
|
||||||
|
unlockedTambourine = StateController.Instance.HasTambourine();
|
||||||
if (playerInput.actions["ThrowTambourine"].WasPressedThisFrame())
|
if (playerInput.actions["ThrowTambourine"].WasPressedThisFrame())
|
||||||
{
|
{
|
||||||
ThrowTambourine();
|
ThrowTambourine();
|
||||||
@ -104,62 +106,65 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
LetGoOfGrapple();
|
LetGoOfGrapple();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clarinet
|
||||||
|
unlockedClarinet = StateController.Instance.HasClarinet();
|
||||||
|
if (unlockedClarinet)
|
||||||
|
{
|
||||||
|
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame() && !isInWater && !playerController.IsGrounded())
|
||||||
|
{
|
||||||
|
isDash = true;
|
||||||
|
playerInput.DeactivateInput();
|
||||||
|
currentDash = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!playerController.IsGrounded() && isDash && (currentDash < dashTime))
|
||||||
|
{
|
||||||
|
if (!forceAdded) {
|
||||||
|
dashVec = new Vector2(1f * forward, -1f) * dashForce;
|
||||||
|
_rb.AddForce(dashVec, ForceMode2D.Impulse);
|
||||||
|
forceAdded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDash += Time.deltaTime;
|
||||||
|
}
|
||||||
|
else if ((currentDash >= dashTime)) // dash ends
|
||||||
|
{
|
||||||
|
if (!isInWater) {
|
||||||
|
isDash = false;
|
||||||
|
forceAdded = false;
|
||||||
|
_rb.AddForce(-(dashVec), ForceMode2D.Impulse);
|
||||||
|
playerInput.ActivateInput();
|
||||||
|
}
|
||||||
|
currentDash = 0.0f;
|
||||||
|
dashVec = Vector2.zero;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isDash = false;
|
||||||
|
forceAdded = false;
|
||||||
|
playerInput.ActivateInput();
|
||||||
|
currentDash = 0.0f;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Animate();
|
Animate();
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockedClarinet = StateController.Instance.HasClarinet();
|
|
||||||
if (playerIsAlive && unlockedClarinet)
|
|
||||||
{
|
|
||||||
if (playerInput.actions["ClarinetDive"].WasPressedThisFrame() && !isInWater)
|
|
||||||
{
|
|
||||||
isDash = true;
|
|
||||||
playerInput.DeactivateInput();
|
|
||||||
currentDash = 0.0f;
|
|
||||||
}
|
|
||||||
if (!playerController.IsGrounded() && isDash && (currentDash < dashTime))
|
|
||||||
{
|
|
||||||
if (forward == 1)
|
|
||||||
{
|
|
||||||
dashVec = new Vector2(1f, -1f) * dashForce;
|
|
||||||
_rb.AddForce(dashVec, ForceMode2D.Impulse);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dashVec = new Vector2(-1f, -1f) * dashForce;
|
|
||||||
_rb.AddForce(dashVec, ForceMode2D.Impulse);
|
|
||||||
}
|
|
||||||
currentDash += dashInc;
|
|
||||||
}
|
|
||||||
else if ((currentDash == dashTime || currentDash > dashTime) && !isInWater)
|
|
||||||
{
|
|
||||||
isDash = false;
|
|
||||||
currentDash = 0.0f;
|
|
||||||
_rb.AddForce(-(dashVec), ForceMode2D.Impulse);
|
|
||||||
dashVec = Vector2.zero;
|
|
||||||
playerInput.ActivateInput();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentDash = 0.0f;
|
|
||||||
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()
|
void Animate()
|
||||||
@ -201,13 +206,6 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlipScale()
|
|
||||||
{ // DOENST WORK RIGHT (that's so sad for you)
|
|
||||||
Vector3 currentScale = this.gameObject.transform.localScale;
|
|
||||||
currentScale.x *= -1;
|
|
||||||
this.gameObject.transform.localScale = currentScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlipRenderer()
|
void FlipRenderer()
|
||||||
{
|
{
|
||||||
GetComponent<SpriteRenderer>().flipX = !GetComponent<SpriteRenderer>().flipX;
|
GetComponent<SpriteRenderer>().flipX = !GetComponent<SpriteRenderer>().flipX;
|
||||||
@ -285,7 +283,11 @@ public class PlayerBehavior : MonoBehaviour
|
|||||||
print("water dash " + isDash);
|
print("water dash " + isDash);
|
||||||
if(isDash)
|
if(isDash)
|
||||||
{
|
{
|
||||||
saveVelocity = _rb.velocity;
|
saveVelocity = _rb.velocity / velocityCut;
|
||||||
|
if (isDash) {
|
||||||
|
dashVec = new Vector2(1f * forward, -1f) * (dashForce / velocityCut);
|
||||||
|
_rb.AddForce(dashVec, ForceMode2D.Force);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user