Motivation

This commit is contained in:
Marco 2025-03-31 18:28:33 +02:00
commit e73596e464
13 changed files with 100 additions and 34 deletions

View file

@ -32,6 +32,8 @@ public partial class Dead : EnemyStateBase
DropsProvider.DropLoot();
GameManager.Instance.AddMotivation(StorageModule.EnemyData.MotivationReward);
StorageModule.Root.QueueFree();
}
}

View file

@ -16,12 +16,23 @@ public partial class Dead : PlayerStateBase
[Export]
private ActorResourceProvider _healthProvider;
[Export]
private ActorResourceProvider _motivationProvider;
public override void EnterState()
{
_animationProvider.PlayDeathAnimation();
// show game over
Hud.Instance.ShowGameOver();
if (_motivationProvider.CurrentResource < 100f)
{
// If motivation is not enough show game over scene
GD.Print("Game over");
}
else
{
// Else show respawn notification
Hud.Instance.ShowGameOver();
}
}
public override void ExitState()
@ -49,6 +60,12 @@ public partial class Dead : PlayerStateBase
MainObject.GlobalPosition = GameManager.Instance.LastCheckpointPosition;
_healthProvider.FillResource();
GameManager.Instance.ClearBullets();
_motivationProvider.CurrentResource -= 100f;
if (_motivationProvider.CurrentResource <= 1f)
{
_motivationProvider.CurrentResource = 1f;
}
ChangeState(PlayerState.Active);
}

View file

@ -1,4 +1,5 @@
using System;
using Cirno.Scripts.Components.Actors;
using Godot;
namespace Cirno.Scripts.Components.FSM;
@ -9,6 +10,8 @@ public partial class PlayerStateMachine : StateMachineBase<PlayerState, Characte
[Export] public Vector2 StartingDirection { get; set; } = Vector2.Down;
[Export] public ActorResourceProvider MotivationResource { get; private set; }
public void RefillHealth()
{
GD.Print("Refilling health");
@ -23,5 +26,10 @@ public partial class PlayerStateMachine : StateMachineBase<PlayerState, Characte
{
GD.Print("NoClip");
}
public void AddMotivation(float motivation)
{
MotivationResource.CurrentResource += motivation;
}
}