This commit is contained in:
2026-03-15 21:26:59 +01:00
parent 95616f61fc
commit 50de6abb5d
9 changed files with 52 additions and 15 deletions

View File

@@ -13,7 +13,7 @@ public partial class RManaRegen(float manaRegenRate, float frequency) : Resource
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
public float ManaRegenRate { get; set; } = manaRegenRate;
[Export(PropertyHint.Range, "0.01,1,0.1,or_greater")]
[Export(PropertyHint.Range, "0.01,1,0.01,or_greater")]
public float Frequency { get; set; } = frequency;
public RManaRegen() : this(1.0f, 0.1f)

View File

@@ -111,6 +111,9 @@ radius = 1.5
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
blend_mode = 1
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_n24vh"]
bg_color = Color(0.15869555, 0.64034444, 0.906125, 1)
[node name="Player" type="CharacterBody3D" unique_id=709076448]
collision_mask = 272
script = ExtResource("1_poq2x")
@@ -555,6 +558,22 @@ offset_bottom = -71.99939
grow_horizontal = 2
grow_vertical = 0
[node name="Manabar" parent="UI" unique_id=1713862004 instance=ExtResource("47_76kmc")]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -859.0
offset_top = -84.0
offset_right = -347.0
offset_bottom = -72.0
grow_horizontal = 2
grow_vertical = 0
BarStyle = SubResource("StyleBoxFlat_n24vh")
[node name="StateChart" type="Node" parent="." unique_id=1675830632]
script = ExtResource("25_wv70j")
metadata/_custom_type_script = "uid://couw105c3bde4"

View File

@@ -5,9 +5,10 @@ using Movementtests.interfaces;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
public partial class PlayerUi : Control
{
internal TextureRect[] _dashIcons = new TextureRect[3];
private TextureRect _enemyTarget;
private Healthbar _healthbar;
internal TextureRect[] DashIcons = new TextureRect[3];
private TextureRect _enemyTarget = null!;
private Healthbar _healthbar = null!;
private Healthbar _manabar = null!;
public enum TargetState
{
@@ -25,12 +26,13 @@ public partial class PlayerUi : Control
public override void _Ready()
{
_dashIcons[0] = GetNode<TextureRect>("%Dash1");
_dashIcons[1] = GetNode<TextureRect>("%Dash2");
_dashIcons[2] = GetNode<TextureRect>("%Dash3");
DashIcons[0] = GetNode<TextureRect>("%Dash1");
DashIcons[1] = GetNode<TextureRect>("%Dash2");
DashIcons[2] = GetNode<TextureRect>("%Dash3");
_enemyTarget = GetNode<TextureRect>("%EnemyTarget");
_healthbar = GetNode<Healthbar>("%Healthbar");
_manabar = GetNode<Healthbar>("%Manabar");
}
public void Initialize(float initialHealth)
@@ -59,7 +61,7 @@ public partial class PlayerUi : Control
public void SetNumberOfDashesLeft(int numberOfDashes)
{
int index = 1;
foreach (var dashIcon in _dashIcons)
foreach (var dashIcon in DashIcons)
{
dashIcon.SetVisible(index <= numberOfDashes);
index++;
@@ -70,4 +72,10 @@ public partial class PlayerUi : Control
{
_healthbar.CurrentHealth = healthChanged.CurrentHealth;
}
public void OnManaChanged(float newValue)
{
_manabar.CurrentHealth = newValue;
GD.Print("mana changed");
}
}

View File

@@ -6,5 +6,5 @@
script = ExtResource("1_1rxoq")
Cost = 50.0
Cooldown = 1.0
ManaRegenPause = 3.0
ManaRegenPause = 2.0
metadata/_custom_type_script = "uid://d0l07gcx1ef18"

View File

@@ -5,5 +5,5 @@
[resource]
script = ExtResource("1_ecb1p")
ManaRegenRate = 20.0
Frequency = 0.1
Frequency = 0.05
metadata/_custom_type_script = "uid://di04jvuqp0h7m"

View File

@@ -2309,13 +2309,18 @@ public partial class PlayerController : CharacterBody3D,
HandleEnemyTargeting();
}
private float _oldMana = 100;
public override void _Process(double delta)
{
// Manage head and camera movement
LookAround(delta);
EffectsManager.UpdateEffects(delta);
GD.Print(Attributes["PlayerAttributeSet.Mana"].CurrentValue);
// TODO: change for actual Cue
var currentMana = Attributes["PlayerAttributeSet.Mana"].CurrentValue;
if (Mathf.Abs(currentMana - _oldMana) > Mathf.Epsilon)
PlayerUi.OnManaChanged(currentMana);
_oldMana = currentMana;
}
///////////////////////////

View File

@@ -4,8 +4,10 @@ using System;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_heart.png")]
public partial class Healthbar : ProgressBar
{
private Timer _damageCatchUpTimer;
private ProgressBar _damagedHealth;
private Timer _damageCatchUpTimer = null!;
private ProgressBar _damagedHealth = null!;
[Export] public StyleBox? BarStyle;
private float _currentHealth;
public float CurrentHealth
@@ -21,6 +23,9 @@ public partial class Healthbar : ProgressBar
_damageCatchUpTimer.Timeout += OnDamageCatchUp;
Visible = false;
if (BarStyle != null)
AddThemeStyleboxOverride("fill", BarStyle);
}
public void Initialize(float initialHealth)

View File

@@ -5,7 +5,7 @@
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0sgot"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0k5hr"]
bg_color = Color(0.698864, 0.047356047, 0, 1)
bg_color = Color(0.69803923, 0.047058824, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0sgot"]
bg_color = Color(0.14767182, 0.14767182, 0.14767176, 1)

View File

@@ -99,7 +99,7 @@ public class PlayerControllerUnitTest
{
var mockUi = new PlayerUi();
var dashIcons = new TextureRect[3] { new TextureRect(), new TextureRect(), new TextureRect() };
mockUi._dashIcons = dashIcons;
mockUi.DashIcons = dashIcons;
_player.PlayerUi = mockUi;