Merge remote-tracking branch 'origin/Over' into Syntriax

This commit is contained in:
2022-02-22 21:00:55 +03:00
36 changed files with 6971 additions and 674 deletions

View File

@@ -16,7 +16,7 @@ namespace Player
private const float GravityScale = 5.0f;
private const float FallMultiplier = 4.0f;
private const float LowJumpMultiplier = 10.0f;
private const float LowJumpMultiplier = 4.0f;
private PlayerInput _controls;
private Rigidbody2D _playerRigidbody2D;
@@ -25,6 +25,8 @@ namespace Player
private CollisionChecker _playerGroundTrigger;
private CollisionChecker _playerInteractableTrigger;
private Orientation _orientation;
private bool _moveKeyPressed;
private bool _jumpKeyPressed;
@@ -33,6 +35,7 @@ namespace Player
private bool _isOnAir;
private bool _canJump;
private bool _afterMoving;
private void Awake()
{
@@ -46,6 +49,13 @@ namespace Player
{
_playerRigidbody2D.mass = DefaultMass;
_playerRigidbody2D.gravityScale = GravityScale;
_orientation = gameObject.GetComponent<SpriteRenderer>().flipX switch
{
true => Orientation.Left,
false => Orientation.Right
};
_canJump = true;
BaseSpeed = 0.0f;
}
@@ -68,21 +78,17 @@ namespace Player
private void FixedUpdate()
{
/*switch (_playerRigidbody2D.velocity.y)
switch (_playerRigidbody2D.velocity.y)
{
case < 0:
_playerRigidbody2D.velocity +=
Vector2.up * (Physics2D.gravity.y * (FallMultiplier - 1) * Time.fixedDeltaTime);
break;
/*case > 0 and < 3:
print("We will go down" + i);
++i;
break;
case > 0 when !_jumpKeyPressed:
_playerRigidbody2D.velocity +=
Vector2.up * (Physics2D.gravity.y * (LowJumpMultiplier - 1) * Time.fixedDeltaTime);
break;
}*/
}
if (_moveKeyPressed)
Move(_xAxisValue);
@@ -91,6 +97,9 @@ namespace Player
if (_jumpKeyPressed && _canJump && _playerGroundTrigger.IsCollided)
Jump();
if (_afterMoving)
DecelerationAfterMoving();
}
private void Update()
@@ -140,9 +149,11 @@ namespace Player
{
case < 0:
_playerSpriteRenderer.flipX = true;
_orientation = Orientation.Left;
break;
case > 0:
_playerSpriteRenderer.flipX = false;
_orientation = Orientation.Right;
break;
default:
_playerSpriteRenderer.flipX = _playerSpriteRenderer.flipX;
@@ -157,7 +168,11 @@ namespace Player
private void DecelerationAfterMoving()
{
throw new NotImplementedException();
BaseSpeed -= 80;
_playerRigidbody2D.velocity = new Vector2(BaseSpeed * (int)_orientation * Time.fixedDeltaTime,
_playerRigidbody2D.velocity.y);
if (BaseSpeed == 0)
_afterMoving = false;
}
private void Jump()
@@ -180,9 +195,10 @@ namespace Player
{
case true:
_moveKeyPressed = false;
BaseSpeed = 0;
_afterMoving = true;
break;
case false:
_afterMoving = false;
_moveKeyPressed = true;
_xAxisValue = context.ReadValue<float>();
break;
@@ -208,5 +224,16 @@ namespace Player
if (_playerInteractableTrigger.IsCollided)
throw new NotImplementedException();
}
public void OnClimb(InputAction.CallbackContext context)
{
Climb();
}
private enum Orientation
{
Left = -1,
Right = 1
}
}
}