parent
ff85b67087
commit
4afb02440c
@ -1,46 +0,0 @@
|
|||||||
using Babushka.scripts.CSharp.Common.Farming;
|
|
||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
|
||||||
|
|
||||||
public partial class VesnaBehaviour : Node
|
|
||||||
{
|
|
||||||
[ExportGroup("Farming")]
|
|
||||||
[Export] private FieldService2D _fieldParent;
|
|
||||||
[Export] private FarmingControls2D _farmingControls;
|
|
||||||
|
|
||||||
[Signal] public delegate void ToolPickupEventHandler(bool success);
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
_farmingControls.FieldParent = _fieldParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Farming
|
|
||||||
|
|
||||||
public void ActivateHoe(bool activate)
|
|
||||||
{
|
|
||||||
ActivateTool(activate, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ActivateWateringCan(bool activate)
|
|
||||||
{
|
|
||||||
ActivateTool(activate, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ActivateTool(bool activate , int toolId)
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
if (toolId == 0)
|
|
||||||
{
|
|
||||||
success = _farmingControls.ActivateHoe(activate);
|
|
||||||
}
|
|
||||||
else if (toolId == 1)
|
|
||||||
{
|
|
||||||
success = _farmingControls.ActivateWateringCan(activate);
|
|
||||||
}
|
|
||||||
EmitSignal(SignalName.ToolPickup, success);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
uid://bblprbhnbyv77
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Babushka.scripts.CSharp.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Switches between two available Sprite Options.
|
||||||
|
/// </summary>
|
||||||
|
public partial class SpriteSwitcher2D : Node2D
|
||||||
|
{
|
||||||
|
[Export] private Sprite2D _firstSprite;
|
||||||
|
[Export] private Sprite2D _secondSprite;
|
||||||
|
[Export] private bool _state = true;
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void SwitchEventHandler(bool state);
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
SetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SwitchState()
|
||||||
|
{
|
||||||
|
_state = !_state;
|
||||||
|
EmitSignal(SignalName.Switch, _state);
|
||||||
|
SetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetState()
|
||||||
|
{
|
||||||
|
if(_firstSprite != null)
|
||||||
|
_firstSprite.Visible = _state;
|
||||||
|
if(_secondSprite != null)
|
||||||
|
_secondSprite.Visible = !_state;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue