mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Health and shield gauges
This commit is contained in:
parent
9e04056800
commit
3682de18d5
14 changed files with 188 additions and 22 deletions
|
|
@ -35,7 +35,6 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
private AnimatedSprite2D _animatedSprite;
|
||||
|
||||
private Vector2 _movementDirection { get; set; }
|
||||
|
||||
private Vector2 _facingDirection { get; set; }
|
||||
|
||||
private Vector2 _rightStickInput { get; set; }
|
||||
|
|
@ -43,6 +42,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
private Sprite2D _crosshair;
|
||||
|
||||
[Export] public float MaxHealth = 32f;
|
||||
[Export] public float MaxShield = 32f;
|
||||
|
||||
public Weapon EquippedWeapon { get; set; }
|
||||
|
||||
|
|
@ -51,6 +51,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
public int CurrentWeaponIndex { get; set; } = 0;
|
||||
|
||||
private float _currentHealth = 0f;
|
||||
private float _currentShield = 0f;
|
||||
|
||||
private bool _isDestroyed = false;
|
||||
|
||||
|
|
@ -66,6 +67,9 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
[Signal]
|
||||
public delegate void HealthChangedEventHandler(float newHealth, float MaxHealth);
|
||||
|
||||
[Signal]
|
||||
public delegate void ShieldChangedEventHandler(float newShield, float maxShield);
|
||||
|
||||
[Signal]
|
||||
public delegate void InteractableAreaEnteredEventHandler(Interactable interactable);
|
||||
|
|
@ -86,11 +90,25 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
}
|
||||
}
|
||||
|
||||
public float CurrentShield
|
||||
{
|
||||
get => _currentShield;
|
||||
set
|
||||
{
|
||||
if (_currentShield != value)
|
||||
{
|
||||
_currentShield = value;
|
||||
EmitSignal(nameof(ShieldChanged), _currentShield, MaxShield);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private InventoryManager _inventoryManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CurrentHealth = MaxHealth;
|
||||
CurrentShield = MaxShield;
|
||||
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
||||
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue