added pickup animation

remotes/checkIfPRContentChanged-1749884192368007736/inventory
kziolkowski 8 months ago
parent 7276bdda38
commit 80c48ea3df

@ -3524,7 +3524,7 @@ position = Vector2(0, -374)
position = Vector2(0, 450) position = Vector2(0, 450)
sprite_frames = SubResource("SpriteFrames_4yiyq") sprite_frames = SubResource("SpriteFrames_4yiyq")
animation = &"diagonal wateringcan" animation = &"diagonal wateringcan"
frame_progress = 0.0934381 frame_progress = 0.234463
offset = Vector2(0, -450) offset = Vector2(0, -450)
[node name="Hoe" type="Sprite2D" parent="CharacterBody2D/visuals"] [node name="Hoe" type="Sprite2D" parent="CharacterBody2D/visuals"]

@ -51,6 +51,7 @@ grow_horizontal = 2
grow_vertical = 0 grow_vertical = 0
[node name="Selector" type="TextureRect" parent="SlotsContainer/SlotSelectContainer"] [node name="Selector" type="TextureRect" parent="SlotsContainer/SlotSelectContainer"]
visible = false
custom_minimum_size = Vector2(100, 100) custom_minimum_size = Vector2(100, 100)
layout_mode = 0 layout_mode = 0
offset_left = 1.0 offset_left = 1.0
@ -64,5 +65,6 @@ script = ExtResource("3_exrk4")
_testItemToCreate = ExtResource("4_5fdxq") _testItemToCreate = ExtResource("4_5fdxq")
[node name="BabushkaUiTmpInventorySelect" type="Sprite2D" parent="."] [node name="BabushkaUiTmpInventorySelect" type="Sprite2D" parent="."]
visible = false
position = Vector2(-648, 1020) position = Vector2(-648, 1020)
texture = ExtResource("4_tiss4") texture = ExtResource("4_tiss4")

@ -14,12 +14,16 @@ public partial class Player2D : CharacterBody2D
private string _toolString; private string _toolString;
private bool anyActionPressed; private bool anyActionPressed;
private bool _wateringInProgress; private bool _wateringInProgress;
private bool _pickupAnimationInProgress;
private Vector2 _lastDirection = Vector2.Zero; private Vector2 _lastDirection = Vector2.Zero;
public override void _Process(double delta) public override void _Process(double delta)
{ {
anyActionPressed = false; anyActionPressed = false;
if (_pickupAnimationInProgress || _wateringInProgress)
return;
if (Input.IsActionPressed("move_right")) if (Input.IsActionPressed("move_right"))
{ {
Velocity = new Vector2(_speed, 0); Velocity = new Vector2(_speed, 0);
@ -64,8 +68,6 @@ public partial class Player2D : CharacterBody2D
} }
else else
{ {
if (_wateringInProgress)
return;
//idle //idle
if(_lastDirection == Vector2.Zero || _lastDirection == Vector2.Down) if(_lastDirection == Vector2.Zero || _lastDirection == Vector2.Down)
_sprite.Animation = "front idle" + _toolString; _sprite.Animation = "front idle" + _toolString;
@ -79,7 +81,10 @@ public partial class Player2D : CharacterBody2D
public void ActivateTool(bool success, int id) public void ActivateTool(bool success, int id)
{ {
if (success) if (success)
{
_toolID = id; _toolID = id;
PlayPickUpAnimation();
}
else _toolID = -1; else _toolID = -1;
switch (_toolID) switch (_toolID)
@ -113,5 +118,18 @@ public partial class Player2D : CharacterBody2D
_wateringInProgress = false; _wateringInProgress = false;
} }
public void PlayPickUpAnimation()
{
_sprite.Animation = "side pickup";
_sprite.Play();
_pickupAnimationInProgress = true;
Task.Run(DelayedPickUpReset);
}
private async Task DelayedPickUpReset()
{
await Task.Delay(1000);
_pickupAnimationInProgress = false;
}
} }

Loading…
Cancel
Save