mana bar
This commit is contained in:
@@ -13,7 +13,7 @@ public partial class RManaRegen(float manaRegenRate, float frequency) : Resource
|
|||||||
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
|
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
|
||||||
public float ManaRegenRate { get; set; } = manaRegenRate;
|
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 float Frequency { get; set; } = frequency;
|
||||||
|
|
||||||
public RManaRegen() : this(1.0f, 0.1f)
|
public RManaRegen() : this(1.0f, 0.1f)
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ radius = 1.5
|
|||||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
|
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_2q0ik"]
|
||||||
blend_mode = 1
|
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]
|
[node name="Player" type="CharacterBody3D" unique_id=709076448]
|
||||||
collision_mask = 272
|
collision_mask = 272
|
||||||
script = ExtResource("1_poq2x")
|
script = ExtResource("1_poq2x")
|
||||||
@@ -555,6 +558,22 @@ offset_bottom = -71.99939
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 0
|
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]
|
[node name="StateChart" type="Node" parent="." unique_id=1675830632]
|
||||||
script = ExtResource("25_wv70j")
|
script = ExtResource("25_wv70j")
|
||||||
metadata/_custom_type_script = "uid://couw105c3bde4"
|
metadata/_custom_type_script = "uid://couw105c3bde4"
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ using Movementtests.interfaces;
|
|||||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
|
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
|
||||||
public partial class PlayerUi : Control
|
public partial class PlayerUi : Control
|
||||||
{
|
{
|
||||||
internal TextureRect[] _dashIcons = new TextureRect[3];
|
internal TextureRect[] DashIcons = new TextureRect[3];
|
||||||
private TextureRect _enemyTarget;
|
private TextureRect _enemyTarget = null!;
|
||||||
private Healthbar _healthbar;
|
private Healthbar _healthbar = null!;
|
||||||
|
private Healthbar _manabar = null!;
|
||||||
|
|
||||||
public enum TargetState
|
public enum TargetState
|
||||||
{
|
{
|
||||||
@@ -25,12 +26,13 @@ public partial class PlayerUi : Control
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_dashIcons[0] = GetNode<TextureRect>("%Dash1");
|
DashIcons[0] = GetNode<TextureRect>("%Dash1");
|
||||||
_dashIcons[1] = GetNode<TextureRect>("%Dash2");
|
DashIcons[1] = GetNode<TextureRect>("%Dash2");
|
||||||
_dashIcons[2] = GetNode<TextureRect>("%Dash3");
|
DashIcons[2] = GetNode<TextureRect>("%Dash3");
|
||||||
|
|
||||||
_enemyTarget = GetNode<TextureRect>("%EnemyTarget");
|
_enemyTarget = GetNode<TextureRect>("%EnemyTarget");
|
||||||
_healthbar = GetNode<Healthbar>("%Healthbar");
|
_healthbar = GetNode<Healthbar>("%Healthbar");
|
||||||
|
_manabar = GetNode<Healthbar>("%Manabar");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(float initialHealth)
|
public void Initialize(float initialHealth)
|
||||||
@@ -59,7 +61,7 @@ public partial class PlayerUi : Control
|
|||||||
public void SetNumberOfDashesLeft(int numberOfDashes)
|
public void SetNumberOfDashesLeft(int numberOfDashes)
|
||||||
{
|
{
|
||||||
int index = 1;
|
int index = 1;
|
||||||
foreach (var dashIcon in _dashIcons)
|
foreach (var dashIcon in DashIcons)
|
||||||
{
|
{
|
||||||
dashIcon.SetVisible(index <= numberOfDashes);
|
dashIcon.SetVisible(index <= numberOfDashes);
|
||||||
index++;
|
index++;
|
||||||
@@ -70,4 +72,10 @@ public partial class PlayerUi : Control
|
|||||||
{
|
{
|
||||||
_healthbar.CurrentHealth = healthChanged.CurrentHealth;
|
_healthbar.CurrentHealth = healthChanged.CurrentHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnManaChanged(float newValue)
|
||||||
|
{
|
||||||
|
_manabar.CurrentHealth = newValue;
|
||||||
|
GD.Print("mana changed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,5 @@
|
|||||||
script = ExtResource("1_1rxoq")
|
script = ExtResource("1_1rxoq")
|
||||||
Cost = 50.0
|
Cost = 50.0
|
||||||
Cooldown = 1.0
|
Cooldown = 1.0
|
||||||
ManaRegenPause = 3.0
|
ManaRegenPause = 2.0
|
||||||
metadata/_custom_type_script = "uid://d0l07gcx1ef18"
|
metadata/_custom_type_script = "uid://d0l07gcx1ef18"
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_ecb1p")
|
script = ExtResource("1_ecb1p")
|
||||||
ManaRegenRate = 20.0
|
ManaRegenRate = 20.0
|
||||||
Frequency = 0.1
|
Frequency = 0.05
|
||||||
metadata/_custom_type_script = "uid://di04jvuqp0h7m"
|
metadata/_custom_type_script = "uid://di04jvuqp0h7m"
|
||||||
|
|||||||
@@ -2309,13 +2309,18 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
HandleEnemyTargeting();
|
HandleEnemyTargeting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float _oldMana = 100;
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
// Manage head and camera movement
|
// Manage head and camera movement
|
||||||
LookAround(delta);
|
LookAround(delta);
|
||||||
|
|
||||||
EffectsManager.UpdateEffects(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ using System;
|
|||||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_heart.png")]
|
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_heart.png")]
|
||||||
public partial class Healthbar : ProgressBar
|
public partial class Healthbar : ProgressBar
|
||||||
{
|
{
|
||||||
private Timer _damageCatchUpTimer;
|
private Timer _damageCatchUpTimer = null!;
|
||||||
private ProgressBar _damagedHealth;
|
private ProgressBar _damagedHealth = null!;
|
||||||
|
|
||||||
|
[Export] public StyleBox? BarStyle;
|
||||||
|
|
||||||
private float _currentHealth;
|
private float _currentHealth;
|
||||||
public float CurrentHealth
|
public float CurrentHealth
|
||||||
@@ -21,6 +23,9 @@ public partial class Healthbar : ProgressBar
|
|||||||
|
|
||||||
_damageCatchUpTimer.Timeout += OnDamageCatchUp;
|
_damageCatchUpTimer.Timeout += OnDamageCatchUp;
|
||||||
Visible = false;
|
Visible = false;
|
||||||
|
|
||||||
|
if (BarStyle != null)
|
||||||
|
AddThemeStyleboxOverride("fill", BarStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(float initialHealth)
|
public void Initialize(float initialHealth)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0sgot"]
|
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0sgot"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0k5hr"]
|
[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"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0sgot"]
|
||||||
bg_color = Color(0.14767182, 0.14767182, 0.14767176, 1)
|
bg_color = Color(0.14767182, 0.14767182, 0.14767176, 1)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class PlayerControllerUnitTest
|
|||||||
{
|
{
|
||||||
var mockUi = new PlayerUi();
|
var mockUi = new PlayerUi();
|
||||||
var dashIcons = new TextureRect[3] { new TextureRect(), new TextureRect(), new TextureRect() };
|
var dashIcons = new TextureRect[3] { new TextureRect(), new TextureRect(), new TextureRect() };
|
||||||
mockUi._dashIcons = dashIcons;
|
mockUi.DashIcons = dashIcons;
|
||||||
|
|
||||||
_player.PlayerUi = mockUi;
|
_player.PlayerUi = mockUi;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user