mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 04:55:54 +00:00
Delay start for animation
This commit is contained in:
parent
1005796e13
commit
a9a7b234fb
9 changed files with 108 additions and 23 deletions
|
|
@ -115,13 +115,13 @@ collision_layer = 2
|
|||
collision_mask = 97
|
||||
platform_wall_layers = 97
|
||||
script = ExtResource("1_mpmil")
|
||||
InitialState = 1
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Init" type="Node2D" parent="."]
|
||||
[node name="Init" type="Node2D" parent="." node_paths=PackedStringArray("_animationProvider")]
|
||||
script = ExtResource("2_i6wc8")
|
||||
_animationProvider = NodePath("../AnimationProvider")
|
||||
|
||||
[node name="Active" type="Node2D" parent="." node_paths=PackedStringArray("_weaponProvider", "_animationProvider", "_crosshairProvider", "_hitboxSpriteProvider", "_inputProvider", "_damageReceiver", "_activationProvider")]
|
||||
[node name="Active" type="Node2D" parent="." node_paths=PackedStringArray("_weaponProvider", "_animationProvider", "_crosshairProvider", "_hitboxSpriteProvider", "_inputProvider", "_damageReceiver", "_activationProvider", "_interactionController")]
|
||||
script = ExtResource("3_3tuio")
|
||||
_weaponProvider = NodePath("../WeaponProvider")
|
||||
_animationProvider = NodePath("../AnimationProvider")
|
||||
|
|
@ -130,6 +130,7 @@ _hitboxSpriteProvider = NodePath("../StrafeSpriteProvider")
|
|||
_inputProvider = NodePath("../InputProvider")
|
||||
_damageReceiver = NodePath("../DamageReceiver")
|
||||
_activationProvider = NodePath("../InteractionProvider")
|
||||
_interactionController = NodePath("../InteractionController")
|
||||
State = 1
|
||||
|
||||
[node name="Cutscene" type="Node2D" parent="." node_paths=PackedStringArray("_animationProvider")]
|
||||
|
|
|
|||
|
|
@ -44,10 +44,12 @@ lifetime = 0.8
|
|||
process_material = SubResource("ParticleProcessMaterial_we5sc")
|
||||
|
||||
[node name="TeleportStart" type="AudioStreamPlayer2D" parent="."]
|
||||
process_mode = 3
|
||||
stream = ExtResource("3_ox1iw")
|
||||
max_distance = 100.0
|
||||
|
||||
[node name="TeleportEnd" type="AudioStreamPlayer2D" parent="."]
|
||||
process_mode = 3
|
||||
stream = ExtResource("4_ildd2")
|
||||
max_distance = 100.0
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,25 @@ using System;
|
|||
|
||||
public partial class InteractionController : Area2D
|
||||
{
|
||||
private bool _enabled = false;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
if (_enabled == value) return;
|
||||
_enabled = value;
|
||||
if (_enabled)
|
||||
{
|
||||
EmitSignal(SignalName.InteractionStarted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Signal]
|
||||
public delegate void InteractionStartedEventHandler();
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ SpawnMarkers = Dictionary[int, NodePath]({
|
|||
2: NodePath("Factory Tilemaps/LevelProps/BossDebugTeleporterDestination"),
|
||||
255: NodePath("Factory Tilemaps/Debug Room/DebugRoomStartPosition")
|
||||
})
|
||||
StartingEquipment = Array[ExtResource("6_8tdlb")]([ExtResource("4_swym2"), ExtResource("5_nqier")])
|
||||
StartingEquipment = [ExtResource("4_swym2"), ExtResource("5_nqier")]
|
||||
MapStartData = SubResource("Resource_6sau4")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
|
|
@ -923,7 +923,7 @@ position = Vector2(-1506, -188)
|
|||
Events = Array[Object]([SubResource("Resource_hppa0")])
|
||||
|
||||
[node name="LevelStartTrigger" parent="Factory Tilemaps/LevelProps" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-776, -160)
|
||||
position = Vector2(-808, -166)
|
||||
scale = Vector2(1.455, 1.455)
|
||||
Events = Array[Object]([SubResource("Resource_5er5x"), SubResource("Resource_b25hy")])
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ public partial class AreaTrigger : Area2D
|
|||
private int _activations = 0;
|
||||
|
||||
[Signal]
|
||||
public delegate void ActivatedEventHandler();
|
||||
public delegate void ActivatedEventHandler();
|
||||
|
||||
private InteractionController _cachedPlayer;
|
||||
|
||||
private bool Activate()
|
||||
{
|
||||
|
|
@ -47,6 +49,23 @@ public partial class AreaTrigger : Area2D
|
|||
private void _on_area_entered(Area2D area)
|
||||
{
|
||||
if (area is not InteractionController player) return;
|
||||
if (player.Enabled)
|
||||
{
|
||||
Activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
_cachedPlayer = player;
|
||||
_cachedPlayer.InteractionStarted += PlayerOnInteractionStarted;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayerOnInteractionStarted()
|
||||
{
|
||||
Activate();
|
||||
if (_cachedPlayer != null)
|
||||
{
|
||||
_cachedPlayer.InteractionStarted -= PlayerOnInteractionStarted;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue