mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 12:35:53 +00:00
Delay start for animation
This commit is contained in:
parent
1005796e13
commit
a9a7b234fb
9 changed files with 108 additions and 23 deletions
|
|
@ -15,6 +15,12 @@ public partial class ActorResourceProvider : Node2D
|
|||
[Signal]
|
||||
public delegate void ResourceChangedEventHandler(float newValue, float maxValue);
|
||||
|
||||
[Signal]
|
||||
public delegate void ResourceIncreasedEventHandler(float oldValue, float newValue, float maxValue);
|
||||
|
||||
[Signal]
|
||||
public delegate void ResourceDecreasedEventHandler(float oldValue, float newValue, float maxValue);
|
||||
|
||||
[Signal]
|
||||
public delegate void ResourceMaxedEventHandler(float maxValue);
|
||||
|
||||
|
|
@ -26,21 +32,29 @@ public partial class ActorResourceProvider : Node2D
|
|||
get => _currentResource;
|
||||
set
|
||||
{
|
||||
if (_currentResource != value)
|
||||
if (_currentResource == value) return;
|
||||
|
||||
if (value > _currentResource)
|
||||
{
|
||||
_currentResource = value;
|
||||
|
||||
if (_currentResource >= MaxResource) {
|
||||
_currentResource = MaxResource;
|
||||
EmitSignal(SignalName.ResourceMaxed, MaxResource);
|
||||
}
|
||||
else if (_currentResource <= 0)
|
||||
{
|
||||
EmitSignal(SignalName.ResourceDepleted);
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.ResourceChanged, _currentResource, MaxResource);
|
||||
EmitSignal(SignalName.ResourceIncreased, _currentResource, value, MaxResource);
|
||||
}
|
||||
else if (value < _currentResource)
|
||||
{
|
||||
EmitSignal(SignalName.ResourceDecreased, _currentResource, value, MaxResource);
|
||||
}
|
||||
|
||||
_currentResource = value;
|
||||
|
||||
if (_currentResource >= MaxResource) {
|
||||
_currentResource = MaxResource;
|
||||
EmitSignal(SignalName.ResourceMaxed, MaxResource);
|
||||
}
|
||||
else if (_currentResource <= 0)
|
||||
{
|
||||
EmitSignal(SignalName.ResourceDepleted);
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.ResourceChanged, _currentResource, MaxResource);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,13 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
|
||||
[Signal]
|
||||
public delegate void HealthChangedEventHandler(float newValue, float maxValue);
|
||||
[Signal]
|
||||
public delegate void HealthDecreasedEventHandler(float value, float newValue, float maxValue);
|
||||
|
||||
[Signal]
|
||||
public delegate void ShieldChangedEventHandler(float newValue, float maxValue);
|
||||
[Signal]
|
||||
public delegate void ShieldDecreasedEventHandler(float value, float newValue, float maxValue);
|
||||
|
||||
[Signal]
|
||||
public delegate void DeathEventHandler();
|
||||
|
|
@ -42,12 +46,24 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
_healthProvider.ResourceChanged += ((value, maxValue) =>
|
||||
{
|
||||
//if (!Enabled) return;
|
||||
Hud.Instance?.UpdateHealth(value, maxValue);
|
||||
EmitSignal(SignalName.HealthChanged, value, maxValue);
|
||||
});
|
||||
|
||||
_healthProvider.ResourceDecreased += (value, newValue, maxValue) =>
|
||||
{
|
||||
EmitSignal(SignalName.HealthDecreased, value, newValue, maxValue);
|
||||
};
|
||||
|
||||
_shieldProvider.ResourceDecreased += (value, newValue, maxValue) =>
|
||||
{
|
||||
EmitSignal(SignalName.ShieldDecreased, value, newValue, maxValue);
|
||||
};
|
||||
|
||||
_shieldProvider.ResourceChanged += ((value, maxValue) =>
|
||||
{
|
||||
//if (!Enabled) return;
|
||||
Hud.Instance?.UpdateShield(value, maxValue);
|
||||
EmitSignal(SignalName.ShieldChanged, value, maxValue);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ public partial class Active : PlayerFSMState
|
|||
[Export] private PlayerDamageReceiver _damageReceiver;
|
||||
[Export] private ActivationProvider _activationProvider;
|
||||
|
||||
[Export] private InteractionController _interactionController;
|
||||
|
||||
private bool _isStrafing;
|
||||
|
||||
public int MovementSpeed => _isStrafing ? StrafeSpeed : Speed;
|
||||
|
|
@ -51,16 +53,16 @@ public partial class Active : PlayerFSMState
|
|||
ChangeState(PlayerState.Dead);
|
||||
};
|
||||
|
||||
_damageReceiver.HealthChanged += (value, maxValue) =>
|
||||
_damageReceiver.HealthDecreased += (value, newValue, maxValue) =>
|
||||
{
|
||||
_animationProvider.Blink();
|
||||
_hud.UpdateHealth(value, maxValue);
|
||||
//_hud.UpdateHealth(value, maxValue);
|
||||
};
|
||||
|
||||
_damageReceiver.ShieldChanged += (value, maxValue) =>
|
||||
_damageReceiver.ShieldDecreased += (value, newValue, maxValue) =>
|
||||
{
|
||||
_animationProvider.PlayShieldAnimation();
|
||||
_hud.UpdateShield(value, maxValue);
|
||||
//_hud.UpdateShield(value, maxValue);
|
||||
};
|
||||
|
||||
_damageReceiver.Init();
|
||||
|
|
@ -84,6 +86,7 @@ public partial class Active : PlayerFSMState
|
|||
_animationProvider.ShowSprite();
|
||||
_damageReceiver.Enabled = true;
|
||||
_activationProvider.Enabled = true;
|
||||
_interactionController.Enabled = true;
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
|
|
@ -94,6 +97,7 @@ public partial class Active : PlayerFSMState
|
|||
|
||||
_damageReceiver.Enabled = false;
|
||||
_activationProvider.Enabled = false;
|
||||
_interactionController.Enabled = false;
|
||||
}
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Player;
|
||||
|
||||
public partial class Init : PlayerFSMState
|
||||
{
|
||||
[Export]
|
||||
private PlayerAnimationProvider _animationProvider;
|
||||
public override void EnterState()
|
||||
{
|
||||
GD.Print(this.State.ToString());
|
||||
_animationProvider.PlayUnteleportAnimation();
|
||||
_ = AutoSwitchToStart();
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
|
|
@ -24,4 +28,10 @@ public partial class Init : PlayerFSMState
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
private async Task AutoSwitchToStart()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
_stateMachine.SetState((int)PlayerState.Active);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue