water
This commit is contained in:
		@@ -5,6 +5,8 @@ using UnityEngine.InputSystem;
 | 
			
		||||
 | 
			
		||||
public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
{
 | 
			
		||||
    public PlayerData Data;
 | 
			
		||||
 | 
			
		||||
    [Header("Physics:")]
 | 
			
		||||
    private float _hInput;
 | 
			
		||||
    private Rigidbody2D _rb;
 | 
			
		||||
@@ -20,7 +22,7 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    [Header("Clarinet:")]
 | 
			
		||||
    bool unlockedClarinet;
 | 
			
		||||
    // things for dash
 | 
			
		||||
    public bool isDash = false;
 | 
			
		||||
    private bool isDash = false;
 | 
			
		||||
    public float dashForce = 1.2f;
 | 
			
		||||
    private float dashTime = 1.0f;
 | 
			
		||||
    private float dashInc = 0.1f;
 | 
			
		||||
@@ -29,8 +31,8 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    // things for bounce
 | 
			
		||||
    public float reflectForce = 2f;
 | 
			
		||||
    private Vector2 saveVelocity;
 | 
			
		||||
    public bool isInWater = false;
 | 
			
		||||
    private bool lowSpeed = false;
 | 
			
		||||
    private bool isInWater = false;
 | 
			
		||||
    private bool hasBounced = false;
 | 
			
		||||
 | 
			
		||||
    [Header("Cymbals:")]
 | 
			
		||||
    private float cymbalActiveTime = 0f;
 | 
			
		||||
@@ -109,7 +111,7 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
        unlockedClarinet = StateController.Instance.HasClarinet();
 | 
			
		||||
        if (playerIsAlive && unlockedClarinet)
 | 
			
		||||
        {
 | 
			
		||||
            if (playerInput.actions["ClarinetDive"].WasPressedThisFrame())
 | 
			
		||||
            if (playerInput.actions["ClarinetDive"].WasPressedThisFrame() && !isInWater)
 | 
			
		||||
            {
 | 
			
		||||
                isDash = true;
 | 
			
		||||
                playerInput.DeactivateInput();
 | 
			
		||||
@@ -262,30 +264,31 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void Bounce()
 | 
			
		||||
    {/*
 | 
			
		||||
    {
 | 
			
		||||
        Vector2 reflect;
 | 
			
		||||
        if (Mathf.Abs(saveVelocity.y) < 1f)
 | 
			
		||||
        if (Mathf.Abs(saveVelocity.y) < 1f && hasBounced)
 | 
			
		||||
        {
 | 
			
		||||
            reflect = Vector2.zero;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            reflect = new Vector2(saveVelocity.x, -(saveVelocity.y) * reflectForce);
 | 
			
		||||
            hasBounced = true;
 | 
			
		||||
        }
 | 
			
		||||
        _rb.AddForce(reflect, ForceMode2D.Impulse);
 | 
			
		||||
        reflect = Vector2.zero;
 | 
			
		||||
        isDash = false;*/
 | 
			
		||||
        isDash = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void Water()
 | 
			
		||||
    {
 | 
			
		||||
        /*if(isDash)
 | 
			
		||||
        if(isDash)
 | 
			
		||||
        {
 | 
			
		||||
            saveVelocity = _rb.velocity;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            playerController.FloatGravity();
 | 
			
		||||
        }
 | 
			
		||||
        /*
 | 
			
		||||
        if (Mathf.Abs(_rb.velocity.y) < 2f)
 | 
			
		||||
@@ -363,7 +366,9 @@ public class PlayerBehavior : MonoBehaviour
 | 
			
		||||
        {
 | 
			
		||||
            isInWater = false;
 | 
			
		||||
            isDash = false;
 | 
			
		||||
            hasBounced = false;
 | 
			
		||||
            playerInput.ActivateInput();
 | 
			
		||||
            playerController.EndFloatGravity();
 | 
			
		||||
            saveVelocity = Vector2.zero;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,8 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    GameObject trumpetAnimationObject;
 | 
			
		||||
    bool trumpetActive = false;
 | 
			
		||||
 | 
			
		||||
    //clarinet
 | 
			
		||||
    private float tempFallSpeed;
 | 
			
		||||
 | 
			
		||||
    //Jump
 | 
			
		||||
    private bool _isJumpCut;
 | 
			
		||||
@@ -91,6 +93,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    {
 | 
			
		||||
        SetGravityScale(Data.gravityScale);
 | 
			
		||||
        IsFacingRight = true;
 | 
			
		||||
        tempFallSpeed = Data.maxFallSpeed;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void OnMove(InputValue value)
 | 
			
		||||
@@ -313,10 +316,6 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
            //Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
 | 
			
		||||
            RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
 | 
			
		||||
        }
 | 
			
		||||
        /*else if (playerBehavior.isInWater)
 | 
			
		||||
        {
 | 
			
		||||
            SetGravityScale(0);
 | 
			
		||||
        }*/
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            //Default gravity if standing on a platform or moving upwards
 | 
			
		||||
@@ -563,6 +562,16 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
        // print(Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping);
 | 
			
		||||
        return (Physics2D.OverlapBox(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize, 0, _groundLayer) && !IsJumping);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void FloatGravity()
 | 
			
		||||
    {
 | 
			
		||||
        Data.maxFallSpeed = 0.1f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void EndFloatGravity()
 | 
			
		||||
    {
 | 
			
		||||
        Data.maxFallSpeed = tempFallSpeed;
 | 
			
		||||
    }
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user