|
|
|
|
@ -43,45 +43,55 @@ public partial class Player2D : CharacterBody2D
|
|
|
|
|
|
|
|
|
|
if (!_canHandleInput)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionPressed("move_right"))
|
|
|
|
|
|
|
|
|
|
bool right = Input.IsActionPressed("move_right");
|
|
|
|
|
bool left = Input.IsActionPressed("move_left");
|
|
|
|
|
bool up = Input.IsActionPressed("move_up");
|
|
|
|
|
bool down = Input.IsActionPressed("move_down");
|
|
|
|
|
bool walkingAnimationPicked = false;
|
|
|
|
|
|
|
|
|
|
if (up)
|
|
|
|
|
{
|
|
|
|
|
Velocity = new Vector2(_speed, 0);
|
|
|
|
|
Velocity = new Vector2(0, -_speed);
|
|
|
|
|
MoveAndSlide();
|
|
|
|
|
_sprite.FlipH = false;
|
|
|
|
|
_sprite.Animation = "side walking" + _toolString;
|
|
|
|
|
_sprite.Animation = "back walking" + _toolString;
|
|
|
|
|
anyActionPressed = true;
|
|
|
|
|
_lastDirection = Vector2.Right;
|
|
|
|
|
_lastDirection = Vector2.Up;
|
|
|
|
|
walkingAnimationPicked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionPressed("move_left"))
|
|
|
|
|
if (down && !walkingAnimationPicked)
|
|
|
|
|
{
|
|
|
|
|
Velocity = new Vector2(-_speed, 0);
|
|
|
|
|
Velocity = new Vector2(0, _speed);
|
|
|
|
|
MoveAndSlide();
|
|
|
|
|
_sprite.FlipH = true;
|
|
|
|
|
_sprite.Animation = "side walking" + _toolString;
|
|
|
|
|
_sprite.Animation = "front walking" + _toolString;
|
|
|
|
|
anyActionPressed = true;
|
|
|
|
|
_lastDirection = Vector2.Left;
|
|
|
|
|
_lastDirection = Vector2.Down;
|
|
|
|
|
walkingAnimationPicked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionPressed("move_up"))
|
|
|
|
|
if (right && !walkingAnimationPicked)
|
|
|
|
|
{
|
|
|
|
|
Velocity = new Vector2(0, -_speed);
|
|
|
|
|
Velocity = new Vector2(_speed, 0);
|
|
|
|
|
MoveAndSlide();
|
|
|
|
|
_sprite.Animation = "back walking" + _toolString;
|
|
|
|
|
_sprite.FlipH = false;
|
|
|
|
|
_sprite.Animation = "side walking" + _toolString;
|
|
|
|
|
anyActionPressed = true;
|
|
|
|
|
_lastDirection = Vector2.Up;
|
|
|
|
|
_lastDirection = Vector2.Right;
|
|
|
|
|
walkingAnimationPicked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionPressed("move_down"))
|
|
|
|
|
if (left && !walkingAnimationPicked)
|
|
|
|
|
{
|
|
|
|
|
Velocity = new Vector2(0, _speed);
|
|
|
|
|
Velocity = new Vector2(-_speed, 0);
|
|
|
|
|
MoveAndSlide();
|
|
|
|
|
_sprite.Animation = "front walking" + _toolString;
|
|
|
|
|
_sprite.FlipH = true;
|
|
|
|
|
_sprite.Animation = "side walking" + _toolString;
|
|
|
|
|
anyActionPressed = true;
|
|
|
|
|
_lastDirection = Vector2.Down;
|
|
|
|
|
_lastDirection = Vector2.Left;
|
|
|
|
|
walkingAnimationPicked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Input.IsActionPressed("interact2"))
|
|
|
|
|
{
|
|
|
|
|
_sprite.Animation = "back interact";
|
|
|
|
|
|