working on fixing clarinet
it's all about the parameters now!
This commit is contained in:
		@@ -21,10 +21,11 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    bool unlockedClarinet;
 | 
			
		||||
    // things for dash
 | 
			
		||||
    private bool isDash = false;
 | 
			
		||||
    public float dashForce = 1.3f;
 | 
			
		||||
    private float dashTime = 1.0f;
 | 
			
		||||
    public float dashForce = 1f;
 | 
			
		||||
    public float dashTime = 1.0f;
 | 
			
		||||
    private float dashInc = 0.1f;
 | 
			
		||||
    private float currentDash = 0.0f;
 | 
			
		||||
    private bool forceAdded = false;
 | 
			
		||||
    Vector2 dashVec;
 | 
			
		||||
    // things for bounce
 | 
			
		||||
    public float reflectForce = 1.1f;
 | 
			
		||||
@@ -32,6 +33,7 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    private bool isInWater = false;
 | 
			
		||||
    private bool hasBounced = false;
 | 
			
		||||
    public float waterGravity = 0.5f;
 | 
			
		||||
    public float velocityCut = 1f;
 | 
			
		||||
 | 
			
		||||
    [Header("Cymbals:")]
 | 
			
		||||
    private float cymbalActiveTime = 0f;
 | 
			
		||||
@@ -78,16 +80,16 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
    void Update()
 | 
			
		||||
    {
 | 
			
		||||
        if (this.cymbalActiveTime < 0)
 | 
			
		||||
        {
 | 
			
		||||
            this.gameUI.ToggleCymbal(true);
 | 
			
		||||
        }
 | 
			
		||||
        this.cymbalActiveTime -= Time.deltaTime;
 | 
			
		||||
 | 
			
		||||
        unlockedTambourine = StateController.Instance.HasTambourine();
 | 
			
		||||
        if (playerIsAlive)
 | 
			
		||||
        {
 | 
			
		||||
            if (this.cymbalActiveTime < 0)
 | 
			
		||||
            {
 | 
			
		||||
                this.gameUI.ToggleCymbal(true);
 | 
			
		||||
            }
 | 
			
		||||
            this.cymbalActiveTime -= Time.deltaTime;
 | 
			
		||||
 | 
			
		||||
            // throw tambourine
 | 
			
		||||
            unlockedTambourine = StateController.Instance.HasTambourine();
 | 
			
		||||
            if (playerInput.actions["ThrowTambourine"].WasPressedThisFrame())
 | 
			
		||||
            {
 | 
			
		||||
                ThrowTambourine();
 | 
			
		||||
@@ -104,62 +106,65 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
                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();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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()
 | 
			
		||||
@@ -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()
 | 
			
		||||
    {
 | 
			
		||||
        GetComponent<SpriteRenderer>().flipX = !GetComponent<SpriteRenderer>().flipX;
 | 
			
		||||
@@ -285,7 +283,11 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
        print("water dash " + 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
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user