mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Motivation
This commit is contained in:
parent
c9b703a0ae
commit
e73596e464
13 changed files with 100 additions and 34 deletions
|
|
@ -22,6 +22,7 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
|
||||
[Export] public float BaseHealth { get; private set; } = 32f;
|
||||
[Export] public float BaseShield { get; private set; } = 32f;
|
||||
[Export] public float BaseMotivation { get; private set; } = 100f;
|
||||
|
||||
[Export] public float HealthExtendAmount { get; private set; } = 4f;
|
||||
[Export] public float ShieldExtendAmount { get; private set; } = 4f;
|
||||
|
|
@ -31,6 +32,7 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
private ActorResourceProvider _healthProvider;
|
||||
[Export]
|
||||
private ActorResourceProvider _shieldProvider;
|
||||
[Export] private ActorResourceProvider _motivationProvider;
|
||||
|
||||
[ExportCategory("Damage Types")]
|
||||
[Export] public StringName AcidGroupName { get; private set; } = "Acid";
|
||||
|
|
@ -62,6 +64,12 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
get => _shieldProvider.CurrentResource;
|
||||
set => _shieldProvider.CurrentResource = value;
|
||||
}
|
||||
|
||||
public float CurrentMotivation
|
||||
{
|
||||
get => _motivationProvider.CurrentResource;
|
||||
set => _motivationProvider.CurrentResource = value;
|
||||
}
|
||||
|
||||
private IStateMachine<PlayerState, CharacterBody2D> _stateMachine;
|
||||
|
||||
|
|
@ -110,6 +118,11 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
|
||||
SetMaxResources();
|
||||
};
|
||||
|
||||
_motivationProvider.ResourceChanged += (value, maxValue) =>
|
||||
{
|
||||
Hud.Instance?.UpdateMotivation(value, maxValue);
|
||||
};
|
||||
}
|
||||
|
||||
private void SetMaxResources()
|
||||
|
|
@ -121,6 +134,8 @@ public partial class PlayerDamageReceiver : Area2D
|
|||
_healthProvider.MaxResource = BaseHealth + (healthExtends * HealthExtendAmount);
|
||||
|
||||
_shieldProvider.MaxResource = BaseShield + (shieldExtends * ShieldExtendAmount);
|
||||
|
||||
_motivationProvider.CurrentResource = BaseMotivation;
|
||||
}
|
||||
|
||||
public void RefillHealth()
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ public partial class Dead : EnemyStateBase
|
|||
|
||||
DropsProvider.DropLoot();
|
||||
|
||||
GameManager.Instance.AddMotivation(StorageModule.EnemyData.MotivationReward);
|
||||
|
||||
StorageModule.Root.QueueFree();
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,11 @@ public partial class GameManager : Node2D
|
|||
StartingEquipment.AddRange(mapStartData.StartingEquipment);
|
||||
}
|
||||
|
||||
public void AddMotivation(float motivation)
|
||||
{
|
||||
Player.AddMotivation(motivation);
|
||||
}
|
||||
|
||||
public void ApplySessionState(SessionSettings settings)
|
||||
{
|
||||
//_inventoryManager.Load(settings.Items);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
[Export] private Label _shieldLabel;
|
||||
[Export] private ProgressBar _shieldBar;
|
||||
|
||||
[Export] private Label _motivationLabel;
|
||||
|
||||
[Export] private Container _itemsContainer;
|
||||
|
||||
|
|
@ -91,18 +93,6 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
_gameOverPanel.Show();
|
||||
_playerDead = true;
|
||||
|
||||
// ShowMessage("Game Over");
|
||||
//
|
||||
// var messageTimer = GetNode<Timer>("MessageTimer");
|
||||
// await ToSignal(messageTimer, Timer.SignalName.Timeout);
|
||||
//
|
||||
// var message = GetNode<Label>("Message");
|
||||
// message.Text = "Dodge the Creeps!";
|
||||
// message.Show();
|
||||
//
|
||||
// await ToSignal(GetTree().CreateTimer(1.0), SceneTreeTimer.SignalName.Timeout);
|
||||
// GetNode<Button>("StartButton").Show();
|
||||
}
|
||||
|
||||
public void HideGameOver()
|
||||
|
|
@ -135,6 +125,11 @@ public partial class Hud : CanvasLayer
|
|||
_shieldBar.Value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateMotivation(float newValue, float maxValue)
|
||||
{
|
||||
_motivationLabel.Text = $"{newValue}%";
|
||||
}
|
||||
|
||||
public void UpdateInteractable(Interactable interactable) {
|
||||
GD.Print($"Interactable ${interactable.Name} entered in HUD");
|
||||
|
|
@ -339,4 +334,6 @@ public partial class Hud : CanvasLayer
|
|||
|
||||
AddInventoryItem(item.Item, item.Count);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public partial class EnemyResource : Resource
|
|||
[Export] public WeaponResource Weapon { get; private set; }
|
||||
|
||||
[Export] public Array<LootDrop> LootDrops { get; private set; } = [];
|
||||
|
||||
[Export] public float MotivationReward { get; private set; } = 4f;
|
||||
[ExportCategory("AI")] [Export] public float PlayerDetectionRange { get; private set; } = 90f;
|
||||
[Export] public float ViewRange { get; private set; } = 120f;
|
||||
[Export] public float AlarmReactRange { get; private set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue